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:[email protected]] 
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: [email protected]
> For additional commands, e-mail: [email protected]
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to