cvs [options] command [command-options]
Ideally I would like to have CLI support this implicity, i.e. validate the 'command' value (this was a feature already recommended by Mike McLean and modified by Max Rydahl Andersen) and based on this value parse the remaining Options.
There are two steps in this: . value validation . mapping value to Options
So here's an example:
ValueValidator commandValidator = new StringValidator() { public boolean validate(String value) { ... } }
OptionsMap optionsMap = new OptionsMap(); optionsMap.add("checkout", checkoutOptions); optionsMap.add("co", checkoutOptions);
// this means that there is an Anonymous Argument which will // have one value and the HelpFormatter will spit 'command' // out in the help text, the value found in the args will // be validated by the specified validator Argument command = abuilder.withOptionMap(optionsMap) .withValidator(commandValidator) .createAnonymous("command",1); // args - "cvs co file.txt" CommandLine line = parser.parse(opts, args);
The parse would find 'co' as the Anonymous Argument, and then validate that the value is allowable, when it confirms that it is valuable then query the OptionsMap to see if there are any Options specified for that value. If there are Options, then parse the remaining args (file.txt) using them. If there are no Options, then throw an exception as there is only one value allowed for the anonymous argument.
What do people think of this? Does it sound good? Are there any better ideas?
Cheers, -John K - - - - - - - - - - - - - - - - - - - - - - - Jakarta Commons CLI http://jakarta.apache.org/commons/cli
- - - - - - - - - - - - - - - - - - - - - - - Jakarta Commons CLI http://jakarta.apache.org/commons/cli
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]