You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Eric Liu <ly...@gmail.com> on 2013/01/28 18:08:00 UTC

Commons CLI command stype

Hi,

 I know the default 'Commons CLI'  command style is like ' java -jar
***.jar [OPTIONS]'. Can anyone tell me how to make this kind of command
style using Commons CLI?

 java -jar ***.jar  [COMMAND] [OPTIONS]


Thanks,

Re: Commons CLI command stype

Posted by Eric Liu <ly...@gmail.com>.
*Thanks *Thomas

2013/1/28 Thomas Neidhart <th...@gmail.com>

> On 01/28/2013 06:08 PM, Eric Liu wrote:
> > Hi,
> >
> >  I know the default 'Commons CLI'  command style is like ' java -jar
> > ***.jar [OPTIONS]'. Can anyone tell me how to make this kind of command
> > style using Commons CLI?
> >
> >  java -jar ***.jar  [COMMAND] [OPTIONS]
>
> Well, as you already pointed out, Commons CLI currently only supports
> additional (or left-over) arguments at the end like this:
>
> java -jar ***.jar [OPTIONS] [COMMAND]
>
> But if you know for sure that the first token will be the command, you
> could strip the first argument (after making sure it is not an option),
> and only provide the remaining arguments to the parser.
>
> The help text could be manually adjusted like that:
>
>   formatter.printHelp("myapp [COMMAND]", header, options, footer, true);
>
> You could also create a feature request in JIRA if you like.
>
> Thomas
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Re: Commons CLI command stype

Posted by Thomas Neidhart <th...@gmail.com>.
On 01/28/2013 06:08 PM, Eric Liu wrote:
> Hi,
> 
>  I know the default 'Commons CLI'  command style is like ' java -jar
> ***.jar [OPTIONS]'. Can anyone tell me how to make this kind of command
> style using Commons CLI?
> 
>  java -jar ***.jar  [COMMAND] [OPTIONS]

Well, as you already pointed out, Commons CLI currently only supports
additional (or left-over) arguments at the end like this:

java -jar ***.jar [OPTIONS] [COMMAND]

But if you know for sure that the first token will be the command, you
could strip the first argument (after making sure it is not an option),
and only provide the remaining arguments to the parser.

The help text could be manually adjusted like that:

  formatter.printHelp("myapp [COMMAND]", header, options, footer, true);

You could also create a feature request in JIRA if you like.

Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org