ionic-team / ionic-cli

The Ionic command-line interface
MIT License
1.99k stars 648 forks source link

Auto completion of commands and options? #2482

Open janpio opened 7 years ago

janpio commented 7 years ago

Is it possible for a CLI tool to offer auto complete for commands and options?

Right now this only works for file names in my command line, but that would be really handy if Ionic CLI could autocomplete ionic c to ionic cordova when I press [Tab].

imhoffd commented 7 years ago

Something I had hoped for, too. Shouldn't be too hard since we have the metadata of all the commands. Maybe in the future, sometime.

janpio commented 7 years ago

Some other CLIs seem to offer something like this: https://akrabat.com/quick-tip-openwhisk-autocompletion/

imhoffd commented 7 years ago

@janpio Yep, we'd have to ship autocomplete functionality with the CLI. But we'd need to generate it from the command metadata just like how we generate the CLI docs. It would be a cool project but I don't have the time to prioritize it yet, unfortunately.

daraul commented 5 years ago

Other tools, like kubectl offer a command to enable completion for bash/zsh like this:

$ kubectl completion bash

Then you can enable completion in bash with $ source <(kubectl completion bash)

Just food for thought.

imhoffd commented 5 years ago

Thanks @daraul, that's what npm does too and it's exactly how I planned to accomplish this.

I looked into this and found that it's much simpler to provide completion for zsh. I may ship this feature just for zsh and reevaluate bash at a later date.

imhoffd commented 5 years ago

ZSH completion is going to be in CLI 5: https://github.com/ionic-team/ionic-cli/issues/3946

Still no updates for bash.