| 10 | #include <string> |
| 11 | |
| 12 | int main(int argc, char **argv) { |
| 13 | CLI::AutoTimer give_me_a_name("This is a timer"); |
| 14 | |
| 15 | CLI::App app("K3Pi goofit fitter"); |
| 16 | |
| 17 | std::string file; |
| 18 | CLI::Option *opt = app.add_option("-f,--file,file", file, "File name")->required()->group("Important"); |
| 19 | |
| 20 | int count{0}; |
| 21 | CLI::Option *copt = app.add_flag("-c,--count", count, "Counter")->required()->group("Important"); |
| 22 | |
| 23 | double value{0.0}; // = 3.14; |
| 24 | app.add_option("-d,--double", value, "Some Value")->group("Other"); |
| 25 | |
| 26 | try { |
| 27 | app.parse(argc, argv); |
| 28 | } catch(const CLI::ParseError &e) { |
| 29 | return app.exit(e); |
| 30 | } |
| 31 | |
| 32 | std::cout << "Working on file: " << file << ", direct count: " << app.count("--file") |
| 33 | << ", opt count: " << opt->count() << '\n'; |
| 34 | std::cout << "Working on count: " << count << ", direct count: " << app.count("--count") |
| 35 | << ", opt count: " << copt->count() << '\n'; |
| 36 | std::cout << "Some value: " << value << '\n'; |
| 37 | |
| 38 | return 0; |
| 39 | } |