brew/Library/Homebrew/extend/os/mac/missing_formula.rb
Isabell (Issy) Long 4a5b02661a
[Linux] Don't prompt users to brew cask install
- I tried to install `keybase`, thinking I'd get the CLI. On Linux,
  casks don't work, yet I was still prompted to `brew cask install
  keybase`. When I tried that (just to make sure), I got the "casks are
  only supported on MacOS" error.
- This change makes it so we don't prompt people to install casks if
  they're on platforms other than MacOS.

Before:

```
╭─issyl0@grus /home/linuxbrew/.linuxbrew/Homebrew ‹master›
╰─ $ brew install keybase
Error: No available formula with the name "keybase"
Found a cask named "keybase" instead.
```

After:

```
Error: No available formula with the name "keybase"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
  git -C "$(brew --repo homebrew/core)" fetch --unshallow

Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
```
2019-05-25 15:44:46 +01:00

30 lines
693 B
Ruby

# frozen_string_literal: true
module Homebrew
module MissingFormula
class << self
def blacklisted_reason(name)
case name.downcase
when "xcode"
<<~EOS
Xcode can be installed from the App Store.
EOS
else
generic_blacklisted_reason(name)
end
end
def cask_reason(name, silent: false, show_info: false)
return if silent
cask = Cask::CaskLoader.load(name)
reason = +"Found a cask named \"#{name}\" instead.\n"
reason << Cask::Cmd::Info.get_info(cask) if show_info
reason.freeze
rescue Cask::CaskUnavailableError
nil
end
end
end
end