Class Option
java.lang.Object
com.appiancorp.suiteapi.common.cli.Option
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Arguments may or may not have parameters.static class
Any extender of Execute MUST implement one of these methods.static class
-
Constructor Summary
ConstructorDescriptionOption
(char shortOption, String longOption, boolean required, String description, Option.Arguments arguments, String argumentName, Option.Execute execute) Construct an Option, to be returned by a Driver. -
Method Summary
Modifier and TypeMethodDescriptionConstruct a list of Options, then invoke Option.execute("myprogram",args,options).getStandardOptions
(String program, PrintStream out) Return the standard options such as 'options' and 'help'.
-
Constructor Details
-
Option
public Option(char shortOption, String longOption, boolean required, String description, Option.Arguments arguments, String argumentName, Option.Execute execute) Construct an Option, to be returned by a Driver.- Parameters:
shortOption
- The single character Option.longOption
- The long name Option.required
- If the option MUST be passed.description
- Description of the Option for help.arguments
- Set to one of the Arguments enumeration to determine if this Option has a parameter.argumentName
- The name of the argument to the Option if it has one, otherwise must be null.execute
- This callback will be executed when the option is passed. Typically this will be used to set a field in the Driver, possibly with validation.
-
-
Method Details
-
getStandardOptions
Return the standard options such as 'options' and 'help'.- Parameters:
program
-out
-- Returns:
-
execute
public static List<String> execute(String program, String[] args, List<Option> options, PrintStream out) throws IllegalArgumentException Construct a list of Options, then invoke Option.execute("myprogram",args,options). It will return all unparsed options. (If you don't want any, just error on their existance.) The help option should be new Option.Help() for its execute to get automatic help.- Parameters:
program
- The program name, used in help.args
- Program arguments, typically from main(String args[])options
- List of options to executeout
- Typically System.out, but if null will prevent prompting for required parameters, instead throwing an exception.- Returns:
- Throws:
IllegalArgumentException
-