Class CLIProcessor
java.lang.Object
gov.nist.secauto.metaschema.cli.processor.CLIProcessor
Processes command line arguments and dispatches called commands.
This implementation make significant use of the command pattern to support a
delegation chain of commands based on implementations of ICommand
.
-
Nested Class Summary
Modifier and TypeClassDescriptionfinal class
Records information about the command line options and called command hierarchy. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Used to identify the version info for the command.static final org.apache.commons.cli.Option
This option indicates if the help should be shown.static final org.apache.commons.cli.Option
This option indicates if colorized output should be disabled.static final org.apache.commons.cli.Option
This option indicates if non-errors should be suppressed.static final org.apache.commons.cli.Option
This option indicates if a strack trace should be shown for an errorExitStatus
.static final org.apache.commons.cli.Option
This option indicates if the version information should be shown. -
Constructor Summary
ConstructorDescriptionCLIProcessor
(String args) The main entry point for CLI processing.CLIProcessor
(String exec, Map<String, IVersionInfo> versionInfos) The main entry point for CLI processing. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCommandHandler
(ICommand handler) Register a new command handler.getExec()
Gets the command used to execute for use in help text.Get the root-level commands.Get the root-level commands, mapped from name to command.Retrieve the version information for this application.static void
Configure the logger to only report errors.static void
The main entry point for command execution.Process a set of CLIProcessor arguments.protected void
Output version information.
-
Field Details
-
HELP_OPTION
This option indicates if the help should be shown. -
NO_COLOR_OPTION
This option indicates if colorized output should be disabled. -
QUIET_OPTION
This option indicates if non-errors should be suppressed. -
SHOW_STACK_TRACE_OPTION
This option indicates if a strack trace should be shown for an errorExitStatus
. -
VERSION_OPTION
This option indicates if the version information should be shown. -
COMMAND_VERSION
Used to identify the version info for the command.- See Also:
-
-
Constructor Details
-
CLIProcessor
The main entry point for CLI processing.This uses the build-in version information.
- Parameters:
args
- the command line arguments
-
CLIProcessor
The main entry point for CLI processing.This uses the provided version information.
- Parameters:
exec
- the command nameversionInfos
- the version info to display when the version option is provided
-
-
Method Details
-
main
The main entry point for command execution.- Parameters:
args
- the command line arguments to process
-
getExec
Gets the command used to execute for use in help text.- Returns:
- the command name
-
getVersionInfos
Retrieve the version information for this application.- Returns:
- the versionInfo
-
addCommandHandler
Register a new command handler.- Parameters:
handler
- the command handler to register
-
process
Process a set of CLIProcessor arguments.process().getExitCode().getStatusCode()
- Parameters:
args
- the arguments to process- Returns:
- the exit status
-
getTopLevelCommands
Get the root-level commands.- Returns:
- the list of commands
-
getTopLevelCommandsByName
Get the root-level commands, mapped from name to command.- Returns:
- the map of command names to command
-
handleQuiet
Configure the logger to only report errors. -
showVersion
Output version information.
-