Class: Anyway::OptionParserBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/anyway/option_parser_builder.rb

Overview

Initializes the OptionParser instance using the given configuration

Class Method Summary collapse

Class Method Details

.call(options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/anyway/option_parser_builder.rb', line 9

def call(options)
  OptionParser.new do |opts|
    opts.accept(AutoCast) { AutoCast.call(_1) }

    options.each do |key, descriptor|
      opts.on(*option_parser_on_args(key, **descriptor)) do |val|
        yield [key, val]
      end
    end
  end
end