brew/Library/Homebrew/cmd/options.rb

40 lines
834 B
Ruby
Raw Normal View History

2011-03-19 09:58:42 -07:00
require 'formula'
require 'cmd/outdated'
2011-03-19 09:58:42 -07:00
def ff
if ARGV.include? "--all"
Formula.to_a
elsif ARGV.include? "--installed"
# outdated brews count as installed
outdated = Homebrew.outdated_brews.collect{ |b| b.name }
Formula.select do |f|
f.installed? or outdated.include? f.name
end
2011-03-19 09:58:42 -07:00
else
raise FormulaUnspecifiedError if ARGV.named.empty?
2011-03-19 09:58:42 -07:00
ARGV.formulae
end
end
2011-03-10 21:32:10 -08:00
module Homebrew extend self
def options
2011-03-19 09:58:42 -07:00
ff.each do |f|
next if f.build.empty?
2011-03-10 21:32:10 -08:00
if ARGV.include? '--compact'
2013-01-14 15:07:31 -06:00
puts f.build.as_flags.sort * " "
2011-03-10 21:32:10 -08:00
else
puts f.name if ff.length > 1
dump_options_for_formula f
2011-03-10 21:32:10 -08:00
puts
end
end
end
def dump_options_for_formula f
2013-01-14 15:07:31 -06:00
f.build.sort_by(&:flag).each do |opt|
puts opt.flag
puts "\t"+opt.description
end
end
end