Skip to content
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

autocomplete for subcommands #716

Closed
khaledosman opened this issue Nov 19, 2017 · 3 comments
Closed

autocomplete for subcommands #716

khaledosman opened this issue Nov 19, 2017 · 3 comments

Comments

@khaledosman
Copy link

Hi,

awesome tool, I have built some kind of cli with two subcommands "deploy" & "undeploy" and was wondering if there's a way to have the terminal autocomplete the subcommands when pressing "tab".. Is this supported via commander? if not any alternatives or ideas to implement this would be appreciated

Thanks

@shadowspawn
Copy link
Collaborator

shadowspawn commented Nov 20, 2017

Commander does not support command line completion itself.

I use tabtab, which has an implementation pattern inspired by npm.

(Of some interest, commander-completion is an older project to add commander completions automatically. I didn't get it working with current commander, but did look to the code for inspiration for parsing commander for commands and options. However, for your two subcommands I suggest it is easier to add them explicitly yourself than to generalise.)

@khaledosman
Copy link
Author

Thanks

@gutenye
Copy link

gutenye commented Dec 26, 2024

For anyone seeking a solution, I’ve developed @gutenye/commander-completion-carapace using Carapace. It's fast, works well, and supports numerous shells like Bash, Zsh, Fish, Nushell, and others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants