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

Generate completions with miniserve --print-completions <shell> #482

Merged
merged 1 commit into from
Mar 28, 2021

Conversation

rouge8
Copy link
Contributor

@rouge8 rouge8 commented Mar 26, 2021

This patch adds a completions subcommand --print-completions option to generate shell completion files at runtime. This ensures the completions are always up to date.

Fixes #377.

CI should pass once #481 is merged. This is some of my first Rust code so lmk if I'm doing anything weird...

@rouge8 rouge8 force-pushed the shell-completions branch 2 times, most recently from a2548dd to b2856f8 Compare March 26, 2021 11:58
Copy link
Owner

@svenstaro svenstaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks a ton! I've been meaning to do this but you just went ahead and did it and that's great! My thoughts are: Shall we make this an option rather than a subcommand? We don't use any subcommands in miniserve so far and I don't really want to change the user flow for this particular thing. I imagine something like --print-completions <shell> and then also restrict it to the available shells for better user feedback.

@rouge8 rouge8 changed the title Generate completions with miniserve completions <shell> Generate completions with miniserve --print-completions <shell> Mar 28, 2021
@rouge8
Copy link
Contributor Author

rouge8 commented Mar 28, 2021

Shall we make this an option rather than a subcommand? We don't use any subcommands in miniserve so far and I don't really want to change the user flow for this particular thing. I imagine something like --print-completions

Agreed, done! I got the subcommand idea from #377, but I agree another option makes more sense here.

also restrict it to the available shells for better user feedback.

Yup, that part is done by using the structopt::clap::Shell enum as the option type: https://github.com/svenstaro/miniserve/pull/482/files#diff-c3fd08257cd326dfa1c2a3c0a69e6b842f194950ac32e7b2c6e2750f52d1765fR137. I added a test with an invalid shell option to ensure it fails.

@rouge8 rouge8 requested a review from svenstaro March 28, 2021 17:20
This patch adds a `--print-completions` option to generate shell
completion files at runtime. This ensures the completions are always up
to date.

Fixes svenstaro#377.
Copy link
Owner

@svenstaro svenstaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thanks!

@svenstaro svenstaro merged commit dbb01e6 into svenstaro:master Mar 28, 2021
@rouge8 rouge8 deleted the shell-completions branch March 28, 2021 19:43
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.

Request: Generate shell completion files
2 participants