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

Function main

examples/simple.cpp:11–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <string>
10
11int main(int argc, char **argv) {
12
13 CLI::App app("K3Pi goofit fitter");
14 // add version output
15 app.set_version_flag("--version", std::string(CLI11_VERSION));
16 std::string file;
17 CLI::Option *opt = app.add_option("-f,--file,file", file, "File name");
18
19 int count{0};
20 CLI::Option *copt = app.add_option("-c,--count", count, "Counter");
21
22 int v{0};
23 CLI::Option *flag = app.add_flag("--flag", v, "Some flag that can be passed multiple times");
24
25 double value{0.0}; // = 3.14;
26 app.add_option("-d,--double", value, "Some Value");
27
28 CLI11_PARSE(app, argc, argv);
29
30 std::cout << "Working on file: " << file << ", direct count: " << app.count("--file")
31 << ", opt count: " << opt->count() << '\n';
32 std::cout << "Working on count: " << count << ", direct count: " << app.count("--count")
33 << ", opt count: " << copt->count() << '\n';
34 std::cout << "Received flag: " << v << " (" << flag->count() << ") times\n";
35 std::cout << "Some value: " << value << '\n';
36
37 return 0;
38}

Callers

nothing calls this directly

Calls 3

set_version_flagMethod · 0.80
add_flagMethod · 0.80
add_optionMethod · 0.45

Tested by

no test coverage detected