brew/Library/Homebrew/cmd/options.rb

36 lines
863 B
Ruby
Raw Normal View History

2011-03-19 09:58:42 -07:00
require 'formula'
module Homebrew
2013-06-26 15:08:45 -05:00
def options
if ARGV.include? '--all'
puts_options Formula.to_a
elsif ARGV.include? '--installed'
puts_options Formula.installed
else
raise FormulaUnspecifiedError if ARGV.named.empty?
puts_options ARGV.formulae
end
2011-03-19 09:58:42 -07:00
end
2013-06-26 15:08:45 -05:00
def puts_options(formulae)
formulae.each do |f|
next if f.options.empty?
2011-03-10 21:32:10 -08:00
if ARGV.include? '--compact'
puts f.options.as_flags.sort * " "
2011-03-10 21:32:10 -08:00
else
2013-06-26 15:08:45 -05:00
puts f.name if formulae.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
f.options.sort_by(&:flag).each do |opt|
2014-08-07 00:11:14 -05:00
puts "#{opt.flag}\n\t#{opt.description}"
end
puts "--devel\n\tInstall development version #{f.devel.version}" if f.devel
puts "--HEAD\n\tInstall HEAD version" if f.head
end
end