jqnatividad / qsv

CSVs sliced, diced & analyzed.
https://qsv.dathere.com
The Unlicense
2.45k stars 70 forks source link

Tab completion for commands, sub-commands and options #1690

Closed Guillawme closed 1 month ago

Guillawme commented 6 months ago

Is your feature request related to a problem? Please describe. I can't get tab completion for qsv commands, sub-commands and options, while I can get them when using xsv (unfortunately no longer maintained). The shell I use, fish, can automatically generate completions from man pages, but qsv doesn't have a man page.

Describe the solution you'd like Tab completion that works in the fish shell for qsv commands, sub-commands and options, regardless of how this is implemented (an exhaustive man page that fish can parse would be sufficient, and would also improve the documentation; but any other mechanism would be fine too).

Describe alternatives you've considered I use xsv interactively to get tab completions, and qsv in scripts once I have interactively figured out the command I need. But this only works for the set of commands present in both programs.

ondohotola commented 6 months ago

is that not mainly a shell issue?

feel  free to submit bash_completions…

jqnatividad commented 6 months ago

As @ondohotola said, feel free to submit bash_completions!

And you don't have to start from scratch! Perhaps, you can build on xsv's bash completion as qsv shares its docopt CLI parser.

https://github.com/jqnatividad/docopt.rs?tab=readme-ov-file#tab-completion-support

Guillawme commented 6 months ago

Sorry, I didn't make this clear in the first message, but I wrote this from the point of view of a user, not a developer. I have no clue how to follow your suggestions. Moreover, I don't use bash interactively, only fish. Fish can generate completions automatically in one command, but does it by parsing a man page, and qsv does not provide one.

is that not mainly a shell issue?

All I know is that xsv gives me tab completions, without me having done anything special other than installing it, while qsv doesn't. It would be helpful (surely not only to me) if it did. From this perspective, it doesn't look like a shell issue: some tools provide completions out of the box, the shell I use provides a mechanism to automatically generate completions for the tools that don't come with them. Unfortunately qsv provides none of these options.

Tab completion is great for discoverability, so this suggestion seems to fit well the stated goal of being "As Easy to Use as Possible" (quoting the README). I understand that given limited time, other features probably need more attention, so no worries. And sorry I can't offer to contribute (I will try, if I ever take time to figure this out).

jqnatividad commented 6 months ago

Thanks for clarifying @Guillawme . Using docopt, and remaining with it with our own qsv specific fork was a "considered" decision - https://github.com/jqnatividad/qsv/discussions/463, so I doubt I'll ever create man pages unless somebody from the community decides to do so.

What we are doing is working on qsv-pro - which aims to make it much easier to leverage the power of qsv - going beyond tab completions (which, is still only a small subset of Data Analysts - folks who are comfortable with a command line interface) to something that ANYBODY can use.

The spreadsheet interface will allow you to load a CSV/spreadsheet, even a very large one that regular spreadsheet software cannot load - apply qsv operations to it; run recipes (that you can download from a recipe library, and you can even create, modify and share your recipes - recipes can be written with Luau or Python); work with different cloud providers, etc.

Recipes should make it easier to use qsv, but we're also experimenting with a natural language interface which will write the qsv command for you based on a natural language request.

I touched on it in a recent presentation I gave at the Mar 2024 CKAN Monthly Live and we'll dive into it a bit more at csvconf.com.

Time allowing, I may get around to enabling tab completion, starting with bash first by renovating the existing docopt-wordlist-bash code. Hopefully, some other member of the community contributes fish shell integration.

rzmk commented 6 months ago

1307 may be relevant for similar implementations.

jqnatividad commented 5 months ago

Thanks @rzmk for your Bashly implementation.

Hopefully, that is but the first tab completion contribution...

rzmk commented 3 months ago

@Guillawme you may find this useful https://github.com/jqnatividad/qsv/tree/master/contrib/fish (from #1884).

rzmk commented 2 months ago

@Guillawme This is also now available: https://github.com/jqnatividad/qsv/blob/master/contrib/completions/examples/qsv.fish

Guillawme commented 2 months ago

Awesome, thank you! :+1:

jqnatividad commented 1 month ago

Closing this now that we have extensive tab completion support thanks to @rzmk !