tomnomnom / gron

Make JSON greppable!
MIT License
13.73k stars 325 forks source link

Auto-provide command line completions #116

Open scop opened 10 months ago

scop commented 10 months ago

Currently there are manually written fish shell completions in the repo, and bash completions in a pull request.

I'd suggest switching command line option parsing to a thing that generates them automatically, and for more shells.

For example, https://github.com/spf13/cobra. https://github.com/mitchellh/cli is another alternative. And https://github.com/posener/complete/tree/master directly too (mitchellh/cli uses an earlier v1 version of this), but its "auto install" is in my opinion inferior.

Autogenerating completions to stdout makes it possible for example for bash-completion to load them automatically on demand, like https://github.com/scop/bash-completion/blob/master/completions/_golangci-lint (cobra flavor) or https://github.com/scop/bash-completion/blob/master/completions/_vault (mitchellh/cli flavor) -- we'd add such a snippet for gron if it had it. In such cases people would not have to bother with "installing" the completion files at all, it would Just Work.