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

Function main

examples/enum_ostream.cpp:32–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30}
31
32int main(int argc, char **argv) {
33 CLI::App app;
34
35 Level level{Level::Low};
36 // specify string->value mappings
37 std::map<std::string, Level> map{{"high", Level::High}, {"medium", Level::Medium}, {"low", Level::Low}};
38 // CheckedTransformer translates and checks whether the results are either in one of the strings or in one of the
39 // translations already
40 app.add_option("-l,--level", level, "Level settings")
41 ->required()
42 ->transform(CLI::CheckedTransformer(map, CLI::ignore_case));
43
44 CLI11_PARSE(app, argc, argv);
45
46 // CLI11's built in enum streaming can be used outside CLI11 like this:
47 using CLI::enums::operator<<;
48 std::cout << "Enum received: " << level << '\n';
49
50 return 0;
51}

Callers

nothing calls this directly

Calls 4

CheckedTransformerClass · 0.85
transformMethod · 0.80
requiredMethod · 0.45
add_optionMethod · 0.45

Tested by

no test coverage detected