-
Notifications
You must be signed in to change notification settings - Fork 113
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
Support for tab completion #360
base: master
Are you sure you want to change the base?
Conversation
The "Lint Commits" action is failing, although I'm not sure whether it's my fault or not 🙂
|
|
||
#[derive(StructOpt, Debug, Clone)] | ||
pub struct CompletionsOpt { | ||
#[structopt(long, short = "s", possible_values = &clap::Shell::variants(), case_insensitive = true)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason you did case insensitive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, no particular reason. If I had to contrive one, people might do --shell=Bash
or similar and reasonably expect that to work. But I don't mind changing it to case sensitive at all, to keep the possibilities simpler.
Release(ReleaseOpt), | ||
Completions(CompletionsOpt), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come you did it at this level? I'm assuming most people will be running cargo-release
as cargo release
and not cargo-release
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put it at the top-level since that's how rustup
and a few other tools in the Rust packaging/toolchain ecosystem do it. My argument for that would be that cargo release
is how people should be running it interactively, but cargo-release completions [...]
makes more sense in the context of a shell profile (to emphasize that the completions are coming from just cargo-release
and that they aren't hooked up to the cargo
completions yet).
The complaint is
ie it isn't following conventional commit but also note it says
I need to go back and look at getting color enabled (the underlying tool supports it) so it'll be easier to see the problem. |
args::Command::clap().gen_completions_to( | ||
"cargo-release", | ||
completion_matches.shell, | ||
&mut io::stdout(), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should we document this capability, including giving the example code you had in the R?
We could probably put it in the long help for the command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, perhaps an FAQ entry? The example I included in the top comment is extremely specific to bash
, so including it in the long help might confuse users of other shells (zsh, fish, etc.)
We could also do it in the "reference" docs, although those seem to cover just the release
subcommand so perhaps not...
Thanks! I misread that error as the tool complaining about the commit's hash, not the commit message body. I'll tweak and amend the PR to bring it into compliance. |
099d328
to
c092742
Compare
c092742
to
c9132c3
Compare
First of all, thanks for creating
cargo-release
! I use it in virtually all of my Rust projects, and it's an absolute pleasure to use.This PR introduces self-generating tab completion (aka "shell completion" in some shells) to
cargo-release
. It usesclap
's built-in tab completion generation, by way ofstructop
. Every shell completion dialect supported byclap
is transparently supported bycargo-release
.By way of example, this command can be used to load shell completions for
cargo-release
into abash
session:This is similar but not identical to the CLI provided by tools like
rustup
, which exposesrustup completions [tool] [shell]
to provide completions.Let me know what you think! I'm happy to tweak the behavior, as desired.