Skip to content

Commit

Permalink
add choices
Browse files Browse the repository at this point in the history
  • Loading branch information
sisakat committed May 8, 2022
1 parent 2df332c commit e497901
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ int main(int argc, char* argv[])
.flag()
.description("Flag for something.");

std::string loglevel;
parser.option<std::string>("--loglevel")
.choices({"trace", "debug", "info"})
.description("Set the log level")
.store(loglevel);

if (parser.parse())
{
std::cout << "Config file: " << config << std::endl;
Expand All @@ -52,8 +58,8 @@ int main(int argc, char* argv[])
Sample Application 1.0.0
Some really useful cli program.

./basic [-h] [-v] -c <json config file> [-s]
[-f]
./a.out [-h] [-v] -c <json config file> [-s]
[-f] [--loglevel debug|info|trace]
-h --help
Print this help message.
-v --version
Expand All @@ -63,6 +69,8 @@ Some really useful cli program.
Silent mode
-f
Flag for something.
--loglevel debug|info|trace
Set the log level
```
```
Expand Down
6 changes: 6 additions & 0 deletions examples/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ int main(int argc, char* argv[])
.flag()
.description("Flag for something.");

std::string loglevel;
parser.option<std::string>("--loglevel")
.choices({"trace", "debug", "info"})
.description("Set the log level")
.store(loglevel);

if (parser.parse())
{
std::cout << "Config file: " << config << std::endl;
Expand Down

0 comments on commit e497901

Please sign in to comment.