public abstract class AbstractCommand extends Object implements Command
Command implementations.Command| Modifier and Type | Field and Description |
|---|---|
protected Logger |
log |
protected String |
name |
protected ParamParser |
paramParser |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractCommand(String spec)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract CliSession.Action |
getAction(CliSession session,
ParseContext ctx,
boolean complete,
Map<String,Object> params)
Process command line parameters and return action.
|
String |
getHelpDetail()
Get expanded help (typically multiple lines).
|
abstract String |
getHelpSummary()
Get summarized help (typically a single line).
|
String |
getName()
Get the name of this command.
|
protected Parser<?> |
getParser(String typeName)
Convert parameter spec type name into a
Parser. |
EnumSet<SessionMode> |
getSessionModes()
Get the
SessionMode(s) supported by this command. |
String |
getUsage()
Get command usage string.
|
CliSession.Action |
parse(ParseSession session,
ParseContext ctx,
boolean complete) |
protected final Logger log
protected final String name
protected final ParamParser paramParser
protected AbstractCommand(String spec)
spec - ParamParser spec string, possibly containing custom type names (see getParser())public String getName()
Commandpublic String getUsage()
The implementation in AbstractCommand delegates to ParamParser.getUsage().
public abstract String getHelpSummary()
getHelpSummary in interface Commandpublic String getHelpDetail()
The implementation in AbstractCommand delegates to getHelpSummary().
getHelpDetail in interface Commandpublic EnumSet<SessionMode> getSessionModes()
SessionMode(s) supported by this command.
The implementation in AbstractCommand returns an EnumSet containing
SessionMode.CORE_API and SessionMode.JSIMPLEDB.
getSessionModes in interface CommandSessionModespublic CliSession.Action parse(ParseSession session, ParseContext ctx, boolean complete)
The implementation in AbstractCommand parses the parameters and delegates to getAction()
with the result.
parse in interface Parser<CliSession.Action>session - CLI sessionctx - input to parsecomplete - false if parse is "for real", true if only for tab completion calculationParseException - if parse fails, or if complete is true and there are valid completionsParseException - if parameters are invalidIllegalArgumentException - if session is not a CliSessionprotected abstract CliSession.Action getAction(CliSession session, ParseContext ctx, boolean complete, Map<String,Object> params)
session - CLI sessionctx - input to parsecomplete - false if parse is "for real", true if only for tab completion calculationparams - parsed parameters indexed by nameParseException - if parse fails, or if complete is true and there are valid completionsParseException - if parameters are invalidprotected Parser<?> getParser(String typeName)
Parser. Used for custom type names not supported by ParamParser.
The implementation in AbstractCommand supports all FieldTypes registered with the
database, type for an object type name (returns Integer), and objid for an object ID
(returns ObjId).
typeName - parameter type nameCopyright © 2016. All rights reserved.