catchorg / Clara

A simple to use, composable, command line parser for C++ 11 and beyond
Boost Software License 1.0
648 stars 67 forks source link

"enum" type values #98

Open mattgodbolt opened 5 years ago

mattgodbolt commented 5 years ago

I'd love a way to constrain a positional argument to "one of" a range of values only. For example, one of a selection of strings like "slow", "medium" or "fast" (for a --speed slow type argument). I couldn't see how to do it without just checking the string value afterwards (which is fine, but this seems like a common enough use case!)

grafikrobot commented 5 years ago

Hey neighbor.. Thanks for the idea. I implemented that in my Lyra fork: https://github.com/bfgroup/Lyra/commit/ccdf09f043bc8af09516e0fbc82be705c298a53e (examples here https://raw.githack.com/bfgroup/Lyra/develop/docs/lyra.html#_option_value_choices).