mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 20:23:55 +00:00
Adding enum example
This commit is contained in:
parent
00e0506f53
commit
3da480792b
@ -19,3 +19,4 @@ add_cli_exe(subcommands subcommands.cpp)
|
|||||||
add_cli_exe(groups groups.cpp)
|
add_cli_exe(groups groups.cpp)
|
||||||
add_cli_exe(inter_argument_order inter_argument_order.cpp)
|
add_cli_exe(inter_argument_order inter_argument_order.cpp)
|
||||||
add_cli_exe(prefix_command prefix_command.cpp)
|
add_cli_exe(prefix_command prefix_command.cpp)
|
||||||
|
add_cli_exe(enum enum.cpp)
|
||||||
|
23
examples/enum.cpp
Normal file
23
examples/enum.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include <CLI/CLI.hpp>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user