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

Include shell completion for Cargo #1425

Closed
wants to merge 5 commits into from

Conversation

ricvelozo
Copy link
Contributor

@ricvelozo ricvelozo commented Jun 2, 2018

Copy link
Contributor

@Diggsey Diggsey left a 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)";
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

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 {
Copy link
Contributor

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(
Copy link
Contributor

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

Copy link
Contributor Author

@ricvelozo ricvelozo Jun 10, 2018

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<()> {
Copy link
Contributor

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.

@bors
Copy link
Contributor

bors commented Jan 8, 2019

☔ The latest upstream changes (presumably #1576) made this pull request unmergeable. Please resolve the merge conflicts.

@nrc
Copy link
Member

nrc commented Jan 14, 2019

Closing due to lack of activity and reviewer bandwidth.

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.

5 participants