diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1b6f2abc..68124dbc 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -19,3 +19,4 @@ add_cli_exe(subcommands subcommands.cpp) add_cli_exe(groups groups.cpp) add_cli_exe(inter_argument_order inter_argument_order.cpp) add_cli_exe(prefix_command prefix_command.cpp) +add_cli_exe(enum enum.cpp) diff --git a/examples/enum.cpp b/examples/enum.cpp new file mode 100644 index 00000000..ce97db39 --- /dev/null +++ b/examples/enum.cpp @@ -0,0 +1,23 @@ +#include + +enum Level : std::int32_t { + High, + Medium, + Low +}; + +int main(int argc, char** argv) { + CLI::App app; + + Level level; + app.add_set("-l,--level", level, {High, Medium, Low}, "Level settings") + ->set_type_name("enum/Level in {High=0, Medium=1, Low=2}"); + + try { + app.parse(argc, argv); + } catch (CLI::Error const& e) { + app.exit(e); + } + return 0; +} +