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

Function main

examples/modhelp.cpp:11–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <string>
10
11int main(int argc, char **argv) {
12 CLI::App test{R"raw(Modify the help print so that argument values are accessible.
13Note that this will not shortcut `->required` and other similar options.)raw"};
14
15 // Remove help flag because it shortcuts all processing
16 test.set_help_flag();
17
18 // Add custom flag that activates help
19 auto *help = test.add_flag("-h,--help", "Request help");
20
21 std::string some_option;
22 test.add_option("-a", some_option, "Some description");
23
24 try {
25 test.parse(argc, argv);
26 if(*help)
27 throw CLI::CallForHelp();
28 } catch(const CLI::Error &e) {
29 std::cout << "Option -a string in help: " << some_option << '\n';
30 return test.exit(e);
31 }
32
33 std::cout << "Option -a string: " << some_option << '\n';
34 return 0;
35}

Callers

nothing calls this directly

Calls 6

CallForHelpClass · 0.85
set_help_flagMethod · 0.80
add_flagMethod · 0.80
parseMethod · 0.80
exitMethod · 0.80
add_optionMethod · 0.45

Tested by

no test coverage detected