commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Keyes <j...@integralsource.com>
Subject [CLI] Support for CVS style command line
Date Sun, 08 Jun 2003 20:06:31 GMT
The CVS command line is defined as follows:

   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);
Mime
View raw message