-
Notifications
You must be signed in to change notification settings - Fork 893
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
Make rustup show
output info in a more logical order
#3225
Conversation
My gut reaction is that folk usually want the active toolchain information, so having it first or last is best; and last means they don't need to scan far for it or use head. Neither first nor last will match your concept though. Thanks for demonstrating the idea clearly though! |
Thanks for considering it! I've fixed the tests I broke, amended the commit and commit message and force pushed. Apologies to anyone who pulled the original commit. |
There's always Matt@Matts-PC /c/d/p/r/rustup (show-order)> rustup show active-toolchain
stable-x86_64-pc-windows-msvc (default)
Matt@Matts-PC /c/d/p/r/rustup (show-order)> rustup show active-toolchain -v
stable-x86_64-pc-windows-msvc (default)
rustc 1.67.1 (d5a82bbd2 2023-02-07) |
rustup show
output info in a more logical order
As an aside, would it be possible to reformat the reason the active toolchain was chosen? At the moment the floating
->
Also, there's some scope for code deduplication between |
I feel like "\nReason:" is nondescript (reason for what? it's dissociated from the phrase "active toolchain" by multiple lines by that point) and the " (inline comment)" style is better, but I don't think " (default)" is a good explanation either. |
It's a little terse, I'll admit. I think because it's right next to the other parts of the active toolchain, you can work out what it's the reason for using context from the reason message. But I would be open to:
Either way, it's certainly more descriptive than the other lines! Perhaps it should really be:
|
Hm. Why not reframe it and instead
|
What would happen if we put the reason on the same line as Active toolchain.
(or something similar). Having thought more about this I do like the idea of making targets subordinate to the toolchain. Perhaps like this:
|
Yes, that's definitely an improvement! Although I think we could do away with the blank lines after the |
@majaha would you be able to rebase this and follow up on the discussion so far? |
Okay, I've rebased the old patch. We're probably not ready to merge yet though, as we were still discussing and iterating on what we wanted to do. I'm going to have another think about what we want here. |
Okay, I've spent some more time thinking about the output format, incorporating some other's ideas, and this is what I've come up with:
I thought about putting the active reason in the header like this:
but decided against it as the
We should also change the format of
⬇
|
Indeed, breaking that into two lines might be a good idea. @majaha, it looks like we are moving in the right direction!
I still prefer using However, I'd like to add an
... and we might want to use |
@rbtcollins @djc Instead of changing to <snip>
active toolchain
----------------
name: stable-x86_64-pc-windows-msvc
compiler: rustc 1.73.0 (cc66ad468 2023-10-03)
active because: overridden by +toolchain on the command line
targets:
wasm32-unknown-unknown
x86_64-pc-windows-msvc Other than this I have no outstanding concerns at the moment. |
Sorry, do you mean that you want it to be on the same line as the header next to |
A separate line underneath, just like in my snippets above. |
Ah, gotcha. Yeah, I think you're version looks quite clean! |
This looks good to me. So can we get the code updated to match the proposed style? |
Okay, I'm working on this. Here's a thought I had: Should we always have the |
@majaha As a quick reminder, with the currently proposed style, the output should be like: $ RUSTUP_TOOLCHAIN=nightly rustup show active-toolchain
nightly-x86_64-pc-windows-msvc
active because: environment override by RUSTUP_TOOLCHAIN (From #3225 (comment)) ... with $ rustup show
Default host: x86_64-pc-windows-msvc
rustup home: C:\Users\Matt\.rustup
installed toolchains
--------------------
stable-x86_64-pc-windows-msvc (active)
nightly-x86_64-pc-windows-msvc (default)
active toolchain
----------------
name: stable-x86_64-pc-windows-msvc
compiler: rustc 1.73.0 (cc66ad468 2023-10-03)
active because: overridden by +toolchain on the command line
targets:
wasm32-unknown-unknown
x86_64-pc-windows-msvc (From #3225 (comment)) Also, (From #3225 (comment)) |
I've uploaded the new patch, which includes the changes and a bit of a refactoring:
|
@majaha this sounds great, except I'd like to request basically one commit per bullet point, which should make it a lot easier to review this. Do you think that would be feasible? |
Changes the model from "find an override to the default toolchain" to "find the active toolchain, which may be the default toolchain".
Redesigns the `OverrideCfg` type so that validity is represented in the type system, i.e. "Parse, don't validate". Probably fixes some subtle bugs when no toolchain is named in a rust-toolchain.toml, implicitly selecting the default toolchain, but the default toolchain isn't displayed as active by `rustup list toolchain` and the like. Also fixes a bug where the `RUSTUP_TOOLCHAIN` erroneously had priority over a `+toolchain` command line override.
16886db
to
8f8f4ca
Compare
This changes the format of `rustup show` to be in a more logical order, and changes the format of `rustup show active-toolchain` to match. Also, as suggested in a comment, these commands will no longer install the active toolchain if it is not already installed, as they now call `cfg.find_active_toolchain()` instead of `cfg.find_or_install_active_toolchain()`. This fixes rust-lang#1397
Update the format of `rustup toolchain list` to have a similar flavour to the new `rustup show` format.
`rustup default` will no longer error and print to stderr if there is no default toolchain configured. It will print to stdout and exit successfully instead.
Fix an issue where the documentation erroneously states that `rust-toolchain.toml` config files can't specify custom toolchain names. This language seems to be very old, ultimately inherited from the original commit that added this feature, and is no longer true: rust-lang@107d8e5#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R330
Nice, well done on merging this guys! |
I ran
rustup show
and noticed that its output is in the order:installed toolchains -> installed targets for active toolchain -> active toolchain
I thought it would make sense to put "active toolchain" before " installed targets for active toolchain" so that they in order of decreasing scope:
installed toolchains -> active toolchain -> installed targets for active toolchain
so that is what this patch does 🙂
Thoughts?
Before:
After:
Fixes #1397