add shell completion for flamegraph #153
Merged
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.
About
This PR adds shell auto-completion support for the
flamegraph
binary.flamegraph --completions <shell>
prints the completion script for the given shell to stdout. Currently supported shells arebash
,fish
,powershell
andelvish
(andzsh
but it does not work).Internally,
clap
s completion generation is used.Known issues/limitations:
Completions must be installed manually.
cargo install
does not support installing extra files right now ifclap
s documentation is to be believed. This means we cannot place a completion script into a completion directory for the user on install and would have to provide a distribution package (deb
,rpm
, ...) for this.No completions for
cargo flamegraph
.As far as I know, there is no official way to get completions for custom cargo subcommands. I tried getting it to work anyway without success. The issue is that you have to provide a binary name for which the completions will be generated.
cargo-flamegraph
sort of works for this if you invoke it directly but does not work at all when usingcargo flamegraph
as a custom subcommand.cargo
as the binary name seems to be working great forcargo flamegraph
. However it overrides existing completions so that you lose completions forcargo build
etc.Invoking
flamegraph --completions zsh
panics.I didn't look into this.
clap
panics: