2010-09-11 20:22:54 +01:00
|
|
|
require 'formula'
|
|
|
|
|
|
|
|
# `brew uses foo bar` now returns formula that use both foo and bar
|
|
|
|
# Rationale: If you want the union just run the command twice and
|
|
|
|
# concatenate the results.
|
|
|
|
# The intersection is harder to achieve with shell tools.
|
|
|
|
|
|
|
|
module Homebrew extend self
|
|
|
|
def uses
|
2012-02-04 00:01:29 -06:00
|
|
|
raise FormulaUnspecifiedError if ARGV.named.empty?
|
2012-01-29 21:42:09 -08:00
|
|
|
|
2012-08-21 11:39:45 -04:00
|
|
|
uses = Formula.select do |f|
|
2010-09-11 20:22:54 +01:00
|
|
|
ARGV.formulae.all? do |ff|
|
2012-03-16 22:00:59 -07:00
|
|
|
if ARGV.flag? '--recursive'
|
|
|
|
f.recursive_deps.include? ff
|
|
|
|
else
|
|
|
|
f.deps.include? ff.name
|
|
|
|
end
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
end
|
2012-01-29 21:42:09 -08:00
|
|
|
|
2010-09-11 20:22:54 +01:00
|
|
|
if ARGV.include? "--installed"
|
|
|
|
uses = uses.select do |f|
|
|
|
|
keg = HOMEBREW_CELLAR/f
|
|
|
|
keg.directory? and not keg.subdirs.empty?
|
|
|
|
end
|
|
|
|
end
|
2012-01-29 21:42:09 -08:00
|
|
|
|
2011-11-28 23:29:29 -08:00
|
|
|
puts_columns uses.map{|f| f.to_s}.sort
|
2010-09-11 20:22:54 +01:00
|
|
|
end
|
|
|
|
end
|