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

add shell completions generation #1031

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

NickyMeuleman
Copy link

@NickyMeuleman NickyMeuleman commented Oct 5, 2023

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 the tokei:: and crate:: use statements in cli.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.

@Laura7089
Copy link

I'd love to see this merged!

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.

None yet

2 participants