- java.lang.Object
-
- org.jline.picocli.PicocliCommandRegistry
-
- All Implemented Interfaces:
org.jline.console.CommandRegistry,org.jline.shell.CommandGroup
public class PicocliCommandRegistry extends java.lang.Object implements org.jline.console.CommandRegistry, org.jline.shell.CommandGroupACommandRegistrythat bridges picocliCommandLinesubcommands 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();
-
-
Constructor Summary
Constructors Constructor Description PicocliCommandRegistry(picocli.CommandLine commandLine)Creates a new registry wrapping the given picocliCommandLine.PicocliCommandRegistry(picocli.CommandLine commandLine, java.lang.String name)Creates a new registry wrapping the given picocliCommandLinewith a custom display name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.String>commandAliases()org.jline.console.CmdDesccommandDescription(java.util.List<java.lang.String> args)java.util.List<java.lang.String>commandInfo(java.lang.String command)java.util.Set<java.lang.String>commandNames()java.util.Collection<org.jline.shell.Command>commands()org.jline.reader.impl.completer.SystemCompletercompileCompleters()picocli.CommandLinegetCommandLine()Returns the underlying picocliCommandLine.booleanhasCommand(java.lang.String command)java.lang.Objectinvoke(org.jline.console.CommandRegistry.CommandSession session, java.lang.String command, java.lang.Object... args)java.lang.Stringname()voidsetLineReader(org.jline.reader.LineReader reader)
-
-
-
Constructor Detail
-
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
public PicocliCommandRegistry(picocli.CommandLine commandLine, java.lang.String name)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 Detail
-
name
public java.lang.String 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
public java.util.Set<java.lang.String> commandNames()
- Specified by:
commandNamesin interfaceorg.jline.console.CommandRegistry
-
commandAliases
public java.util.Map<java.lang.String,java.lang.String> commandAliases()
- Specified by:
commandAliasesin interfaceorg.jline.console.CommandRegistry
-
commandInfo
public java.util.List<java.lang.String> commandInfo(java.lang.String command)
- Specified by:
commandInfoin interfaceorg.jline.console.CommandRegistry
-
hasCommand
public boolean hasCommand(java.lang.String command)
- 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
public org.jline.console.CmdDesc commandDescription(java.util.List<java.lang.String> args)
- Specified by:
commandDescriptionin interfaceorg.jline.console.CommandRegistry
-
invoke
public java.lang.Object invoke(org.jline.console.CommandRegistry.CommandSession session, java.lang.String command, java.lang.Object... args) throws java.lang.Exception- Specified by:
invokein interfaceorg.jline.console.CommandRegistry- Throws:
java.lang.Exception
-
commands
public java.util.Collection<org.jline.shell.Command> commands()
- Specified by:
commandsin interfaceorg.jline.shell.CommandGroup
-
getCommandLine
public picocli.CommandLine getCommandLine()
Returns the underlying picocliCommandLine.- Returns:
- the command line
-
-