commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Johann Petrak (JIRA)" <>
Subject [jira] [Commented] (CLI-257) Allow partial parsing
Date Thu, 22 Jun 2017 14:13:00 GMT


Johann Petrak commented on CLI-257:

Sorry Benedikt Ritter, I somehow missed this reply. 
Maybe I should point out what the intended use of ignoring unrecognised options is: I have
a situation where the same options list is passed on to several "option consumers" (separate
modules), each knows which options it needs or optionally supports, but knows nothing about
the options for other modules. This means that each module only is interested in their own
options and each module parses the "command line"  with their own options definitions, expecting
anything that does not match that definition to simply get ignored. Therefore there is no
need to retrieve the unknown arguments, because those will be known arguments of another module.
It is not straightforward to add something to just retrieve unknown arguments since the definition
tells us a lot about *how* to retrieve them and by definition we do not have it. 

My patch above does have one other problem though: if ignore unknown options is enabled, then
any value after an unknown option is interpreted as a positional argument. Positional arguments
do not make a lot of sense if there are several consumers, but it would probably still be
better to handle this slightly differently: instead, ignore all non-option tokens until a
known option is encountered again, if at all. In the worst case this will also ignore any
actual positional arguments if the last option is an unknown option, but again, positional
arguments do not really make sense in this scenario.

If you think this would be a useful addition I will provide a modified patch.

> Allow partial parsing
> ---------------------
>                 Key: CLI-257
>                 URL:
>             Project: Commons CLI
>          Issue Type: Improvement
>    Affects Versions: 1.3.1
>         Environment: any
>            Reporter: guai
>         Attachments: commons-cli.diff
> commons cli can only throw exception or start skipping once it hit unknown parameter.
> I need a way to tell it to start skip unknown arguments and save them somewhere for later
handling, but do handle known arguments to the end

This message was sent by Atlassian JIRA

View raw message