2015-08-03 13:09:07 +01:00
|
|
|
require "formula"
|
2015-12-27 19:12:27 +01:00
|
|
|
require "options"
|
2019-04-17 18:25:08 +09:00
|
|
|
require "cli/parser"
|
2011-03-19 09:58:42 -07:00
|
|
|
|
2014-06-18 22:41:47 -05:00
|
|
|
module Homebrew
|
2016-09-26 01:44:51 +02:00
|
|
|
module_function
|
|
|
|
|
2018-11-07 21:59:04 +05:30
|
|
|
def options_args
|
|
|
|
Homebrew::CLI::Parser.new do
|
|
|
|
usage_banner <<~EOS
|
2019-01-30 21:32:35 +00:00
|
|
|
`options` [<options>] <formula>
|
2018-11-07 21:59:04 +05:30
|
|
|
|
2019-01-30 21:32:35 +00:00
|
|
|
Display install options specific to <formula>
|
2018-11-07 21:59:04 +05:30
|
|
|
EOS
|
|
|
|
switch "--compact",
|
|
|
|
description: "Show all options on a single line separated by spaces."
|
|
|
|
switch "--all",
|
|
|
|
description: "Show options for all formulae."
|
|
|
|
switch "--installed",
|
|
|
|
description: "Show options for all installed formulae."
|
|
|
|
switch :debug
|
2019-01-29 19:39:41 +00:00
|
|
|
conflicts "--all", "--installed"
|
2018-11-07 21:59:04 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-26 15:08:45 -05:00
|
|
|
def options
|
2018-11-07 21:59:04 +05:30
|
|
|
options_args.parse
|
|
|
|
|
|
|
|
if args.all?
|
2017-10-14 06:25:31 +01:00
|
|
|
puts_options Formula.to_a.sort
|
2018-11-07 21:59:04 +05:30
|
|
|
elsif args.installed?
|
2017-10-14 06:25:31 +01:00
|
|
|
puts_options Formula.installed.sort
|
2013-06-26 15:08:45 -05:00
|
|
|
else
|
2018-11-07 21:59:04 +05:30
|
|
|
raise FormulaUnspecifiedError if args.remaining.empty?
|
2018-09-17 02:45:00 +02:00
|
|
|
|
2013-06-26 15:08:45 -05:00
|
|
|
puts_options ARGV.formulae
|
2011-11-22 19:28:05 -06:00
|
|
|
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|
|
2014-08-10 21:45:24 -05:00
|
|
|
next if f.options.empty?
|
2018-09-17 02:45:00 +02:00
|
|
|
|
2018-11-07 21:59:04 +05:30
|
|
|
if args.compact?
|
2014-08-10 21:45:24 -05:00
|
|
|
puts f.options.as_flags.sort * " "
|
2011-03-10 21:32:10 -08:00
|
|
|
else
|
2015-05-27 21:08:24 +08:00
|
|
|
puts f.full_name if formulae.length > 1
|
2012-08-04 15:40:36 -04:00
|
|
|
dump_options_for_formula f
|
2011-03-10 21:32:10 -08:00
|
|
|
puts
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-08-04 15:40:36 -04:00
|
|
|
end
|