Class SimpleCommandSupport

java.lang.Object
org.dellroad.jct.core.simple.SimpleCommandSupport
Direct Known Subclasses:
SimpleExec, SimpleShell

public class SimpleCommandSupport extends Object
Support superclass for console components that utilize SimpleCommands.
  • Field Details

  • Constructor Details

    • SimpleCommandSupport

      public SimpleCommandSupport()
  • Method Details

    • getCommandLineParser

      public CommandLineParser getCommandLineParser()
      Get the configured command line parser.
      Returns:
      command line parser, never null
    • setCommandLineParser

      public void setCommandLineParser(CommandLineParser commandLineParser)
      Configure how command lines are parsed into separate arguments.

      By default, a SimpleCommandLineParser is used.

      Parameters:
      commandLineParser - command line parser
      Throws:
      IllegalArgumentException - if commandLineParser is null
    • getCommandBundles

      public List<CommandBundle> getCommandBundles()
      Get the list of command bundles.
      Returns:
      command bundles, never null
    • buildCommandMap

      public SortedMap<String,SimpleCommand> buildCommandMap()
      Build a combined command map, where command names in earlier bundles hide later ones.
      Returns:
      map from command name to command
    • findCommand

      public SimpleCommandSupport.FoundCommand findCommand(PrintStream errout, ExecRequest request)
      Find the command in the bundle corresponding to the given request.

      If an error occurs, an error message is printed to errout and null is returned.

      Parameters:
      errout - error output
      request - exec request
      Returns:
      successful parse and lookup, otherwise null
      Throws:
      IllegalArgumentException - if either parameter is null
    • findCommand

      public SimpleCommandSupport.FoundCommand findCommand(PrintStream errout, String commandString)
      Find the command in the bundle corresponding to the given command string, which will be parsed.

      If an error occurs, an error message is printed to errout and null is returned.

      Parameters:
      errout - error output
      commandString - command string
      Returns:
      successful parse and lookup, otherwise null
      Throws:
      IllegalArgumentException - if either parameter is null
    • findCommand

      public SimpleCommandSupport.FoundCommand findCommand(PrintStream errout, List<String> commandList)
      Find the command in the bundle corresponding to the given command list.

      If an error occurs, an error message is printed to errout and null is returned.

      Parameters:
      errout - error output
      commandList - command list
      Returns:
      successful parse and lookup, otherwise null
      Throws:
      IllegalArgumentException - if either parameter is null