Class Completers.Completer

  • All Implemented Interfaces:
    Completer
    Enclosing class:
    Completers

    public static class Completers.Completer
    extends java.lang.Object
    implements Completer
    A completer implementation that provides command and argument completion.

    This completer uses a CompletionEnvironment to provide context-aware completion for commands and their arguments.

    • Constructor Detail

      • Completer

        public Completer​(Completers.CompletionEnvironment environment)
        Creates a new Completer with the specified environment.
        Parameters:
        environment - the completion environment to use
    • Method Detail

      • complete

        public void complete​(LineReader reader,
                             ParsedLine line,
                             java.util.List<Candidate> candidates)
        Completes the current input line.

        If the cursor is at the first word, completes command names. Otherwise, tries to complete command arguments.

        Specified by:
        complete in interface Completer
        Parameters:
        reader - the line reader
        line - the parsed command line
        candidates - the list to add completion candidates to
        See Also:
        Candidate
      • tryCompleteArguments

        protected void tryCompleteArguments​(LineReader reader,
                                            ParsedLine line,
                                            java.util.List<Candidate> candidates)
        Attempts to complete command arguments.

        Retrieves completion data for the command and delegates to completeCommandArguments if completion data is available.

        Parameters:
        reader - the line reader
        line - the parsed command line
        candidates - the list to add completion candidates to
      • completeCommandArguments

        protected void completeCommandArguments​(LineReader reader,
                                                ParsedLine line,
                                                java.util.List<Candidate> candidates,
                                                java.util.List<Completers.CompletionData> completions)
        Completes command arguments based on completion data.

        Processes each completion data entry and adds appropriate candidates based on the current command line state and completion conditions.

        Parameters:
        reader - the line reader
        line - the parsed command line
        candidates - the list to add completion candidates to
        completions - the list of completion data to process
      • completeCommand

        protected void completeCommand​(java.util.List<Candidate> candidates)
        Completes command names.

        Adds completion candidates for all available commands, including their descriptions if available.

        Parameters:
        candidates - the list to add completion candidates to