[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.
```
This commit is contained in:
Isabell (Issy) Long 2019-05-21 07:12:09 +01:00
parent 50138dbbe3
commit 4a5b02661a
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4
2 changed files with 12 additions and 10 deletions

View File

@ -13,6 +13,17 @@ module Homebrew
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

View File

@ -196,16 +196,7 @@ module Homebrew
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
def cask_reason(name, silent: false, show_info: false); end
require "extend/os/missing_formula"
end