commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Keyes <j...@mac.com>
Subject Re: [CLI] child Options
Date Sat, 31 May 2003 16:43:29 GMT
> Just to double check, I can then have an app whose CLI looks like:
>
> App (-commandA -cmdAOption|-cmdBOption) | (-commandB
> -cmdBOption|-cmdBOption) | -help

I assume you meant:
App (-commandA -cmdAOption|-cmdBOption) | (-commandB
  -cmdAOption|-cmdBOption) | -help

If so it would be something like (pseudo code):

   Option cmdAOption
   Option cmdBOption

   ExclusiveGroup childExcgroup
   childExcgroup.add(cmdAOption)
   childExcgroup.add(cmdBOption)

   Option commandA
   Option commandB
   Option help

   Options child = new Options();
   child.add(childExcgroup);

   commandA.setOptions(child);
   commandB.setOptions(child);

   ExclusiveGroup excGroup
   excGroup.add(commandA)
   excGroup.add(commandB)
   excGroup.add(help)

   Options options
   options.add(excGroup)

-John K

> Gary
> -----Original Message-----
> From: John Keyes [mailto:jbjk@mac.com]
> Sent: Saturday, May 31, 2003 08:41
> To: commons-dev
> Subject: [CLI] child Options
>
> The current version on the branch has support for child Options:
>    addChild(Option)
>    addChildren(Set)
>
> I think that this is too restrictive and the correct support should be:
>    addOptions(Options)
>
> This will allow the following style command line:
>
> app -option -x|-y
>
> The definition for this is:
>
>    // build child options
>    Option x = builder.withName("x").create();
>    Option y = builder.withName("y").create();
>    ExclusiveGroup axis = new ExclusiveGroup();
>    axis.add(x);
>    axis.add(y);
>    Options child = new Options();
>    child.add(axis);
>
>    // build option
>    Option option = builder.withName("option").create();
>    option.setOptions(child);
>
>    // build application options
>    Options options = new Options();
>    options.add(option);
>
> This means that if "-option" is found in the command line arguments,
> parse the remaining arguments using the Options specified for 'option'.
> In this case, the only valid remaining arguments are "-x" or "-y", but
> not both.
>
> If I don't hear any reasons why people think this approach is incorrect
> (or any other significant comments) I will proceed to implement it.
>
> -John K
> - - - - - - - - - - - - - - - - - - - - - - -
> Jakarta Commons CLI
> http://jakarta.apache.org/commons/cli
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
- - - - - - - - - - - - - - - - - - - - - - -
Jakarta Commons CLI
http://jakarta.apache.org/commons/cli


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


Mime
View raw message