JTerminal documentation Help

Commodore Tools

The Commodore framework offers the possibility to define several commands and provides a clear structure in programming.

Preparation

terminal.commandHandler(new ExampleCommandHandler()); //see next code block LineReader lineReader = terminal.lineReader(); lineReader.tabCompleter(new CommandTabCompleter(terminal)); lineReader.inputHistory(InputHistory.create(false)); terminal.lineReading(true);

Define command handler

Command: service <???> <start/stop>

public class ExampleCommandHandler extends CommodoreHandler<CommandArgument> { public ExampleCommandHandler() { super(new DefaultCommandParser()); } @Override protected void build(@NotNull CommodoreManager<CommandArgument> manager) throws CommandBuildException { manager.addCommand("service") .add(value("id") .suggestionResolver((suggestions, state) -> { suggestions.add(...) }) .styleEditor(highlightStyle(TerminalColor.YELLOW)) .add(literal("start") .execute(state -> { CommandArgument arg = state.argumentById("id"); ... }) ).add(literal("stop") .execute(state -> { CommandArgument arg = state.argumentById("id"); ... }) ) ); manager.unknownCommandExecute(state -> { System.out.println("Unknown Command!"); }); } }

Style Editor templates

There are style templates for arguments at CommodoreHelper interface:

  • highlightStyle(foreground_color)

  • passwordStyle()

  • numberInvalidStyle()

  • modifiedStyle(func(state) => textstyle)

Last modified: 01 Juni 2025