Class 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.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

      Constructors 
      Constructor Description
      PicocliCommandRegistry​(picocli.CommandLine commandLine)
      Creates a new registry wrapping the given picocli CommandLine.
      PicocliCommandRegistry​(picocli.CommandLine commandLine, java.lang.String name)
      Creates a new registry wrapping the given picocli CommandLine with 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.CmdDesc commandDescription​(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.SystemCompleter compileCompleters()  
      picocli.CommandLine getCommandLine()
      Returns the underlying picocli CommandLine.
      boolean hasCommand​(java.lang.String command)  
      java.lang.Object invoke​(org.jline.console.CommandRegistry.CommandSession session, java.lang.String command, java.lang.Object... args)  
      java.lang.String name()  
      void setLineReader​(org.jline.reader.LineReader reader)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.jline.shell.CommandGroup

        command
    • Constructor Detail

      • 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,
                                      java.lang.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 Detail

      • name

        public java.lang.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 java.util.Set<java.lang.String> commandNames()
        Specified by:
        commandNames in interface org.jline.console.CommandRegistry
      • commandAliases

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

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

        public boolean hasCommand​(java.lang.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​(java.util.List<java.lang.String> args)
        Specified by:
        commandDescription in interface org.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:
        invoke in interface org.jline.console.CommandRegistry
        Throws:
        java.lang.Exception
      • commands

        public java.util.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