Hi Parag,

I have checked the fix for this in.  The test is in BugsTest as 
test12210().

Enjoy,
-John K

On Wednesday, Aug 28, 2002, at 22:24 Etc/GMT, Parag Thakur wrote:

> thanks for the response, John!
>
> Here are the arguments i expect:
>
> cmd -exec -exec_opt1 -exec_opt2
> cmd -rep -rep_opt1 -rep_opt2
>
> Thus, depending on the first argument (-exec or -rep), i would like to 
> parse
> the remaining arguments. So, here is the code snippet that i have:
>
>     // create the main options object which will handle the first 
> parameter
>     Options mainOptions = new Options();
>     // There can be 2 main exclusive options:  -exec|-rep
>
>     // Therefore, place them in an option group
>
>     OptionGroup grp = new OptionGroup();
>
>     grp.addOption(new Option("exec",false,"description for this 
> option"));
>
>     grp.addOption(new Option("rep",false,"description for this 
> option"));
>
>     mainOptions.addOptionGroup(grp);
>
>     // for the exec option, there are 2 options...
>     execOptions = new Options();
>     execOptions.addOption("exec_opt1",false," desc");
>     execOptions.addOption("exec_opt2",false," desc");
>
>     // similarly, for rep there are 2 options...
>     repOptions = new Options();
>     repOptions.addOption("rep_opt1","false","desc");
>     repOptions.addOption("rep_opt2","false","desc");
>
>     // create the parser
>     CommandLineParser parser =
> CommandLineParserFactory.newParser("org.apache.commons.cli.GnuParser");
>
>     // finally, parse the arguments:
>
>     // first parse the main options to see what the user has specified
>     // We set stopAtNonOption to true so it does not touch the 
> remaining
>     // options
>     CommandLine cmd = parser.parse(mainOptions,argv,true);
>     // get the remaining options...
>     argv = cmd.getArgs();
>
>     if(cmd.hasOption("exec")){
>         cmd = parser.parse(execOptions,argv,false);
>         // process the exec_op1 and exec_opt2...
>     }
>     else if(cmd.hasOption("rep")){
>         cmd = parser.parse(repOptions,argv,false);
>         // process the rep_op1 and rep_opt2...
>     }
>     else {
>         printUsage();
>     }
>
>
> thanks again for your help!
> regards,
> parag.
>
> ----- Original Message -----
> From: "John Keyes" <[EMAIL PROTECTED]>
> To: "Jakarta Commons Users List" <[EMAIL PROTECTED]>
> Sent: Wednesday, August 28, 2002 3:54 PM
> Subject: Re: CLI library question
>
>
>> Hi Parag,
>>
>> Do you have some sample code for this.  I will give it a wizz in a mo
>> and see
>> what happens.
>>
>> I had identified this as a possible problem area but I haven't had a
>> chance to
>> address it yet.
>>
>> Cheers,
>> -John K
>>
>> On Wednesday, August 28, 2002, at 05:59 , Parag Thakur wrote:
>>
>>> hi!
>>>
>>> I have a CLI library question...
>>>
>>> In the GnuParser, is there a reason why the flatten() method does not
>>> pay
>>> attention to the "stopAtNoAction" parameter? In my parse method, I am
>>> using
>>> the Gnu Parser with the stopAtNoAction set to true. But it's 
>>> throwing an
>>> exception when it encounters an option it does not recognize 
>>> instread of
>>> stopping the parsing...
>>>
>>> thanks in advance!
>>> regards,
>>> parag.
>>>
>>>
>>> --
>>> To unsubscribe, e-mail:   <mailto:commons-user-
>>> [EMAIL PROTECTED]>
>>> For additional commands, e-mail: <mailto:commons-user-
>>> [EMAIL PROTECTED]>
>>>
>>
>>
>> --
>> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
>> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
>>
>
>
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to