Class Completers.TreeCompleter

java.lang.Object
org.jline.builtins.Completers.TreeCompleter
All Implemented Interfaces:
Completer
Enclosing class:
Completers

public static class Completers.TreeCompleter extends Object implements Completer
A completer that supports hierarchical command structures.

This completer allows defining a tree of command nodes, where each node can have its own completer and child nodes. It's useful for implementing command hierarchies where different completions are available at different levels of the command structure.

  • Constructor Details

    • TreeCompleter

      public TreeCompleter(Completers.TreeCompleter.Node... nodes)
      Creates a new TreeCompleter with the specified nodes.
      Parameters:
      nodes - the root nodes of the completion tree
    • TreeCompleter

      public TreeCompleter(List<Completers.TreeCompleter.Node> nodes)
      Creates a new TreeCompleter with the specified list of nodes.
      Parameters:
      nodes - the list of root nodes of the completion tree
  • Method Details

    • node

      public static Completers.TreeCompleter.Node node(Object... objs)
      Creates a new node for the completion tree.

      This method accepts various types of objects and constructs a node based on their types:

      • String objects are converted to Candidate objects
      • Candidate objects are used directly
      • Node objects are added as child nodes
      • Completer objects are used as the node's completer
      Parameters:
      objs - the objects to include in the node
      Returns:
      a new Node instance
      Throws:
      IllegalArgumentException - if the objects cannot form a valid node
    • complete

      public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates)
      Completes the current input line using the tree structure.

      Delegates to the RegexCompleter which handles the tree structure.

      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: