Package org.dellroad.jct.core.simple
Interface SimpleCommand
- All Known Implementing Classes:
AbstractSimpleCommand
,DateCommand
,EchoCommand
,ExitCommand
,HelpCommand
,JShellCommand
,SleepCommand
,SubshellCommand
public interface SimpleCommand
Implemented by commands that can be configured for a
SimpleExec
or SimpleShell
.-
Method Summary
Modifier and TypeMethodDescriptionint
execute
(ConsoleSession<?, ?> session, String name, List<String> args) Execute this command in the current thread and return success or failure.getHelpDetail
(String name) Get expanded help.getHelpSummary
(String name) Get summarized help.Get this command's usage string.
-
Method Details
-
getUsage
Get this command's usage string.The usage string should be a synopsis of the command's arguments. If the command takes no arguments, this can return null or empty string.
- Parameters:
name
- the name under which this command is registered- Returns:
- command usage string
-
getHelpSummary
Get summarized help. This should be a single line of text, playing a role similar to the first sentence (or sentence fragment) of a Javadoc comment.- Parameters:
name
- the name under which this command is registered- Returns:
- one line command summary
-
getHelpDetail
Get expanded help. This is typically multiple lines of text; lines should be separated by newline characters.- Parameters:
name
- the name under which this command is registered- Returns:
- detailed command description
-
execute
int execute(ConsoleSession<?, ?> session, String name, List<String> args) throws InterruptedExceptionExecute this command in the current thread and return success or failure.In the failure case, some error information should be written to standard error.
- Parameters:
session
- associated sessionname
- the name under which this command was invokedargs
- zero or more command arguments (does not include command name)- Returns:
- zero if successful, non-zero error code if an error occurred
- Throws:
InterruptedException
- if execution is interrupted
-