Class PicocliCommandRegistry

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();
 
  • Constructor Details

    • PicocliCommandRegistry

      public PicocliCommandRegistry(picocli.CommandLine commandLine)
      Creates a new registry wrapping the given picocli CommandLine. 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, String name)
      Creates a new registry wrapping the given picocli CommandLine with a custom display name.
      Parameters:
      commandLine - the picocli command line whose subcommands to expose
      name - the display name for this command group (defaults to class name if null)
  • Method Details

    • name

      public String name()
      Specified by:
      name in interface org.jline.shell.CommandGroup
      Specified by:
      name in interface org.jline.console.CommandRegistry
    • setLineReader

      public void setLineReader(org.jline.reader.LineReader reader)
    • commandNames

      public Set<String> commandNames()
      Specified by:
      commandNames in interface org.jline.console.CommandRegistry
    • commandAliases

      public Map<String,String> commandAliases()
      Specified by:
      commandAliases in interface org.jline.console.CommandRegistry
    • commandInfo

      public List<String> commandInfo(String command)
      Specified by:
      commandInfo in interface org.jline.console.CommandRegistry
    • hasCommand

      public boolean hasCommand(String command)
      Specified by:
      hasCommand in interface org.jline.shell.CommandGroup
      Specified by:
      hasCommand in interface org.jline.console.CommandRegistry
    • compileCompleters

      public org.jline.reader.impl.completer.SystemCompleter compileCompleters()
      Specified by:
      compileCompleters in interface org.jline.console.CommandRegistry
    • commandDescription

      public org.jline.console.CmdDesc commandDescription(List<String> args)
      Specified by:
      commandDescription in interface org.jline.console.CommandRegistry
    • invoke

      public Object invoke(org.jline.console.CommandRegistry.CommandSession session, String command, Object... args) throws Exception
      Specified by:
      invoke in interface org.jline.console.CommandRegistry
      Throws:
      Exception
    • commands

      public Collection<org.jline.shell.Command> commands()
      Specified by:
      commands in interface org.jline.shell.CommandGroup
    • getCommandLine

      public picocli.CommandLine getCommandLine()
      Returns the underlying picocli CommandLine.
      Returns:
      the command line