diff options
| author | Max Howell | 2010-07-20 21:52:44 -0700 | 
|---|---|---|
| committer | Adam Vandenberg | 2010-08-07 18:08:49 -0700 | 
| commit | c6ce36300a90c72813596b76c7cebed2d9370e39 (patch) | |
| tree | 41c13830bb7e3bcf52bfc5b084e8b13cd446a5a2 /bin | |
| parent | 12e1baf8c37141dc0d4ab7431873838bb317d40d (diff) | |
| download | homebrew-c6ce36300a90c72813596b76c7cebed2d9370e39.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.
Diffstat (limited to 'bin')
| -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  | 
