-
Notifications
You must be signed in to change notification settings - Fork 420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to suggest options and sub-command at the same time? #827
Comments
Hi, that was done to allow default bash completions. My understanding is that the current picocli completion behaviour is consistent with bash-completion. I am open to improvements though. |
Hi, I have sping boot + picocli application. I want to implement TAB auto completion feature to show the params and options in my application. Could you please help me how to do that. I am using picocli-3.8.2.jar. Your help is most appriciated. Thanks |
Hi @DaitariJena1505, I would always recommend upgrading to the latest version (picocli 4.0.4). Is there anything preventing you from upgrading? About your question, have you had a chance to read the autocompletion user manual? |
No the problem is when i am executing the command : java -cp "picocli-3.8.2.jar:my.jar" picocli.AutoComplete -n login /BOOT-INF/classes/com.xyz.123.cli.command.LoginCommand , it is showing the error java.lang.ClassNotFoundException: /BOOT-INF/classes/com.xyz.123.cli.command.LoginCommand |
You need to specify a fully qualified class name. Have you tried without the “ /BOOT-INF/classes/” prefix?
|
Yes, i have tried that one also but same issue. |
Surely it cannot be the same; at least the error message should be different... Can you let me know the exact error message? Is there any way for me to try to reproduce the issue? Could you create a test project? |
Also, can you post the result of |
5372 Mon Nov 18 12:53:26 GMT 2019 |
Ok that’s the problem. That’s a Spring executable jar, not a normal jar. Your LoginCommand class is not visible on the classpath. Can you extract your class and run the autocompletion generator again? |
After extraction, where i will put the class ? |
Just any directory is fine. For example:
Then, run:
|
@DaitariJena1505 By the way, see AutoCompletion distribution for an alternative way to distribute autocompletion scripts with your application: the idea is to give your top-level command a subcommand that end-users can use to generate and install the autocompletion script. (Just an idea.) |
Sorry to ask again, after extract the LoginCommand.class i have to create folder structure as above and re-build the jar again ? |
After you have run |
Do you have any sample project for Auto completion ? If you can share it would be a great help for me. |
After generating the completion script, how will i use that script ? |
@DaitariJena1505 You install it by sourcing the script. Then you can use tab completion for that command in that shell session. |
You mean to say i have to run -> source login_completion |
No, if you run If your command is When you create an autocompletion script you need to specify the command name. This command name (basically your script) is associated with a specific completion script and only when users enter that command it will trigger the bash completion for that command. |
Hi, Step 1 : alias login='java -cp "picocli-3.8.2.jar:myproject.jar" com.test.LoginCommand' Step 2 : java -cp "picocli-3.8.2.jar:myproject.jar" picocli.AutoComplete -n login com.xyz.123.cli.command.LoginCommand Step 3: Auto Completion script got created with the name - login_completion Step 4 : i have write a script where i have to write the below code. echo "alias login='java -cp "picocli-1.0.0.jar;myproject.jar" com.test.LoginCommand'" >> ~/.bashrc Could you please confirm if the above steps are correct for auto completion. |
Looks more or less okay. Some details: Use full path to the jars in the alias: if the user invokes the In the alias, the class name is
|
Closing for now: current picocli completion behaviour is consistent with bash-completion. |
Hi,
I have command line like "icmd -v -h -o sub1 sub2", and sub1 and sub2 are sub commands. I tried to use picocli(version is 4.0.4) to generate auto completion script, and it only works as below:
->icmd TAB TAB
sub1 sub2
->icmd -TAB
-v -h -o
But actually I want to show all options and sub-command as below. How should I do? Thanks.
->icmd
-v -h -o sub1 sub2
The text was updated successfully, but these errors were encountered: