Significantly simpler brew uses and brew deps

Partly simpler because the output is less pretty. But I think the output is
now more useful for other tools. And comma separated lists aren't particularly
human-readable IMO either.
This commit is contained in:
Max Howell 2010-07-20 21:52:44 -07:00 committed by Adam Vandenberg
parent 28504229aa
commit 3b106ea205

View File

@ -261,56 +261,17 @@ begin
args.unshift ARGV.formulae.first.path unless ARGV.named.empty? args.unshift ARGV.formulae.first.path unless ARGV.named.empty?
exec "git", "log", *args exec "git", "log", *args
when 'uses'
# For each formula given, show which other formulas depend on it. # For each formula given, show which other formulas depend on it.
# We only go one level up, direct dependencies. # We only go one level up, ie. direct dependencies.
require 'formula' when 'uses'
require 'utils' puts *ARGV.formulae.map{ |f| Formula.all.select{ |ff| ff.deps.include? f.name }.map(&:name) }.flatten.uniq.sort
deps = Formula.get_used_by
ARGV.formulae.each do |f|
name = f.name
our_deps = deps[name]
if our_deps == nil
puts "#{name} is not a dependency."
else
puts "#{name} is a dependency for #{our_deps.join(', ')}."
end
end
when 'deps' when 'deps'
require 'formula' require 'formula_installer'
if ARGV.include?("-1") or ARGV.include?("--1")
ARGV.formulae.each do |f| puts *ARGV.formulae.map{ |f| f.deps or [] }.flatten.uniq.sort
name = f.name
our_deps = []
checked = {}
to_check = [name]
stop_early = false
until to_check.empty? or stop_early
stop_early = ARGV.include?("-1") or ARGV.include?("--1")
item = to_check.pop
checked[item] = true
formula = Formulary.read item
next if formula == nil || formula.deps == nil || formula.deps.empty?
our_deps.push(*formula.deps)
to_check.push(*formula.deps.select{|g| !checked[g]})
end
our_deps.uniq!
if our_deps.empty?
puts "#{name} has no dependencies."
else else
our_deps.sort! puts *ARGV.formulae.map{ |f| FormulaInstaller.expand_deps(f).map(&:name) }.flatten.uniq.sort
puts "#{name} depends on #{our_deps.join(", ")}"
end
end end
when 'cat' when 'cat'