mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 12:13:52 +00:00
in progress: formatters Getting closer Working on apps One test actually runs All builds, added filter functions Reverting a few behavours as needed Repairs All tests pass Fixing error with adding help flag Labels are simpler mappings, normalized setters Adding help_all Adding a few more tests One more line tested Adding one more check Adding to readme Simplify naming Adding default constructors Fixing spacing issues with subcommand all printout Adding a couple of tests
28 lines
1011 B
C++
28 lines
1011 B
C++
#include "CLI/CLI.hpp"
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
CLI::App app("K3Pi goofit fitter");
|
|
app.set_help_all_flag("--help-all", "Expand all help");
|
|
app.add_flag("--random", "Some random flag");
|
|
CLI::App *start = app.add_subcommand("start", "A great subcommand");
|
|
CLI::App *stop = app.add_subcommand("stop", "Do you really want to stop?");
|
|
app.require_subcommand(); // 1 or more
|
|
|
|
std::string file;
|
|
start->add_option("-f,--file", file, "File name");
|
|
|
|
CLI::Option *s = stop->add_flag("-c,--count", "Counter");
|
|
|
|
CLI11_PARSE(app, argc, argv);
|
|
|
|
std::cout << "Working on --file from start: " << file << std::endl;
|
|
std::cout << "Working on --count from stop: " << s->count() << ", direct count: " << stop->count("--count")
|
|
<< std::endl;
|
|
std::cout << "Count of --random flag: " << app.count("--random") << std::endl;
|
|
for(auto subcom : app.get_subcommands())
|
|
std::cout << "Subcommand: " << subcom->get_name() << std::endl;
|
|
|
|
return 0;
|
|
}
|