-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
always reject uninstallable formulae
- Loading branch information
Showing
1 changed file
with
9 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
# | ||
# | ||
|
||
# brew | ||
require "formula" | ||
require "extend/ARGV.rb" | ||
|
||
TAP_RE = %r(^.+?/[^/]+) | ||
|
@@ -21,16 +21,16 @@ def matches(cmd) | |
Utils.popen_read("grep", cmd, LIST_PATH).chomp.split(/\n/) | ||
end | ||
|
||
def reject_formula?(name) | ||
f = Formula[name] rescue nil | ||
f.nil? || f.installed? || f.requirements.any? { |r| r.required? && !r.satisfied? } | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bfontaine
Author
Contributor
|
||
end | ||
|
||
# Print a small text explaining how to get 'cmd' by installing 'formula'. Note | ||
# that it'll still suggest to install the formula if it's already installed but | ||
# unlinked. | ||
def explain_formula_install(cmd, formula) | ||
require "formula" | ||
f = Formula[formula] rescue nil | ||
unless f.nil? | ||
return if f.installed? | ||
return if f.requirements.any? { |r| r.required? && !r.satisfied? } | ||
end | ||
return if reject_formula? formula | ||
puts <<-EOS | ||
The program '#{cmd}' is currently not installed. You can install it by typing: | ||
brew install #{formula} | ||
|
@@ -40,6 +40,8 @@ def explain_formula_install(cmd, formula) | |
# Print a small text explaining how to get 'cmd' by installing one of the given | ||
# formulae. | ||
def explain_formulae_install(cmd, formulae) | ||
formulae.reject! { |f| reject_formula? f } | ||
return if formulae.empty? | ||
return explain_formula_install(cmd, formulae.first) if formulae.size == 1 | ||
puts <<-EOS.undent | ||
The program '#{cmd}' can be found in the following formulae: | ||
|
Unsatisfied requirement doesn't mean uninstallable, right?