Package io.permazen.cli.cmd
Class AbstractCommand
java.lang.Object
io.permazen.cli.cmd.AbstractCommand
- All Implemented Interfaces:
Command
- Direct Known Subclasses:
AbstractKVCommand
,AbstractRaftCommand
,CompareSchemasCommand
,InfoCommand
,JsckCommand
,LoadCommand
,RaftFallbackForceStandaloneCommand
,RaftFallbackStatusCommand
,RemoveSchemaCommand
,SaveCommand
,SetAllowNewSchemaCommand
,SetLogLevelCommand
,SetSchemaRemovalCommand
,SetSessionModeCommand
,SetValidationModeCommand
,SetVerboseCommand
,ShowSchemaCommand
Support superclass for CLI
Command
implementations.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Logger
protected final String
protected final ParamParser
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Execute this command.protected abstract Session.Action
Process command line parameters and return action.Get expanded help (typically multiple lines).abstract String
Get summarized help (typically a single line).getName()
Get the name of this command.protected Parser<?>
Convert parameter spec type name into aParser
.Get theSessionMode
(s) supported by this command.getUsage()
Get command usage string.
-
Field Details
-
log
-
name
-
paramParser
-
-
Constructor Details
-
AbstractCommand
Constructor.- Parameters:
spec
-ParamParser
spec string, possibly containing custom type names (seegetParser()
)
-
-
Method Details
-
getName
Description copied from interface:Command
Get the name of this command. -
getUsage
Get command usage string.The implementation in
AbstractCommand
delegates toParamParser.getUsage()
. -
getHelpSummary
Get summarized help (typically a single line).- Specified by:
getHelpSummary
in interfaceCommand
- Returns:
- one line command summary
-
getHelpDetail
Get expanded help (typically multiple lines).The implementation in
AbstractCommand
delegates togetHelpSummary()
.- Specified by:
getHelpDetail
in interfaceCommand
- Returns:
- detailed command description
-
getSessionModes
Get theSessionMode
(s) supported by this command.The implementation in
AbstractCommand
returns anEnumSet
containingSessionMode.CORE_API
andSessionMode.PERMAZEN
.- Specified by:
getSessionModes
in interfaceCommand
- Returns:
- set of supported
SessionMode
s
-
execute
Execute this command.The implementation in
AbstractCommand
parses the parameters, delegates togetAction()
to generate an action, and then executes the action.- Specified by:
execute
in interfaceCommand
- Parameters:
session
- CLI sessionname
- command nameparams
- command line arguments- Returns:
- command return value
- Throws:
InterruptedException
- if the current thread is interrupted
-
getAction
Process command line parameters and return action.- Parameters:
session
- CLI sessionparams
- parsed parameters indexed by name- Returns:
- action to perform for the parsed command
- Throws:
IllegalArgumentException
- if parameters are invalid
-
getParser
Convert parameter spec type name into aParser
. Used for custom type names not supported byParamParser
.The implementation in
AbstractCommand
supports allEncoding
s registered with the database, plus:objid
for an object ID of the form64e8f29755302fe1
(returnsObjId
)
- Parameters:
typeName
- parameter encoding ID or encoding ID alias- Returns:
- parser for parameters of the specified type
-