class IDL::OptionList::Option::Configurator

Public Class Methods

new(opt) click to toggle source
# File lib/ridl/optparse_ext.rb, line 240
def initialize(opt)
  @option = opt
end

Public Instance Methods

define_group(id, options = {}, &block) click to toggle source
# File lib/ridl/optparse_ext.rb, line 244
def define_group(id, options = {}, &block)
  id = id.to_sym
  raise "option group [#{id}] already exists" if @option.groups.has_key?(id)

  @option.groups[id] = Group.new(id, options)
  block.call(Group::Configurator.new(@option.groups[id])) if block_given?
end
Also aliased as: for_group
define_param(id, options = {}, &block) click to toggle source
# File lib/ridl/optparse_ext.rb, line 283
def define_param(id, options = {}, &block)
  modify_group :default, {test: true} do |grpcfg|
    grpcfg.define_param_set("#{id}_set", options) do |pscfg|
      pscfg.with(id)
      pscfg.on_exec(&block)
    end
  end
end
Also aliased as: for_param
define_param_set(id, options = {}, &block) click to toggle source
# File lib/ridl/optparse_ext.rb, line 267
def define_param_set(id, options = {}, &block)
  modify_group :default, {test: true} do |grpcfg|
    grpcfg.define_param_set(id, options, &block)
  end
end
Also aliased as: for_set, for_params
for_group(id, options = {}, &block)
Alias for: define_group
for_param(id, options = {}, &block)
Alias for: define_param
for_params(id, options = {}, &block)
Alias for: define_param_set
for_set(id, options = {}, &block)
Alias for: define_param_set
modify_group(id, options = {}, &block) click to toggle source
# File lib/ridl/optparse_ext.rb, line 253
def modify_group(id, options = {}, &block)
  id = id.to_sym
  parms = options[:params] ? options.delete(:params) : options.delete(:param)
  @option.groups[id] ||= Group.new(id, options)
  grpcfg = Group::Configurator.new(@option.groups[id])
  grpcfg.modify_param_set(id, params: parms) if parms
  block.call(grpcfg) if block_given?
end
Also aliased as: with_group
on_exec(options = {}, &block) click to toggle source
# File lib/ridl/optparse_ext.rb, line 275
def on_exec(options = {}, &block)
  modify_group :default, {test: true} do |grpcfg|
    grpcfg.modify_param_set(:default, options.merge({all_params: true})) do |pscfg|
      pscfg.on_exec(&block)
    end
  end
end
undefine_group(id) click to toggle source
# File lib/ridl/optparse_ext.rb, line 263
def undefine_group(id)
  @option.groups.delete(id.to_sym)
end
with_group(id, options = {}, &block)
Alias for: modify_group
without_param(id) click to toggle source
# File lib/ridl/optparse_ext.rb, line 293
def without_param(id)
  if @option.groups.has_key?(:default)
    modify_group :default do |grpcfg|
      grpcfg.without_set("#{id}_set")
    end
  end
end
Also aliased as: without_set, without_params
without_params(id)
Alias for: without_param
without_set(id)
Alias for: without_param