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

when brew cat fails, suggest brew info --github #14902

Merged
merged 6 commits into from Mar 7, 2023

Conversation

g0t4
Copy link
Contributor

@g0t4 g0t4 commented Mar 6, 2023

When brew cat formula|cask fails, add suggestion to use brew info --github formula|cask instead. This gives a workaround for API users that don't have taps locally for homebrew/core and homebrew/cask.

This builds on changes from #14824 which addressed #14815

Comment on lines 56 to 57
$stderr.puts "The name may be wrong, or the tap hasn't been tapped."
$stderr.puts "Consider using `brew info --github formula|cask [...]` instead."
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$stderr.puts "The name may be wrong, or the tap hasn't been tapped."
$stderr.puts "Consider using `brew info --github formula|cask [...]` instead."
$stderr.puts "The name may be wrong, or the tap hasn't been tapped. Instead try:"
$stderr.puts " brew info --github"

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.

Looks good so far, thanks for the PR! A formatting suggestion.

@muescha
Copy link
Contributor

muescha commented Mar 6, 2023

Is it possiboe to add the cask Name - so that the suggested command is just read for copy paste?

@g0t4
Copy link
Contributor Author

g0t4 commented Mar 6, 2023 via email

@g0t4
Copy link
Contributor Author

g0t4 commented Mar 6, 2023

@MikeMcQuaid formatting change adopted
@muescha I added the formula/cask args

  brew style Library/Homebrew/**/cat*
@g0t4 g0t4 changed the title Cat mention brew info GitHub Cat mention brew info --github Mar 6, 2023
@g0t4 g0t4 changed the title Cat mention brew info --github when brew cat fails, suggest brew info --github Mar 6, 2023
@muescha
Copy link
Contributor

muescha commented Mar 6, 2023

Great. Thx :)

It is possible to check if the option --cask is given and print it also?

@@ -15,4 +15,12 @@
.and not_to_output.to_stderr
.and be_a_success
end

describe "when a source file isn't found" do
Copy link
Member

Choose a reason for hiding this comment

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

I think in this case we shouldn't add an entire integration test just for this change. They're really slow and since this is just a messaging issue I think it's fine for it to be missed by tests.

Thanks for writing it, though!

Copy link
Contributor

Choose a reason for hiding this comment

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

Good to go once this test is removed.

@MikeMcQuaid
Copy link
Member

Thanks so much for your first contribution (hopefully of many)! Without people like you submitting PRs we couldn't run this project. You rock, @g0t4!

@MikeMcQuaid MikeMcQuaid merged commit 2fe078d into Homebrew:master Mar 7, 2023
23 checks passed
@g0t4
Copy link
Contributor Author

g0t4 commented Mar 8, 2023 via email

@muescha
Copy link
Contributor

muescha commented Mar 8, 2023

Great. Thx :)

It is possible to check if the option --cask is given and print it also?

$ brew cat docker
Error: docker's source doesn't exist on disk.
The name may be wrong, or the tap hasn't been tapped. Instead try:
  brew info --github docker

$ brew cat --cask docker
Error: docker's source doesn't exist on disk.
The name may be wrong, or the tap hasn't been tapped. Instead try:
  brew info --github docker
$ brew info --github docker
Warning: Treating docker as a formula. For the cask, use homebrew/cask/docker

opened https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/docker.rb

$ brew info --github --cask docker

opened https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/docker.rb

@g0t4
Copy link
Contributor Author

g0t4 commented Mar 9, 2023

@muescha, yeah that was my fear with showing the args! darn edge cases

@g0t4
Copy link
Contributor Author

g0t4 commented Mar 9, 2023

@MikeMcQuaid hey I have another change as suggested by @muescha, should I open a new PR? it's right on top of the change you made to nuke the test, same branch in my repo. I've never reopened a merged+closed PR before, so I'm not sure if that's doable?

@muescha if you wanna give feedback on it, here it is... it was a quick hack just to test it out :)

master...g0t4:brew:cat_mention_brew_info_github

@g0t4
Copy link
Contributor Author

g0t4 commented Mar 9, 2023

@muescha oh and I just have to ask... will there be flame wars over suggesting --formula vs --formulae and --cask vs --casks ;)

@muescha
Copy link
Contributor

muescha commented Mar 9, 2023

the PR is already merged - so you have to create a new PR

@muescha
Copy link
Contributor

muescha commented Mar 9, 2023

but i see at your link there is a green button to create a new pull request

the man page says

     --formula
              Treat all named arguments as formulae.

       --cask Treat all named arguments as casks.

so there is no --formulae and no --casks

@g0t4
Copy link
Contributor Author

g0t4 commented Mar 9, 2023

@muescha looks like man pages are out of date!

$ brew cat --help

Usage: brew cat [--formula] [--cask] formula|cask [...]

Display the source of a formula or cask.

      --formula, --formulae        Treat all named arguments as formulae.
      --cask, --casks              Treat all named arguments as casks.
  -d, --debug                      Display any debugging information.
  -q, --quiet                      Make some output more quiet.
  -v, --verbose                    Make some output more verbose.
  -h, --help                       Show this message.

Completions also don't have --casks/--formulae, which IMO is a good thing to avoid wondering if the arg is different when it's just an alias!

@github-actions github-actions bot added the outdated PR was locked due to age label Apr 9, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 9, 2023
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

5 participants