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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve user ergonomics of brew link --overwrite help #16645

Merged
merged 1 commit into from Feb 12, 2024

Conversation

jasonkarns
Copy link
Contributor

@jasonkarns jasonkarns commented Feb 12, 2024

This PR makes the two-step: link --overwrite --dry-run followed by link --overwrite easier/faster for users. (Easy to leverage shell history to re-run the command without the --dry-run flag.)

Background

When a Keg is unlinked, brew-link gives a very helpful message for how to proceed: add the --overwrite flag.

For safety, it also recommends running in --dry-run mode first to see what would be deleted.

So a user's common flow would be:

  1. run brew link foo
  2. get error message with guidance
  3. run brew link --overwrite --dry-run foo
  4. inspect output
  5. run brew link --overwrite foo

In this flow, steps 3-5 are likely very common to run back-to-back. Common enough that a user may use their shell history (up arrow) to re-populate their prompt with step 3's command, delete the --dry-run flag, and re-run.

The --dry-run flag needs to be removed from the command, of course. If it had been at the end of the command, it would make the subsequent modification easier.

Instead of "up arrow, left-arrow a bunch, then backspace over --dry-run, hopefully not backspacing over the formula name", it would be easier for the user if the dry-run flag were already at the end of the command. Then the user can "up arrow, backspace a few times and hit enter".

What's more, if the last arg were --dry-run, a more advanced bash user could even use !:- to re-run the link command with all-but-the-last-arg.

This change is admittedly quite trivial, and unlikely to heavily impact anyone's life. However, I find myself running these commands often enough in quick succession that it would be a nice improvement to make the "re-run for reals" step easier. (for users, like myself, that start by copy/pasting the command from brew's helpful message)

Additional

There is one existing reference to the string "link --overwrite --dry-run" in the "Common Issues docs.

If it's helpful to have that sample output updated to match, I'd be happy to do so.


  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example. This doesn't seem worth a test?
  • Have you successfully run brew style with your changes locally? this errored while installing gems 馃槵
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

When a Keg is unlinked, brew-link gives a helpful message for how to proceed: adding the `--overwrite` flag.

For safety, it also recommends running in `--dry-run` mode first to see what would be deleted.

So a user's common flow would be:

1. run `brew link foo`
2. get error message with guidance
3. run `brew link --overwrite --dry-run foo`
4. inspect
5. run `brew link --overwrite foo`

In this flow, steps 3-5 are likely very common. Common enough that a user may use their shell history to re-populate their prompt with step 3's command, delete the `--dry-run` flag, and re-run. (The end goal, of course, is to link `foo`.)

The `--dry-run` flag needs to be removed from the command, of course. If it had been at the _end_ of the command, it would make the subsequent  modification easier.

Instead of "up arrow, left-arrow a bunch, then backspace over --dry-run, hopefully not backspacing over the formula name", it would be easier for the user if the dry-run flag were already at the end of the command. Then the user can "up arrow, backspace a few times and hit enter".

What's more, if the last arg were `--dry-run`, a more advanced bash user could even use `!:-` to re-run the link command with all-but-the-last-arg.
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Seems fine, thanks @jasonkarns!

@MikeMcQuaid MikeMcQuaid merged commit eb7338a into Homebrew:master Feb 12, 2024
24 checks passed
@jasonkarns jasonkarns deleted the patch-1 branch February 12, 2024 16:13
@github-actions github-actions bot added the outdated PR was locked due to age label Mar 14, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants