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

[feature] shell completions #678

Open
Freed-Wu opened this issue May 25, 2023 · 3 comments
Open

[feature] shell completions #678

Freed-Wu opened this issue May 25, 2023 · 3 comments

Comments

@Freed-Wu
Copy link

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.

@wader
Copy link
Owner

wader commented May 25, 2023

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?

@Freed-Wu
Copy link
Author

Sorry, I am not familiar with golang 😢

@wader
Copy link
Owner

wader commented May 25, 2023

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.

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

2 participants