Class Command

java.lang.Object
pro.gravit.utils.command.Command
Direct Known Subclasses:
ClearCommand, DebugCommand, GCCommand, HelpCommand, SubCommand

public abstract class Command extends Object
  • Field Details

    • childCommands

      public final Map<String,Command> childCommands
      List of available subcommands
  • Constructor Details

    • Command

      public Command()
    • Command

      public Command(Map<String,Command> childCommands)
  • Method Details

    • parseUsername

      protected static String parseUsername(String username) throws CommandException
      Throws:
      CommandException
    • parseUUID

      protected static UUID parseUUID(String s) throws CommandException
      Throws:
      CommandException
    • getArgsDescription

      public abstract String getArgsDescription()
    • getUsageDescription

      public abstract String getUsageDescription()
    • buildCandidate

      public org.jline.reader.Candidate buildCandidate(CommandHandler.Category category, String commandName)
      Creates a JLine candidate that appears in the list of available options when you press TAB
      Parameters:
      category - this command category
      commandName - this command name
      Returns:
      JLine Candidate
    • complete

      public List<org.jline.reader.Candidate> complete(List<String> words, int wordIndex, String word)
      Returns a list of available options for the next word for the current command.
      Parameters:
      words - list all user words
      wordIndex - current word index
      word - current word
      Returns:
      list of available Candidate
    • invokeSubcommands

      public void invokeSubcommands(String... args) throws Exception
      Transfer control to subcommands
      Parameters:
      args - command arguments(includes subcommand name)
      Throws:
      Exception - Error executing command
    • invoke

      public abstract void invoke(String... args) throws Exception
      Run current command
      Parameters:
      args - command arguments
      Throws:
      Exception - Error executing command
    • verifyArgs

      protected final void verifyArgs(String[] args, int min) throws CommandException
      Throws:
      CommandException