aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/options.rb
blob: 482f982ccb9f1b83c025f2edd6379fa6d9f33d85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'formula'
require 'cmd/outdated'

def ff
  if ARGV.include? "--all"
    Formula.all
  elsif ARGV.include? "--installed"
    # outdated brews count as installed
    outdated = Homebrew.outdated_brews.collect{ |b| b.name }
    Formula.all.select do |f|
      f.installed? or outdated.include? f.name
    end
  else
    raise FormulaUnspecifiedError if ARGV.named.empty?
    ARGV.formulae
  end
end

module Homebrew extend self
  def options
    ff.each do |f|
      next if f.build.empty?
      if ARGV.include? '--compact'
        puts f.build.collect {|k,v| "--"+k} * " "
      else
        puts f.name if ff.length > 1
        dump_options_for_formula f
        puts
      end
    end
  end

  def dump_options_for_formula f
    f.build.each do |k,v|
      puts "--"+k
      puts "\t"+v
    end
  end
end