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 a subcommand to generate shell completions #427

Merged
merged 1 commit into from
Aug 11, 2021
Merged

Add a subcommand to generate shell completions #427

merged 1 commit into from
Aug 11, 2021

Conversation

messense
Copy link
Contributor

@messense messense commented Jul 31, 2021

This can be used by Homebrew formula to automatically generate shell completions.

$ py-spy completions --help
py-spy-completions
Generate shell completions

USAGE:
    py-spy completions [shell]

OPTIONS:
    -h, --help       Prints help information
    -V, --version    Prints version information

ARGS:
    <shell>    Shell type [possible values: zsh, bash, fish, powershell, elvish]

"completions" => {
let shell = value_t!(matches.value_of("shell"), clap::Shell).unwrap_or_else(|e| e.exit());
app.gen_completions_to(crate_name!(), shell, &mut std::io::stdout());
std::process::exit(0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like this, but IMO Config is currently too tied with clap::App.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case you don't know, I'd recommend using structopt instead of using clap directly.

@benfred benfred merged commit 885fe20 into benfred:master Aug 11, 2021
@benfred
Copy link
Owner

benfred commented Aug 11, 2021

thanks!

@messense messense deleted the generate-shell-completions branch August 11, 2021 22:51
manuels pushed a commit to manuels/py-spy that referenced this pull request Aug 16, 2021
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.

2 participants