module Anyway::OptparseConfig::ClassMethods

Public Instance Methods

describe_options(**hargs) click to toggle source
# File lib/anyway/optparse_config.rb, line 20
def describe_options(**hargs)
  hargs.each do |name, desc|
    if String === desc
      option_parser_descriptors[name.to_s][:desc] = desc
    else
      option_parser_descriptors[name.to_s].merge!(desc)
    end
  end
end
extend_options(&block) click to toggle source
# File lib/anyway/optparse_config.rb, line 36
def extend_options(&block)
  option_parser_extensions << block
end
flag_options(*args) click to toggle source
# File lib/anyway/optparse_config.rb, line 30
def flag_options(*args)
  args.each do |name|
    option_parser_descriptors[name.to_s][:flag] = true
  end
end
ignore_options(*args) click to toggle source
# File lib/anyway/optparse_config.rb, line 14
def ignore_options(*args)
  args.each do |name|
    option_parser_descriptors[name.to_s][:ignore] = true
  end
end
option_parser_descriptors() click to toggle source
# File lib/anyway/optparse_config.rb, line 60
def option_parser_descriptors
  return @option_parser_descriptors if instance_variable_defined?(:@option_parser_descriptors)

  @option_parser_descriptors =
    if superclass < Anyway::Config
      superclass.option_parser_descriptors.deep_dup
    else
      Hash.new { |h, k| h[k] = {} }
    end
end
option_parser_extensions() click to toggle source
# File lib/anyway/optparse_config.rb, line 49
def option_parser_extensions
  return @option_parser_extensions if instance_variable_defined?(:@option_parser_extensions)

  @option_parser_extensions =
    if superclass < Anyway::Config
      superclass.option_parser_extensions.dup
    else
      []
    end
end
option_parser_options() click to toggle source
# File lib/anyway/optparse_config.rb, line 40
def option_parser_options
  config_attributes.each_with_object({}) do |key, result|
    descriptor = option_parser_descriptors[key.to_s]
    next if descriptor[:ignore] == true

    result[key] = descriptor
  end
end