Lightweight C++ command-line option parser for building CLI applications
Lightweight C++ command-line option parser
$ #include <cxxopts.hpp>
cxxopts::Options options("program");
options.add_options()("h,help", "Print help");$ options.add_options()("input,i", "Input file", cxxopts::value<std::string>())("verbose,v", "Enable verbose mode", cxxopts::value<bool>()->default_value("false"));$ auto result = options.parse(argc, argv);
if (result.count("help")) { std::cout << options.help() << std::endl; }$ std::string input = result["input"].as<std::string>();
bool verbose = result["verbose"].as<bool>();$ std::cout << options.help() << std::endl;