diff options
| author | Max Howell | 2010-07-20 21:52:44 -0700 |
|---|---|---|
| committer | Adam Vandenberg | 2010-08-07 18:08:49 -0700 |
| commit | 3b106ea2059cda718b3c934bc2a071efa5098ce7 (patch) | |
| tree | ae4071fce3634559070cc235b701e993239eca85 | |
| parent | 28504229aa7a1389fa60bbfb9b987344d608e925 (diff) | |
| download | brew-3b106ea2059cda718b3c934bc2a071efa5098ce7.tar.bz2 | |
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.
| -rwxr-xr-x | bin/brew | 61 |
1 files changed, 11 insertions, 50 deletions
@@ -260,59 +260,20 @@ begin args = ARGV.options args.unshift ARGV.formulae.first.path unless ARGV.named.empty? exec "git", "log", *args - + + # For each formula given, show which other formulas depend on it. + # We only go one level up, ie. direct dependencies. when 'uses' - # For each formula given, show which other formulas depend on it. - # We only go one level up, direct dependencies. - require 'formula' - require 'utils' - - 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 - + puts *ARGV.formulae.map{ |f| Formula.all.select{ |ff| ff.deps.include? f.name }.map(&:name) }.flatten.uniq.sort + when 'deps' - require 'formula' - - ARGV.formulae.each do |f| - 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 - our_deps.sort! - puts "#{name} depends on #{our_deps.join(", ")}" - end + require 'formula_installer' + if ARGV.include?("-1") or ARGV.include?("--1") + puts *ARGV.formulae.map{ |f| f.deps or [] }.flatten.uniq.sort + else + puts *ARGV.formulae.map{ |f| FormulaInstaller.expand_deps(f).map(&:name) }.flatten.uniq.sort end - + when 'cat' Dir.chdir HOMEBREW_REPOSITORY exec "cat", ARGV.formulae.first.path, *ARGV.options |
