This is a helper library of muellan/clipp, the awesome C++ command-line parser.
- Support using nlohmann/json as a
boost::program_options::variables_map
-like object, which makes it possible to print all the variables at once to console/files in a computer-readable format. - Create a pair of
clipp::option
andclipp::value
(as aclipp::group
) with a doc string including its default value. - Use
std::sto***()
to validate arguments and convert strings. A proper function is chosen for eachclipp::value
based on the type of its target variable. - Support comma separated values for vector targets, e.g.,
-v 1,2,3
. - Support limiting choices of values.
- Accept
=
as an optional separator of a flag and its value, e.g.,--longopt=value
is treated almost equally as--longopt value
. - Support
CMake
building system.
The easiest way is to use Homebrew. The following command installs tumopp and all the dependencies:
brew install heavywatal/tap/clippson
Alternatively, you can get the source code from GitHub manually:
git clone https://github.com/heavywatal/clippson.git
cd clippson/
DESTINATION=${HOME}/local
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=$DESTINATION
cmake --build build -j2
cmake --install build
clippson.hpp
and the required headers, clipp.h
and json.hpp
, are installed to ${CMAKE_INSTALL_PREFIX}/include/clippson/
.
Add #include <clippson/clippson.hpp>
to your source code.
Functions are defined in the namespace clippson::
.
The required headers clipp.h
and json.hpp
are included therein, hence their functions are available in the original namespaces.
See test/example.cpp for more details.
This library can be imported as a CMake package:
find_package(clippson REQUIRED)
target_link_libraries(your_project PRIVATE clippson::clippson)