diff --git a/Library/Homebrew/cmd/options.rb b/Library/Homebrew/cmd/options.rb index 9a54d9c37b..d113e6ef38 100644 --- a/Library/Homebrew/cmd/options.rb +++ b/Library/Homebrew/cmd/options.rb @@ -10,17 +10,37 @@ require "formula" require "options" +require "cli_parser" module Homebrew module_function + def options_args + Homebrew::CLI::Parser.new do + usage_banner <<~EOS + `options` [] + + Display install options specific to + 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 + end + end + def options - if ARGV.include? "--all" + options_args.parse + + if args.all? puts_options Formula.to_a.sort - elsif ARGV.include? "--installed" + elsif args.installed? puts_options Formula.installed.sort else - raise FormulaUnspecifiedError if ARGV.named.empty? + raise FormulaUnspecifiedError if args.remaining.empty? puts_options ARGV.formulae end @@ -30,7 +50,7 @@ module Homebrew formulae.each do |f| next if f.options.empty? - if ARGV.include? "--compact" + if args.compact? puts f.options.as_flags.sort * " " else puts f.full_name if formulae.length > 1