forked from Homebrew/brew
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
missing_formula.rb
69 lines (59 loc) 路 1.74 KB
/
missing_formula.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# frozen_string_literal: true
require "cask/cmd/abstract_command"
require "cask/cmd/info"
require "cask/cask_loader"
require "cask/caskroom"
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
when "tex", "tex-live", "texlive", "mactex", "latex"
<<~EOS
There are three versions of MacTeX.
Full installation:
brew cask install mactex
Full installation without bundled applications:
brew cask install mactex-no-gui
Minimal installation:
brew cask install basictex
EOS
else
generic_blacklisted_reason(name)
end
end
def cask_reason(name, silent: false, show_info: false)
return if silent
suggest_command(name, show_info ? "info" : "install")
end
def suggest_command(name, command)
suggestion = <<~EOS
Found a cask named "#{name}" instead. Try
brew cask #{command} #{name}
EOS
case command
when "install"
Cask::CaskLoader.load(name)
when "uninstall"
cask = Cask::Caskroom.casks.find { |installed_cask| installed_cask.to_s == name }
raise Cask::CaskUnavailableError, name if cask.nil?
when "info"
cask = Cask::CaskLoader.load(name)
suggestion = <<~EOS
Found a cask named "#{name}" instead.
#{Cask::Cmd::Info.get_info(cask)}
EOS
else
return
end
suggestion
rescue Cask::CaskUnavailableError
nil
end
end
end
end