Command Context

The CommandContext interface gives you access to the context of the currently running command. It provides access to the parsed command input, command registry, and other useful information.

@Command(name = "hello")
public void sayHello(CommandContext commandContext) {
	// use command context to get options, arguments and output writer
}

If you need to read input from the shell, you can get the InputReader from the CommandContext and use it to read input. You can find more details about reading from a shell in the Reading Input section.

If you need to print something into a shell, you can get a PrintWriter from the CommandContext and use it to print text. You can find more details about writing into a shell in the Writing Output section.