mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
uninstall: clean up warnings
This commit is contained in:
parent
14099ffaf3
commit
c77040b346
@ -87,36 +87,64 @@ module Homebrew
|
|||||||
return false unless result = Keg.find_some_installed_dependents(kegs)
|
return false unless result = Keg.find_some_installed_dependents(kegs)
|
||||||
|
|
||||||
if ARGV.homebrew_developer?
|
if ARGV.homebrew_developer?
|
||||||
dependents_output_for_developers(*result)
|
DeveloperDependentsMessage.new(*result).output
|
||||||
else
|
else
|
||||||
dependents_output_for_nondevelopers(*result)
|
NondeveloperDependentsMessage.new(*result).output
|
||||||
end
|
end
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def dependents_output_for_developers(requireds, dependents)
|
class DependentsMessage
|
||||||
msg = requireds.join(", ")
|
attr :reqs, :deps
|
||||||
msg << (requireds.count == 1 ? " is" : " are")
|
|
||||||
msg << " required by #{dependents.join(", ")}, which "
|
def initialize(requireds, dependents)
|
||||||
msg << (dependents.count == 1 ? "is" : "are")
|
@reqs = requireds
|
||||||
msg << " currently installed."
|
@deps = dependents
|
||||||
msg << "\nYou can silence this warning with "
|
end
|
||||||
msg << "`brew uninstall --ignore-dependencies "
|
|
||||||
msg << "#{requireds.map(&:name).join(" ")}`."
|
protected
|
||||||
opoo msg
|
|
||||||
|
def is(items)
|
||||||
|
items.count == 1 ? "is" : "are"
|
||||||
|
end
|
||||||
|
|
||||||
|
def it(items)
|
||||||
|
items.count == 1 ? "it" : "they"
|
||||||
|
end
|
||||||
|
|
||||||
|
def list(items)
|
||||||
|
items.join(", ")
|
||||||
|
end
|
||||||
|
|
||||||
|
def sample_command
|
||||||
|
"brew uninstall --ignore-dependencies #{list reqs.map(&:name)}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_required_by_deps
|
||||||
|
"#{is reqs} required by #{list deps}, which #{is deps} currently installed"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def dependents_output_for_nondevelopers(requireds, dependents)
|
class DeveloperDependentsMessage < DependentsMessage
|
||||||
msg = "Refusing to uninstall #{requireds.join(", ")} because "
|
def output
|
||||||
msg << (requireds.count == 1 ? "it is" : "they are")
|
opoo <<-EOS.undent
|
||||||
msg << " required by #{dependents.join(", ")}, which "
|
#{list reqs} #{is_required_by_deps}.
|
||||||
msg << (dependents.count == 1 ? "is" : "are")
|
You can silence this warning with:
|
||||||
msg << " currently installed."
|
#{sample_command}
|
||||||
msg << "\nYou can override this and force removal with "
|
EOS
|
||||||
msg << "`brew uninstall --ignore-dependencies "
|
end
|
||||||
msg << "#{requireds.map(&:name).join(" ")}`."
|
end
|
||||||
ofail msg
|
|
||||||
|
class NondeveloperDependentsMessage < DependentsMessage
|
||||||
|
def output
|
||||||
|
ofail <<-EOS.undent
|
||||||
|
Refusing to uninstall #{list reqs}
|
||||||
|
because #{it reqs} #{is_required_by_deps}.
|
||||||
|
You can override this and force removal with:
|
||||||
|
#{sample_command}
|
||||||
|
EOS
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def rm_pin(rack)
|
def rm_pin(rack)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user