| 14 | enum class Level : int { High, Medium, Low }; |
| 15 | |
| 16 | int main(int argc, char **argv) { |
| 17 | CLI::App app; |
| 18 | |
| 19 | Level level{Level::Low}; |
| 20 | // specify string->value mappings |
| 21 | std::map<std::string, Level> map{{"high", Level::High}, {"medium", Level::Medium}, {"low", Level::Low}}; |
| 22 | // CheckedTransformer translates and checks whether the results are either in one of the strings or in one of the |
| 23 | // translations already |
| 24 | app.add_option("-l,--level", level, "Level settings") |
| 25 | ->required() |
| 26 | ->transform(CLI::CheckedTransformer(map, CLI::ignore_case)); |
| 27 | |
| 28 | CLI11_PARSE(app, argc, argv); |
| 29 | |
| 30 | // CLI11's built in enum streaming can be used outside CLI11 like this: |
| 31 | using CLI::enums::operator<<; |
| 32 | std::cout << "Enum received: " << level << '\n'; |
| 33 | |
| 34 | return 0; |
| 35 | } |
nothing calls this directly
no test coverage detected