Commit 3da480792b18f0debd181270372cb2d560494a52
1 parent
00e0506f
Adding enum example
Showing
2 changed files
with
24 additions
and
0 deletions
examples/CMakeLists.txt
examples/enum.cpp
0 → 100644
| 1 | +#include <CLI/CLI.hpp> | |
| 2 | + | |
| 3 | +enum Level : std::int32_t { | |
| 4 | + High, | |
| 5 | + Medium, | |
| 6 | + Low | |
| 7 | +}; | |
| 8 | + | |
| 9 | +int main(int argc, char** argv) { | |
| 10 | + CLI::App app; | |
| 11 | + | |
| 12 | + Level level; | |
| 13 | + app.add_set("-l,--level", level, {High, Medium, Low}, "Level settings") | |
| 14 | + ->set_type_name("enum/Level in {High=0, Medium=1, Low=2}"); | |
| 15 | + | |
| 16 | + try { | |
| 17 | + app.parse(argc, argv); | |
| 18 | + } catch (CLI::Error const& e) { | |
| 19 | + app.exit(e); | |
| 20 | + } | |
| 21 | + return 0; | |
| 22 | +} | |
| 23 | + | ... | ... |