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

Shell completions for Cargo #1646

Merged
merged 13 commits into from
Apr 14, 2019
Merged

Conversation

yodaldevoid
Copy link
Contributor

This is a cleanup of a prior PR (#1425) by @ricvelozo.

  • Adds the ability to output shell completions for cargo using the command rustup completions <shell> cargo
  • Updates the completion instructions to mention and suggest placing bash completions in the home directory.

@kinnison
Copy link
Contributor

Hi @yodaldevoid

Thanks for your contribution. Could you possibly tidy up the commit sequence (e.g. fold the fixes to formatting into the requisite commits instead of having a 'run rustfmt' commit) to make it easier to review?

I've put this PR on my list to watch but I'd like to see things a little tidier before I review.

I look forward to your changes.

D

@yodaldevoid
Copy link
Contributor Author

Hello @kinnison

Thanks for getting to looking over this. I've tidied up the rustfmt commit, but no other commits jumped out at me as being appropriate to tidy up. Is there anything else you would like cleaned up?

I should note that I wanted to keep @ricvelozo's commits mostly intact. They could get merged together with other commits, to condense everything, but I wanted to preserve his contribution.

@kinnison
Copy link
Contributor

Fair enough, I can appreciate wanting to maintain that. I'll put this on my list to review as soon as I can (likely within a day or two)

@bors
Copy link
Contributor

bors commented Feb 26, 2019

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

@yodaldevoid
Copy link
Contributor Author

@kinnison Just wanted to ping you to make sure this hasn't fallen by the wayside.

Copy link
Contributor

@kinnison kinnison left a comment

Choose a reason for hiding this comment

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

First up, thank you for submitting a PR and contributing to rustup.

This is not a bad PR, though there are a number of points which need cleanup. The big thing is that there's a distinct lack of tests.

Could we please have some basic tests for the new command you're adding?

Thanks,

D.

README.md Show resolved Hide resolved
src/rustup-cli/rustup_mode.rs Outdated Show resolved Hide resolved
src/rustup-cli/rustup_mode.rs Outdated Show resolved Hide resolved
@ehuss
Copy link
Contributor

ehuss commented Feb 28, 2019

FWIW, I'm proposing a new approach for completions for cargo at rust-lang/cargo#6645. It may not have any impact here, but just wanted to make you aware.

@yodaldevoid
Copy link
Contributor Author

@ehuss I'll keep an eye on that discussion, and when/if it gets implemented if no one else does it I'll make sure to submit a PR moving to the new system for newer versions of cargo.

@dwijnand
Copy link
Member

dwijnand commented Mar 1, 2019

Thanks, @ehuss, I've been meaning to cross link that here.

@bors
Copy link
Contributor

bors commented Mar 15, 2019

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

ricvelozo and others added 9 commits March 16, 2019 14:47
Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
This "command" argument allows rustup to output the completion information of
more than just rustup. In this case it adds a cargo completion script.

Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
This allows the cargo script for the current default toolchain to be called,
and if the script is ever updated the user won't have to maually update their
completion script after updating Rust.

Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
This removes the duplication between the `variants` and `from_str`
implementations.
@yodaldevoid
Copy link
Contributor Author

@kinnison Sorry about the long time since the last update. As the famous quote goes, "Life... finds a way to always get in the way of projects."

I believe I have addressed all requested changes. Please let me know if there is anything else you would like modified.

Moves the error reporting from the completion function to the standard
error handling mechanism.

CompletionCommand had to be made fully public, not that this matters for
a binary target. That said, this could have been prevented by
transforming the CompletionCommand into its String form at the error
site rather than at the reporting site. It was chosen to go with this
method as stringly-typed interfaces are generally bad.
Compares two different command invocations and panics if their return
code and stdout/stderr don't match.
@kinnison
Copy link
Contributor

Thank you for making the updates, I'll endeavour to review this, likely tomorrow.

@yodaldevoid
Copy link
Contributor Author

@kinnison I hate to be a hypocrite in this regard, but I wanted to ping you about this PR as it has been some time.

@kinnison
Copy link
Contributor

@kinnison I hate to be a hypocrite in this regard, but I wanted to ping you about this PR as it has been some time.

No, that's very fair, I needed a kick up the backside it seems the past two weeks have been busy and somehow this slipped off my TODO without me noticing :(

@kinnison
Copy link
Contributor

This looks reasonable to me, I'm grateful for the tests too. I wonder if the user ought to be told about how the completions script they're given may vary with the default toolchain; but ultimately I think that's not worth blocking this for.

@kinnison kinnison merged commit ed08330 into rust-lang:master Apr 14, 2019
@yodaldevoid yodaldevoid deleted the shell-completions branch April 14, 2019 16:52
@sondr3 sondr3 mentioned this pull request Apr 23, 2019
10 tasks
fnichol added a commit to fnichol/bashrc that referenced this pull request Apr 30, 2019
References: rust-lang/rustup#1646

Signed-off-by: Fletcher Nichol <fnichol@nichol.ca>
@pickfire
Copy link
Contributor

pickfire commented Jul 9, 2019

Are there fish completions yet?

@tesuji
Copy link
Contributor

tesuji commented Jul 9, 2019

If you want to contribute, please help with rust-lang/cargo#6645 .

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.

8 participants