-
I have an option that allows zero or more arguments: std::vector<std::string> optStr;
app.add_option("-o,--option", optStr, "option help string")->expected(0,1); and a flag: bool myFlag {false};
app.add_flag("-f,--flag", myFlag, "flag help string"); and I'd like to be allowed to call it like this: app -of but apparently, CLI11 places Calling |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
How is anybody supposed to know, whether "f" should be treated as an argument or as a flag if that was allowed? |
Beta Was this translation helpful? Give feedback.
-
Looking at this a little closer, there is probably an inconsistency here in the way multiple single arguments are treated with a single -. However, there is a modifier So the documentation states that a non flag option must come last in the chain, however, this case is a bit of a gray area and an argument could be made that if combined with I don't think there is any way to make this work currently. |
Beta Was this translation helpful? Give feedback.
Looking at this a little closer, there is probably an inconsistency here in the way multiple single arguments are treated with a single -.
As you have it
-of
has to treat it as-o=f
if it didn't it would open up all sorts of issues.However, there is a modifier
validate_optional_arguments()
to the option which would allow a validation step to discriminate optional arguments from others. Which looking at the code is not consistently applied in the case of chaining single character options.So the documentation states that a non flag option must come last in the chain, however, this case is a bit of a gray area and an argument could be made that if combined with
validate_optional_arguments()
…