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

Automatic shell completion generation using xtask. #1068

Closed

Conversation

ThomasFrans
Copy link
Contributor

This adds the option to automatically generate shell completion scripts for a variety of shells (currently bash, zsh, fish, elvish and powershell) using cargo xtask generate-shell-completion. It uses the crate clap_complete to automatically create these completions based on the clap::Command struct. It could be handy for package maintainers to add these scripts to their package.

This changes the default behavior of the `cargo run` command for xtasks
to hide the compilation info. This makes sense as xtask's are run as a
program, and showing the compilation info every time clutters stdout
with unrelated info.
Moving the `clap::Command` used internally by ncspot to a library allows
it to be easily shared between different packages (xtask and ncspot
itself).

This commit also reworks the xtasks to use clap for parsing the xtask
arguments, which simplifies writing new xtasks.
Add automatic generation of shell completion scripts for various shells
(the ones supported by `clap_complete`). The scripts can be generated
using the `generate-shell-completion` xtask, which outputs the shell
script to stdout.
@ThomasFrans
Copy link
Contributor Author

ThomasFrans commented Mar 2, 2023

I feel like I'm not contributing a lot of code in the last few PRs...
...

Anyways, automatic shell completion script generation using xtask. Now we never have to type --debug again, because it's so long... Totally worth it... 😐

I know this isn't really required but I like when apps adhere to the most common conventions/rules of an OS, so I thought being able to generate shell completions would be nice for package maintainers, so they can add shell completion scripts with the package. What do you think? 😁

The reason I keep these as a draft for now is related to an issue I created recently. I'm wondering how packagers will find these new options. One option is just to add info to the README but I don't think everyone would notice that. Another option is to hope the packagers notice this in the changelog. I think the best option would be as mentioned in issue #1061, where there is a separate section for packagers, mentioned clearly in the top level README. The files could also be provided upstream so packagers only have to install them. Many options...

Next up: Appstream for nicer Flathub?

@ThomasFrans ThomasFrans closed this Mar 7, 2023
@ThomasFrans ThomasFrans deleted the shell-completion-generation branch May 11, 2023 15:50
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

Successfully merging this pull request may close these issues.

1 participant