cxxopts

Lightweight C++ command-line option parser library for developers

brewmacoslinux
Try with needOr install directly
Source

About

Lightweight C++ command-line option parser

Commands

cxxopts

Examples

Include cxxopts header in C++ project to parse command-line arguments$ #include <cxxopts.hpp> cxxopts::Options options("program", "Description"); options.add_options()("h,help", "Print help");
Parse arguments with positional and optional parameters$ cxxopts::Options opts("myapp"); opts.add_options()("f,file", "Input file", cxxopts::value<std::string>()); auto result = opts.parse(argc, argv);
Access parsed arguments and check for help flag$ if(result.count("help")) { std::cout << opts.help() << std::endl; } std::string file = result["file"].as<std::string>();