You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I have defined a few options but NOT "-x" and then I call the program with "-x" then no error is given and my if() is never reached where I'm testing for mycli11.empty() with each defined option!
Request:
It would be good to have a count of given valid options/flags and a count of invalid options/flags after parsing.
By default, extra options are not allowed. You have to set app.allow_extras(). Then, if you do, it collects and returns all the left over arguments (options or otherwise) that show up on the command line. Those are in remaining. If it's not working, can you post a minimal (not) working example (MWE)?
Since you mentioned the try-catch block, maybe you are forgetting to return app.exit(e)? Without enabling extras, the default behavior is to throw a parse exception.
Activity
phlptp commentedon May 24, 2020
What operation are you using to check? I am not sure there is an empty() function on a CLI11::App? or are you doing it on each option separately?
count()will return if it is processedcount_all()will return the number or processed arguments.if allow_extras() is set to true then the processing won't error when an unrecognized argument is passed. but it will be available in
remaining()patlecat commentedon May 24, 2020
Sure there is:
auto list = m_conf.add_flag("--list", "List all available xx with complete options");And then ...
But like I said, the lib shows weird behaviour since code after the parsing in the try-catch block no code below is executed anymore.
patlecat commentedon May 24, 2020
remaining()doesn't seem to do what you said, I couldn't use it this way to get all unrecognised paramters, would be nice though, exactly what I need!From the code: "This returns the missing options from the current subcommand"
henryiii commentedon May 25, 2020
By default, extra options are not allowed. You have to set
app.allow_extras(). Then, if you do, it collects and returns all the left over arguments (options or otherwise) that show up on the command line. Those are in remaining. If it's not working, can you post a minimal (not) working example (MWE)?Since you mentioned the try-catch block, maybe you are forgetting to
return app.exit(e)? Without enabling extras, the default behavior is to throw a parse exception.patlecat commentedon May 25, 2020
I'm doing the app.exit and it doesn't seem to work. If I can find some time I'll do a simple example, but I can't promise.
Update CLI11 to v1.9.1
Update CLI11 to v1.9.1