Reputation: 1596
I'm trying to provide completion for positional parameters. Somewhere I found note that they are not very well supported, but currently I'm not able to find exact place in spec and I'm not sure what that really means.
In meantime I found CompletionCandidatesTest.java in sources which would suggest that they're supported in some fashion or at least prepared to support it.
That's why I would like to know if they work and if yes what I'm doing wrong. Currently my code in Groovy looks like this:
package com.some.package
import picocli.CommandLine
import picocli.CommandLine.Command
@Command
class TjTest implements Runnable {
static class TjTestCandidates implements Iterable<String> {
@Override
Iterator<String> iterator() {
return Arrays.asList("aaaa", "bbbb", "cccc", "dddd", "eeeee", "ffff").iterator()
}
}
@CommandLine.Option(names = "-x", completionCandidates = TjTestCandidates)
String x;
@CommandLine.Parameters(completionCandidates = TjTestCandidates)
String param;
@Override
public void run() {
println "Start"
println x
println param;
println "Stop"
}
public static void main(String[] args) {
CommandLine.run(new TjTest(), args);
}
}
I performed required bash commands like this:
java -cp "picocli-3.9.5.jar;tj.jar" picocli.AutoComplete -f -n tjtest com.some.package.TjTest
. tjtest_completion
It works like a charm for an option. Unfortunately I was not able to make it work for parameter. I was also trying to:
Upvotes: 3
Views: 698
Reputation: 36754
Your code looks fine. The current state (picocli 3.9.5) is that positional parameter completion works in JLine, but not in bash/zsh.
There is an outstanding todo item to fix this. Someone contributed a pull request to address this but it had an issue and has not been merged.
Contributions are welcome!
Upvotes: 1