1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 12:13:52 +00:00
CLI11/examples/enum.cpp
Henry Fredrick Schreiner 5d9a5636bc Removing enum conversion
2018-04-07 06:58:21 +02:00

26 lines
619 B
C++

#include <sstream>
#include <CLI/CLI.hpp>
enum class Level : int { High, Medium, Low };
std::istream &operator>>(std::istream &in, Level &level) {
int i;
in >> i;
level = static_cast<Level>(i);
return in;
}
std::ostream &operator<<(std::ostream &in, const Level &level) { return in << static_cast<int>(level); }
int main(int argc, char **argv) {
CLI::App app;
Level level;
app.add_set("-l,--level", level, {Level::High, Level::Medium, Level::Low}, "Level settings")
->set_type_name("enum/Level in {High=0, Medium=1, Low=2}");
CLI11_PARSE(app, argc, argv);
return 0;
}