Refactor and document Options
.
This commit is contained in:
parent
c3874580a4
commit
5540eac625
@ -239,7 +239,7 @@ module Homebrew
|
||||
|
||||
if !f.options.empty? || f.head || f.devel
|
||||
ohai "Options"
|
||||
Homebrew.dump_options_for_formula f
|
||||
Options.dump_for_formula f
|
||||
end
|
||||
|
||||
caveats = Caveats.new(f)
|
||||
|
@ -80,7 +80,7 @@ module Homebrew
|
||||
puts f.options.as_flags.sort * " "
|
||||
else
|
||||
puts f.full_name if formulae.length > 1
|
||||
dump_options_for_formula f
|
||||
Options.dump_for_formula f
|
||||
puts
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# A formula option.
|
||||
#
|
||||
# @api private
|
||||
class Option
|
||||
attr_reader :name, :description, :flag
|
||||
|
||||
@ -33,6 +36,9 @@ class Option
|
||||
end
|
||||
end
|
||||
|
||||
# A deprecated formula option.
|
||||
#
|
||||
# @api private
|
||||
class DeprecatedOption
|
||||
attr_reader :old, :current
|
||||
|
||||
@ -55,6 +61,9 @@ class DeprecatedOption
|
||||
alias eql? ==
|
||||
end
|
||||
|
||||
# A collection of formula options.
|
||||
#
|
||||
# @api private
|
||||
class Options
|
||||
include Enumerable
|
||||
|
||||
@ -112,12 +121,8 @@ class Options
|
||||
def inspect
|
||||
"#<#{self.class.name}: #{to_a.inspect}>"
|
||||
end
|
||||
end
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
|
||||
def dump_options_for_formula(f)
|
||||
def self.dump_for_formula(f)
|
||||
f.options.sort_by(&:flag).each do |opt|
|
||||
puts "#{opt.flag}\n\t#{opt.description}"
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user