Class ArgumentCompleter

  • All Implemented Interfaces:
    Completer

    public class ArgumentCompleter
    extends java.lang.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 Detail

      • ArgumentCompleter

        public ArgumentCompleter​(ArgumentCompleter.ArgumentDelimiter delimiter,
                                 java.util.Collection<Completer> completers)
        Create a new completer with the specified argument delimiter.
        Parameters:
        delimiter - The delimiter for parsing arguments
        completers - The embedded completers
      • ArgumentCompleter

        public ArgumentCompleter​(ArgumentCompleter.ArgumentDelimiter delimiter,
                                 Completer... completers)
        Create a new completer with the specified argument delimiter.
        Parameters:
        delimiter - The delimiter for parsing arguments
        completers - The embedded completers
    • Method Detail

      • 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.
      • 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 java.util.List<Completer> getCompleters()
        Since:
        2.3
      • complete

        public int complete​(java.lang.String buffer,
                            int cursor,
                            java.util.List<java.lang.CharSequence> candidates)
        Description copied from interface: Completer
        Populates candidates with a list of possible completions for the buffer. The candidates list will not be sorted before being displayed to the user: thus, the complete method should sort the List before returning.
        Specified by:
        complete in interface Completer
        Parameters:
        buffer - The buffer
        cursor - The current position of the cursor in the buffer
        candidates - The List of candidates to populate
        Returns:
        The index of the buffer for which the completion will be relative