Class CommandDefinition

java.lang.Object
com.github.copilot.sdk.json.CommandDefinition

public class CommandDefinition extends Object
Defines a slash command that users can invoke from the CLI TUI.

Register commands via SessionConfig.setCommands(java.util.List) or ResumeSessionConfig.setCommands(java.util.List). Each command appears as /name in the CLI TUI.

Example Usage


 var config = new SessionConfig().setCommands(List.of(
 		new CommandDefinition().setName("deploy").setDescription("Deploy the application").setHandler(context -> {
 			System.out.println("Deploying: " + context.getArgs());
 			return CompletableFuture.completedFuture(null);
 		})));
 
Since:
1.0.0
See Also:
  • Constructor Details

    • CommandDefinition

      public CommandDefinition()
  • Method Details

    • getName

      public String getName()
      Gets the command name (without leading /).
      Returns:
      the command name
    • setName

      public CommandDefinition setName(String name)
      Sets the command name (without leading /).

      For example, "deploy" registers the /deploy command.

      Parameters:
      name - the command name
      Returns:
      this instance for method chaining
    • getDescription

      public String getDescription()
      Gets the human-readable description shown in the command completion UI.
      Returns:
      the description, or null if not set
    • setDescription

      public CommandDefinition setDescription(String description)
      Sets the human-readable description shown in the command completion UI.
      Parameters:
      description - the description
      Returns:
      this instance for method chaining
    • getHandler

      public CommandHandler getHandler()
      Gets the handler invoked when the command is executed.
      Returns:
      the command handler
    • setHandler

      public CommandDefinition setHandler(CommandHandler handler)
      Sets the handler invoked when the command is executed.
      Parameters:
      handler - the command handler
      Returns:
      this instance for method chaining