Class AbstractCommand

java.lang.Object
org.jline.shell.impl.AbstractCommand
All Implemented Interfaces:
Command

public abstract class AbstractCommand extends Object implements Command
Base implementation of Command that stores name and aliases.

Example:

 Command echo = new AbstractCommand("echo", "e") {
     @Override
     public Object execute(CommandSession session, String[] args) {
         session.out().println(String.join(" ", args));
         return null;
     }
 };
 
Since:
4.0
See Also:
  • Constructor Details

    • AbstractCommand

      protected AbstractCommand(String name, String... aliases)
      Creates a new command with the given name and optional aliases.
      Parameters:
      name - the primary command name
      aliases - optional alias names
  • Method Details

    • name

      public String name()
      Description copied from interface: Command
      Returns the primary name of this command.
      Specified by:
      name in interface Command
      Returns:
      the command name, never null
    • aliases

      public List<String> aliases()
      Description copied from interface: Command
      Returns alternative names for this command.

      The default implementation returns an empty list.

      Specified by:
      aliases in interface Command
      Returns:
      the list of aliases, never null