brew/Library/Homebrew/cmd/options.rb
Misty De Meo d1c0d4c879 Fix normalization of old- and new-style options
When combining the set of old-style and new-style options, make sure
that the leading "--" is stripped.

Fixes displaying options in `brew options`, and the exotic case of
declaring options using the old syntax and then checking them with
`build.include?`
2012-08-11 16:54:03 -05:00

40 lines
809 B
Ruby

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