Closed DevCubeHD closed 6 years ago
Could you be a bit more specific please ? I don't really understand what you want / need...
Thats hard to be more precise :D
I think a method in the LineReader to update the completer would be useful since not every implementation is static.
E.g. there are devs that can implement more commands via an API to my terminal.. the command contains its Argument nodes, but I cannot tell the reader because it does only update ist completer on initiation.
That's a start, but I'm still not completely with you. What do you mean by update its completer ? A completer does not have to be static, for example the org.jline.builtins.Completers$Completer
grabs its data from the CompletionEnvironment
which can then be updated at will between calls to readline()
. That's what is done in the main JLine demo, where the CompletionEnvironment
is actually filled by running a set of commands : this actually happens during initialisation, but the commands are accessible from the shell and calling the complete
command will actually affect the current shell completion system.
Could be that you are right but there is a chance we misunderstood each other. It is simple to find out:
Can you send me an example how I add a node to a TreeCompleter
after initializing the LineReader
?
The TreeCompleter
is static, but you could easily wrap it in a more dynamic completer:
public class DelegateCompleter implements Completer {
Completer delegate;
@Override
public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) {
delegate.complete(reader, line, candidates);
}
public void setCompleter(Completer delegate) {
this.delegate = delegate;
}
}
So that you can then keep a reference to that completer and call the following whenever you need
theCompleter.setCompleter(new TreeCompleter(xxx));
Thanks a lot! Your high availability for a free resource is much appreciated Sir! You are awesome! Keep on going.
//CLOSE
There really should be a method to update the completer of a LineReader while it's running. Thanks!