-
Notifications
You must be signed in to change notification settings - Fork 892
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
Include shell completion for Cargo #1425
Conversation
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.
Thanks for the PR! There are however a few changes needed before I'd be happy accepting it.
@@ -80,11 +80,34 @@ pub fn main() -> Result<()> { | |||
}, | |||
("completions", Some(c)) => { | |||
if let Some(shell) = c.value_of("shell") { | |||
let shell = shell.parse::<Shell>().unwrap(); | |||
let prefix = "~/.rustup/toolchains/$(rustup toolchain list --default)"; |
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.
This prefix is not correct - rustup is not necessarily installed here, and the default toolchain isn't necessarily correct.
To get the installation directory of the active toolchain, you should use rustc --print sysroot
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.
Does to replace the rustup toolchain list --default
for rustc --print sysroot
solves the problem? I have no way to know the toolchain that the user is using, just the default.
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.
@Diggsey Help me to finish this, please.
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.
rustc --print sysroot
will call the binary of the currently used toolchain.
&mut io::stdout(), | ||
); | ||
|
||
match shell { |
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.
Non-trivial logic like this should be pulled out into its own function.
@@ -172,7 +195,15 @@ pub fn cli() -> App<'static, 'static> { | |||
.setting(AppSettings::VersionlessSubcommands) | |||
.setting(AppSettings::DeriveDisplayOrder) | |||
.setting(AppSettings::SubcommandRequiredElseHelp) | |||
.subcommand(SubCommand::with_name("list").about("List installed toolchains")) | |||
.subcommand( |
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.
This change should not be necessary
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.
Are you requesting to remove the new --default
arg?
@@ -326,24 +327,32 @@ pub fn list_components(toolchain: &Toolchain) -> Result<()> { | |||
Ok(()) | |||
} | |||
|
|||
pub fn list_toolchains(cfg: &Cfg) -> Result<()> { | |||
pub fn list_toolchains(cfg: &Cfg, m: &ArgMatches) -> Result<()> { |
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.
Please revert the changes to this file as they should not be necessary.
☔ The latest upstream changes (presumably #1576) made this pull request unmergeable. Please resolve the merge conflicts. |
Closing due to lack of activity and reviewer bandwidth. |
rustup completions
(Install zsh completions for rustc #387, rustup completions don't include completions for Cargo cargo#5596)rustup toolchain list --default
(Machine-readable output #450, rustup show: add flag to show only active toolchain #1406)rustup completions bash
instructions to use home directory (Completion instructions for bash #1199)