commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <>
Subject [jira] [Commented] (CLI-219) Allow to specify options with a single argument that will be split into multiple arguments
Date Fri, 03 Jun 2011 22:11:47 GMT


Gilles commented on CLI-219:

people will most likely forget to put the quotes
But this is a common usage for anyone used to command lines...
I think that the behaviour which I'm proposing is quite well defined, once it is assumed that
a single argument is passed (i.e. it is obvious that forgetting the quotes will pass _several_

what if the file names also contain a space?

Well, it's up to the application programmer to choose a regexp that's best suited to the case
at hand.

Splitting the argument manually is possible, but it lowers the usefulness of CLI. Auto-splitting
could be an often used feature, that would be tedious repeat in the application if it can
be provided with the additional clause ("splitWith") which I'm proposing.

As I explained on the ML, the syntax you recommend makes it much more tedious to type a command-line.

[...] using a regexp instead of a simple char for splitting the values that seems a bit overkill

It's just another possibility offered to the user (of the application). For example, the application
programmer could use {code}\\s+{code} as a separator regexp in order to be forgiving if the
user's command-line is something like
 $ java MyApp --foo "a  b  c"

It's not much of additional code and seems not to be incompatible with the current behaviour.

> Allow to specify options with a single argument that will be split into multiple arguments
> ------------------------------------------------------------------------------------------
>                 Key: CLI-219
>                 URL:
>             Project: Commons CLI
>          Issue Type: New Feature
>          Components: CLI-1.x
>    Affects Versions: 1.2
>            Reporter: Gilles
>              Labels: features
>             Fix For: 1.3
>         Attachments: svn_diff.txt
> I've explained the issue in that thread:
> As hinted there, a solution might be to allow that the (single) argument of an "Option"
(cf. "hasArg()") be split according to a user-defined regexp pattern. If given a split pattern,
the code would convert a single-arg "Option" into a multiple-args one (where the arguments
are the result of splitting the single-arg string with the pattern).

This message is automatically generated by JIRA.
For more information on JIRA, see:

View raw message