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 Wed, 23 Feb 2011 22:07:36 GMT
Using OptionBuilder how should be done? 

I really would like to give a specific name to my arguments. I tried the code below, but it
does not work, discarding the first argument...

Option db1topkds = OptionBuilder
		.hasArgs(2)
		.withArgName("myarg1")
		.withArgName("myarg2")
		.withDescription("myoption that performs something asking for arg1 and arg2")
		.create("myoption");

Best Regards,

Henrique Seganfredo

-----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