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