Add a rustc version segment with multiple install options#314
Conversation
|
@bobthecow This is ready to review when you want, and has been rebased on laster master branch. Thanks! |
bobthecow
left a comment
There was a problem hiding this comment.
How expensive are cargo lookups? Can we default to on if rustc is present?
| case yes | ||
| cargo locate-project --message-format plain --quiet >/dev/null 2>/dev/null | ||
| and set local_rustc_version (__bobthefish_get_cargo_version (__bobthefish_pwd)) | ||
| case diff |
There was a problem hiding this comment.
This is the default behavior for most segments (e.g. ruby). Can we make two options, always and yes, and have yes do what diff currently does?
(Alternatively, if it's not to expensive to default on, it would be off/always).
There was a problem hiding this comment.
It takes 70msec to run rustc --version. I think it's too much to run with every prompt; if you had 2-3 of these it would be a third of a second and it's noticeable. But I'll defer the final decision to you.
I've done the first part.
|
|
||
| function __bobthefish_get_cargo_version -S -d 'Display the cargo version in a directory' | ||
| pushd $argv[1] | ||
| command rustc --version | cut -d ' ' -f 2 |
There was a problem hiding this comment.
Does rustc take a working directory to save us from a pushd/popd? Otherwise, we should probably add command.
There was a problem hiding this comment.
Unfortunately no. I'll add command but I'm also exploring if there's a better way to get this information.
There was a problem hiding this comment.
So I decided to rely on fish -c " ... " to create a subshell only if we need to (which should be once for the global anyway).
|
PTAL. |
|
Ping, @bobthecow |
|
@bobthecow Ping. I have additional changes that I would like to submit a PR for, but they're based on this and don't want to pollute your queue. |


This adds 4 options for rustc (if installed):
alwayswill always show the version.yeswill show the version of rustc if we can locate the Cargo.toml file (usingcargo locate-project).diffwill show the version if there's a different result than the global rustc (as ran in the root). This is useful when using.rust-toolchainfiles to enforce specific version of the toolchain, for example.