Class CommandLine
- java.lang.Object
-
- net.adoptopenjdk.icedteaweb.client.commandline.CommandLine
-
public class CommandLine extends java.lang.ObjectEncapsulates a command line interface to the deployment configuration.The central method is
Sample usage:handle(), which calls one of the various 'handle' methods. The commands listed in CommandLineOptions.getItwsettingsCommands are supported. For each supported command, a method handleCOMMANDCommand exists. This method actually takes action based on the command. Generally, a printCOMMANDHelp method also exists, and prints out the help message for that specific command. For example, seehandleListCommand()andprintListHelp().CommandLine cli = new CommandLine(); // the string array represents input using the command line int retVal = cli.handle(new String[] { "help" }); if (retVal == CommandLine.SUCCESS) { // good! } else { // bad! }
-
-
Field Summary
Fields Modifier and Type Field Description private DeploymentConfigurationconfigstatic intERRORprivate static LoggerLOGprivate CommandLineOptionsParseroptionParserprivate java.lang.StringprogramNamestatic intSUCCESS
-
Constructor Summary
Constructors Constructor Description CommandLine(CommandLineOptionsParser optionParser)Creates a new instance
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanconfigContains(java.lang.String arg)private intgetNumberOfOptions()inthandle()Handles overall command line arguments.private inthandleCheckCommand()Handles the 'check' commandprivate inthandleGetCommand()Handles the 'get' command.private inthandleHelpCommand()Handle the 'help' commandprivate inthandleInfoCommand()Handles the 'info' commandprivate inthandleListCommand()Handles the 'list' commandprivate inthandleResetCommand()Handles the 'reset' commandinthandleSetCommand()Handles the 'set' commandprivate booleanhasUnrecognizedCommands()private booleanisDetailsValid()static voidmain(java.lang.String[] args)The starting point of the programprivate voidprintCheckHelp()Prints a help message for the 'check' commandprivate voidprintGetHelp()Prints help message for the get commandprivate voidprintInfoHelp()Print a help message for the 'info' commandprivate voidprintListHelp()Prints help message for the list commandprivate voidprintResetHelp()Prints a help message for the reset commandprivate voidprintSetHelp()Prints the help message for the 'set' commandprivate intvalidateValue(java.lang.String key, java.lang.String value)
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
ERROR
public static final int ERROR
- See Also:
- Constant Field Values
-
SUCCESS
public static final int SUCCESS
- See Also:
- Constant Field Values
-
programName
private final java.lang.String programName
-
optionParser
private final CommandLineOptionsParser optionParser
-
config
private DeploymentConfiguration config
-
-
Constructor Detail
-
CommandLine
public CommandLine(CommandLineOptionsParser optionParser)
Creates a new instance- Parameters:
optionParser- used to parse applications arguments
-
-
Method Detail
-
handleHelpCommand
private int handleHelpCommand()
Handle the 'help' command- Returns:
- the result of handling the help command. SUCCESS if no errors occurred.
-
printListHelp
private void printListHelp()
Prints help message for the list command
-
handleListCommand
private int handleListCommand()
Handles the 'list' command- Returns:
- result of handling the command. SUCCESS if no errors occurred.
-
printGetHelp
private void printGetHelp()
Prints help message for the get command
-
handleGetCommand
private int handleGetCommand()
Handles the 'get' command.- Returns:
- an integer representing success (SUCCESS) or error handling the get command.
-
printSetHelp
private void printSetHelp()
Prints the help message for the 'set' command
-
handleSetCommand
public int handleSetCommand()
Handles the 'set' command- Returns:
- an integer indicating success (SUCCESS) or error in handling the command
-
configContains
private boolean configContains(java.lang.String arg)
-
validateValue
private int validateValue(java.lang.String key, java.lang.String value)
-
printResetHelp
private void printResetHelp()
Prints a help message for the reset command
-
handleResetCommand
private int handleResetCommand()
Handles the 'reset' command- Returns:
- an integer indicating success (SUCCESS) or error in handling the command
-
printInfoHelp
private void printInfoHelp()
Print a help message for the 'info' command
-
handleInfoCommand
private int handleInfoCommand()
Handles the 'info' command- Returns:
- an integer indicating success (SUCCESS) or error in handling the command
-
printCheckHelp
private void printCheckHelp()
Prints a help message for the 'check' command
-
handleCheckCommand
private int handleCheckCommand()
Handles the 'check' command- Returns:
- an integer indicating success (SUCCESS) or error in handling the command
-
handle
public int handle()
Handles overall command line arguments. The argument array is split into two pieces: the first element is assumed to be the command, and everything after is taken to be the argument to the command.- Returns:
- an integer representing an error code or SUCCESS if no problems occurred.
-
hasUnrecognizedCommands
private boolean hasUnrecognizedCommands()
-
isDetailsValid
private boolean isDetailsValid()
-
getNumberOfOptions
private int getNumberOfOptions()
-
main
public static void main(java.lang.String[] args)
The starting point of the program- Parameters:
args- the command line arguments to this program
-
-