Skip to content

Conversation

@bakkot
Copy link
Contributor

@bakkot bakkot commented Aug 27, 2021

Fixes #1016.

I didn't document this anywhere, since it seems like something you don't need to know about until you've already tripped over it.

Copy link
Contributor

@charlespierce charlespierce 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 this! A couple of small tweaks but looks like a great usability improvement!

Copy link
Contributor

@charlespierce charlespierce left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

name: name.as_ref().to_string(),
version: maybe_version.as_ref().to_string(),
match (args.next(), args.next(), args.next()) {
(Some(maybe_version), None, None) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you'll take a random question while I'm here (I'm new to rust) - would it be more idiomatic to have

(Some(maybe_version), None, None) if is_version_like(maybe_version.as_ref()) => {

rather than

(Some(maybe_version), None, None) => {
  if is_version_like(maybe_version.as_ref()) {

?

(In the case that nothing else is going to match anyway so that they have the same semantics.)

Also, if it is, would it be more idiomatic to have the match itself provide the return value, i.e. get rid of the returns and make the _ branch be _ => Ok(())?

Happy to push up a commit with that change if it would be an improvement.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a great question! In my experience, it usually comes down to readability: I find the <pattern> if <predicate> => can very easily get verbose enough that it's more difficult to read than <pattern> => if <predicate>. For your second question, yes if you use the predicate matching it would be more idiomatic to have the match provide the value directly.

In this case, I would probably lean that doing predicate matching is slightly cleaner, but it's not anything that would block a PR. So if you'd like to (and have the time to) add another commit, that would be a bonus! But if not no worries and I'm happy to merge as is 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the response! Pushed up a commit doing that.

@charlespierce
Copy link
Contributor

Awesome, thanks!

@charlespierce charlespierce merged commit 98dfa2c into volta-cli:main Aug 28, 2021
@bakkot bakkot deleted the install-version-number branch August 28, 2021 20:02
@bakkot
Copy link
Contributor Author

bakkot commented Sep 2, 2021

@charlespierce Any chance of cutting a release with this change?

@charlespierce
Copy link
Contributor

@bakkot Done! Released as part of 1.0.5!

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.

warn for or forbid volta install 10

2 participants