Skip to content

๐Ÿ“Ž Helper library of clipp, C++ command-line parser

License

Notifications You must be signed in to change notification settings

heavywatal/clippson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

clippson

Build status

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 and clipp::value (as a clipp::group) with a doc string including its default value.
  • Use std::sto***() to validate arguments and convert strings. A proper function is chosen for each clipp::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.

Installation

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/.

Usage

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)

About

๐Ÿ“Ž Helper library of clipp, C++ command-line parser

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published