Class ArgumentCompleter

java.lang.Object
org.jline.reader.impl.completer.ArgumentCompleter
All Implemented Interfaces:
Completer

public class ArgumentCompleter extends Object implements Completer
A Completer implementation that invokes a child completer using the appropriate separator argument. This can be used instead of the individual completers having to know about argument parsing semantics.
Since:
2.3
  • Constructor Details

    • ArgumentCompleter

      public ArgumentCompleter(Collection<Completer> completers)
      Create a new completer.
      Parameters:
      completers - The embedded completers
    • ArgumentCompleter

      public ArgumentCompleter(Completer... completers)
      Create a new completer.
      Parameters:
      completers - The embedded completers
  • Method Details

    • setStrict

      public void setStrict(boolean strict)
      If true, a completion at argument index N will only succeed if all the completions from 0-(N-1) also succeed.
      Parameters:
      strict - the strict flag
    • setStrictCommand

      public void setStrictCommand(boolean strictCommand)
      If true, a completion at argument index N will only succeed if all the completions from 1-(N-1) also succeed.
      Parameters:
      strictCommand - the strictCommand flag
    • isStrict

      public boolean isStrict()
      Returns whether a completion at argument index N will success if all the completions from arguments 0-(N-1) also succeed.
      Returns:
      True if strict.
      Since:
      2.3
    • getCompleters

      public List<Completer> getCompleters()
      Returns the list of completers used inside this ArgumentCompleter.
      Returns:
      The list of completers.
      Since:
      2.3
    • complete

      public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates)
      Description copied from interface: Completer
      Populates candidates with a list of possible completions for the command line.

      The list of candidates will be sorted and filtered by the LineReader, so that the list of candidates displayed to the user will usually be smaller than the list given by the completer. Thus it is not necessary for the completer to do any matching based on the current buffer. On the contrary, in order for the typo matcher to work, all possible candidates for the word being completed should be returned.

      Implementations should add Candidate objects to the candidates list. Each candidate can include additional information such as descriptions, groups, and display attributes that will be used when presenting completion options to the user.

      This method is called by the LineReader when the user requests completion, typically by pressing the Tab key.

      Specified by:
      complete in interface Completer
      Parameters:
      reader - The line reader instance that is requesting completion
      line - The parsed command line containing the current input state
      candidates - The List of candidates to populate with completion options
      See Also: