assetnote / kiterunner

Contextual Content Discovery Tool
GNU Affero General Public License v3.0
2.64k stars 296 forks source link

Bash & Zsh completion (WIP) #15

Open Albonycal opened 3 years ago

Albonycal commented 3 years ago

This adds auto completion for zsh & bash... How should we implement this? Like We can add just a couple lines to the Readme for bash or zsh completions, But how will this be implemented on pre-compiled binaries? Include the completion files with the archive? Thank you :)

minight commented 3 years ago

I would suggest leveraging the existing cobra framework for using completions. https://github.com/spf13/cobra/blob/master/shell_completions.md

This would then allow for baking the completion into the binary itself so people can just run kr completion zsh >> ~/.zshrc

Albonycal commented 3 years ago

Hmm.. Interesting.. ok

minight commented 3 years ago

You should be able to generate the completions by using cobra along the lines of

cd cmd/kiterunner
cobra add completions

I think. I haven't had a chance to try yet, but this might have the desired effect of generating autocompletion for all commands.

Additional work would be annotating specific flags with better autocompletion hints, like the output flag https://github.com/spf13/cobra/blob/master/shell_completions.md#specify-dynamic-flag-completion