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:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
- - - - - - - - - - - - - - - - - - - - - - - Jakarta Commons CLI http://jakarta.apache.org/commons/cli
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
