Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I heavily rely on shell completions for all CLI tools I use, it requires me to memorize less and prevents spelling mistakes.
This PR adds a way to generate shell completions.
Example of it running on my machine, using the zsh shell and using tab to see all possible completions, and sending the output for fish shell completions to a file:
https://asciinema.org/a/K0EIiTGadqN8N5MgeudE5GxDe
I originally wanted to generate completions in
build.rs
but I did not succeed because of issues described here: https://internals.rust-lang.org/t/problems-with-using-include-in-build-rs-for-rs-code/8447, even if I duplicated all dependencies into build-dependencies the compiler couldn't figure out thetokei::
andcrate::
use
statements incli.rs
This implementation adds the ability to print the contents of a completion file to stdout.
I'm still not very comfortable with Rust lifetimes, and the compiler suggested to use
'static
, it worked, but I lack the knowhow on how to prevent using a static lifetime.While this PR works, I'm sure it's not ideal and I opted for a PR instead of an issue since it's easier to see what I'm talking about this way.
I would like to rework this to make the buildtime completions generation work, and maybe even update the build pipeline in the future to include those in repo packages, but I'll need some help.