MCPcopy Create free account
hub / github.com/CLIUtils/CLI11 / main

Function main

examples/groups.cpp:12–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include <string>
11
12int 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}

Callers

nothing calls this directly

Calls 6

add_flagMethod · 0.80
parseMethod · 0.80
exitMethod · 0.80
groupMethod · 0.45
requiredMethod · 0.45
add_optionMethod · 0.45

Tested by

no test coverage detected