Class AbstractSimpleCommand

java.lang.Object
org.dellroad.jct.core.simple.AbstractSimpleCommand
All Implemented Interfaces:
SimpleCommand
Direct Known Subclasses:
DateCommand, EchoCommand, ExitCommand, HelpCommand, SleepCommand, SubshellCommand

public abstract class AbstractSimpleCommand extends Object implements SimpleCommand
Support superclass for SimpleCommand implementations.
  • Constructor Details

    • AbstractSimpleCommand

      protected AbstractSimpleCommand(String usage, String summary, String detail)
      Constructor.
      Parameters:
      usage - usage string, or null if command takes no arguments
      summary - help summary
      detail - help detail
      Throws:
      IllegalArgumentException - if summary or detail is null
  • Method Details

    • getUsage

      public String getUsage(String name)
      Description copied from interface: SimpleCommand
      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.

      Specified by:
      getUsage in interface SimpleCommand
      Parameters:
      name - the name under which this command is registered
      Returns:
      command usage string
    • getHelpSummary

      public String getHelpSummary(String name)
      Description copied from interface: SimpleCommand
      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.
      Specified by:
      getHelpSummary in interface SimpleCommand
      Parameters:
      name - the name under which this command is registered
      Returns:
      one line command summary
    • getHelpDetail

      public String getHelpDetail(String name)
      Description copied from interface: SimpleCommand
      Get expanded help. This is typically multiple lines of text; lines should be separated by newline characters.
      Specified by:
      getHelpDetail in interface SimpleCommand
      Parameters:
      name - the name under which this command is registered
      Returns:
      detailed command description
    • printUsage

      protected void printUsage(ConsoleSession<?,?> session, String name)