[feature] shell completions
Freed-Wu opened this issue · comments
Can it provide completions for common shells? Like https://github.com/cli/cli/blob/cf4b73ff958b272cf3c9c0cf9351459f76b793a0/pkg/cmd/completion/completion.go. https://jmtirado.net/shell-completion-with-cobra-and-go/ should be helpful.
Hey, yes that would be nice. Unfortunately fq does not use cobra or any common go argument parser package. This is because most of the CLI and glue code in fq is implemented with jq code, it makes many things smoother to implement but also some things harder :)
But i think it shouldn't be that much work to provide at least basic completion support via --completion
argument etc. All arguments are defined here https://github.com/wader/fq/blob/master/pkg/interp/options.jq#L383-L523 and to support completing decode names etc i guess one could generate calls to fq with small snippets? maybe could extend _opt_cli_opts
to include optional jq snippet to get possible values?
Let me know if it's something you would like to work on. Maybe i could spend some time adding support for one shell and then adding others would be easier?
Sorry, I am not familiar with golang 😢
No worries :) think i will try to do a quick stab at it. It will probably involve mostly writing jq code. Can let you know if/when i have something.