java.lang.Object
org.jline.picocli.PicocliCommandRegistry
- All Implemented Interfaces:
org.jline.console.CommandRegistry,org.jline.shell.CommandGroup
public class PicocliCommandRegistry
extends Object
implements org.jline.console.CommandRegistry, org.jline.shell.CommandGroup
A
CommandRegistry that bridges picocli CommandLine subcommands
into the JLine console framework.
This registry exposes picocli subcommands as JLine commands, providing tab completion, command descriptions for TailTipWidgets, and command execution.
Example usage:
CommandLine commandLine = new CommandLine(new MyApp());
PicocliCommandRegistry registry = new PicocliCommandRegistry(commandLine);
Shell shell = Shell.builder()
.commands(registry)
.build();
shell.run();
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jline.console.CommandRegistry
org.jline.console.CommandRegistry.CommandSession -
Constructor Summary
ConstructorsConstructorDescriptionPicocliCommandRegistry(picocli.CommandLine commandLine) Creates a new registry wrapping the given picocliCommandLine.PicocliCommandRegistry(picocli.CommandLine commandLine, String name) Creates a new registry wrapping the given picocliCommandLinewith a custom display name. -
Method Summary
Modifier and TypeMethodDescriptionorg.jline.console.CmdDesccommandDescription(List<String> args) commandInfo(String command) Collection<org.jline.shell.Command> commands()org.jline.reader.impl.completer.SystemCompleterpicocli.CommandLineReturns the underlying picocliCommandLine.booleanhasCommand(String command) name()voidsetLineReader(org.jline.reader.LineReader reader) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jline.shell.CommandGroup
command
-
Constructor Details
-
PicocliCommandRegistry
public PicocliCommandRegistry(picocli.CommandLine commandLine) Creates a new registry wrapping the given picocliCommandLine. The subcommands of the command line become the commands of this registry.- Parameters:
commandLine- the picocli command line whose subcommands to expose
-
PicocliCommandRegistry
Creates a new registry wrapping the given picocliCommandLinewith a custom display name.- Parameters:
commandLine- the picocli command line whose subcommands to exposename- the display name for this command group (defaults to class name if null)
-
-
Method Details
-
name
- Specified by:
namein interfaceorg.jline.shell.CommandGroup- Specified by:
namein interfaceorg.jline.console.CommandRegistry
-
setLineReader
public void setLineReader(org.jline.reader.LineReader reader) -
commandNames
- Specified by:
commandNamesin interfaceorg.jline.console.CommandRegistry
-
commandAliases
- Specified by:
commandAliasesin interfaceorg.jline.console.CommandRegistry
-
commandInfo
- Specified by:
commandInfoin interfaceorg.jline.console.CommandRegistry
-
hasCommand
- Specified by:
hasCommandin interfaceorg.jline.shell.CommandGroup- Specified by:
hasCommandin interfaceorg.jline.console.CommandRegistry
-
compileCompleters
public org.jline.reader.impl.completer.SystemCompleter compileCompleters()- Specified by:
compileCompletersin interfaceorg.jline.console.CommandRegistry
-
commandDescription
- Specified by:
commandDescriptionin interfaceorg.jline.console.CommandRegistry
-
invoke
public Object invoke(org.jline.console.CommandRegistry.CommandSession session, String command, Object... args) throws Exception - Specified by:
invokein interfaceorg.jline.console.CommandRegistry- Throws:
Exception
-
commands
- Specified by:
commandsin interfaceorg.jline.shell.CommandGroup
-
getCommandLine
public picocli.CommandLine getCommandLine()Returns the underlying picocliCommandLine.- Returns:
- the command line
-