commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henrique Seganfredo <henrique.seganfr...@bcb.gov.br>
Subject RES: [cli] Example using of option with two mandatory arguments
Date Fri, 25 Feb 2011 23:17:21 GMT
Hello Emmanuel,

I´ve been trying to to this:

Option db1topkds = OptionBuilder
		.hasArgs(5)
		.create("db1topkds");

When I execute the app without any option, help is displayed like this:

MyApp v.1.0 (c) 2011
usage: MyApp
	-db1topkds <arg>

Why is not showing something like 

usage: MyApp
	-db1topkds <arg1> <arg2> <arg3> <arg4> <arg5> 

??

Any idea? Isn´t this the expected behavior? I am confused, does Commons-CLI supports or not
multiple arguments for an option?

Regards,



-----Mensagem original-----
De: Emmanuel Bourg [mailto:ebourg@apache.org] 
Enviada em: quarta-feira, 23 de fevereiro de 2011 16:47
Para: Commons Users List
Assunto: Re: [cli] Example using of option with two mandatory arguments

Hi Henrique,

With CLI 1.x you would do it like this :

   Options options = new Options();
   options.addOption(OptionBuilder.hasArgs(2).create("myoption"));

   CommandLine cmd = new DefaultParser().parse(options, new String[] { 
"-myoption", "argument1" });

If an argument is missing a MissingArgumentException is thrown.

Emmanuel Bourg



Le 23/02/2011 19:46, Henrique Seganfredo a écrit :
> Hello,
>
> Could please someone post an example of Commons CLI to have na option with two mandatory
arguments?
>
> Example:
>
> ./myprog -myoption<argument1>  <argument2>
>
> Many thanks,
>
> Henrique Seganfredo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>



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


Mime
View raw message