I want to make a console application with jline and brigadier, but I have problem on command completing. I can complete the literal command but can't complete argument commands.
What I did:
private static List<Completers.TreeCompleter.Node> generateNodes(CommandNode<ConsoleSender> root) {
List<Completers.TreeCompleter.Node> nodes = new ArrayList<>();
for (CommandNode<ConsoleSender> commandNode : root.getChildren()) {
List<Object> objects = new ArrayList<>();
if (commandNode instanceof ArgumentCommandNode<?, ?>) {
objects.add(new StringsCompleter()); // cannot complete if user input non-literal arguments
} else {
objects.add(commandNode.getName());
}
objects.addAll(generateNodes(commandNode));
nodes.add(Completers.TreeCompleter.node(objects.toArray()));
}
return nodes;
}
> hello literal // can complete well
> hello <name: string value> literal // "literal" cannot be completed
What I want:
> hello literal // can complete well
> hello <name: string value> literal // "literal" can be completed well without bugs whatever the value of name argument is