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 Details

    • getUsage

      String getUsage(String name)
      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

      String getHelpSummary(String name)
      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

      String getHelpDetail(String name)
      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 InterruptedException
      Execute 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 session
      name - the name under which this command was invoked
      args - 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