class Yoptparse::Command
Public Class Methods
parse(argv)
click to toggle source
@param argv [Array<String>] @return [Yoptparse::Command]
# File lib/yoptparse/command.rb, line 14 def parse(argv) option_parser, result_store = generate_option_parser_and_result_store option_parser.parse(argv) new(result_store) end
to_option_parser()
click to toggle source
@return [OptionParser]
# File lib/yoptparse/command.rb, line 21 def to_option_parser generate_option_parser_and_result_store.first end
Private Class Methods
constructor_path()
click to toggle source
@return [String]
# File lib/yoptparse/command.rb, line 28 def constructor_path instance_method(:initialize).source_location.first end
generate_option_parser_and_result_store()
click to toggle source
@return [Array]
# File lib/yoptparse/command.rb, line 33 def generate_option_parser_and_result_store load_constructor_documentation result_store = {} option_parser = ::OptionParser.new option_parser.banner = banner instance_method(:initialize).parameters.map do |argument_type, argument_name| option = ::Yoptparse::Option.new( argument_name: argument_name, argument_type: argument_type, command_class: self, ) option_parser.on( option.long_option, option.type_class, option.description, ) do |value| result_store[argument_name] = value end end [option_parser, result_store] end
load_constructor_documentation()
click to toggle source
@return [void]
# File lib/yoptparse/command.rb, line 56 def load_constructor_documentation ::YARD.parse(constructor_path) end