Class CommandMethods

java.lang.Object
org.jline.console.CommandMethods

public class CommandMethods extends Object
Class that encapsulates the execution and completion methods for a command.

CommandMethods provides a way to associate a command execution function with a completer compilation function. This allows commands to be registered with both their execution logic and their completion logic in a single object.

  • Constructor Details

    • CommandMethods

      public CommandMethods(Function<CommandInput,?> execute, Function<String,List<org.jline.reader.Completer>> compileCompleter)
      Creates a new CommandMethods with the specified execution and completer compilation functions.

      This constructor takes a function that returns a result when executing the command.

      Parameters:
      execute - the function that executes the command and returns a result
      compileCompleter - the function that compiles completers for the command
    • CommandMethods

      public CommandMethods(Consumer<CommandInput> execute, Function<String,List<org.jline.reader.Completer>> compileCompleter)
      Creates a new CommandMethods with the specified execution and completer compilation functions.

      This constructor takes a consumer that doesn't return a result when executing the command. The execution function is wrapped to return null after executing the consumer.

      Parameters:
      execute - the consumer that executes the command without returning a result
      compileCompleter - the function that compiles completers for the command
  • Method Details

    • execute

      public Function<CommandInput,?> execute()
      Returns the function that executes the command.
      Returns:
      the function that executes the command
    • compileCompleter

      public Function<String,List<org.jline.reader.Completer>> compileCompleter()
      Returns the function that compiles completers for the command.
      Returns:
      the function that compiles completers for the command