Package com.github.copilot.sdk.json
Class CommandDefinition
java.lang.Object
com.github.copilot.sdk.json.CommandDefinition
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the human-readable description shown in the command completion UI.Gets the handler invoked when the command is executed.getName()Gets the command name (without leading/).setDescription(String description) Sets the human-readable description shown in the command completion UI.setHandler(CommandHandler handler) Sets the handler invoked when the command is executed.Sets the command name (without leading/).
-
Constructor Details
-
CommandDefinition
public CommandDefinition()
-
-
Method Details
-
getName
Gets the command name (without leading/).- Returns:
- the command name
-
setName
Sets the command name (without leading/).For example,
"deploy"registers the/deploycommand.- Parameters:
name- the command name- Returns:
- this instance for method chaining
-
getDescription
Gets the human-readable description shown in the command completion UI.- Returns:
- the description, or
nullif not set
-
setDescription
Sets the human-readable description shown in the command completion UI.- Parameters:
description- the description- Returns:
- this instance for method chaining
-
getHandler
Gets the handler invoked when the command is executed.- Returns:
- the command handler
-
setHandler
Sets the handler invoked when the command is executed.- Parameters:
handler- the command handler- Returns:
- this instance for method chaining
-