class Benry::Cmdopt::Facade

Public Class Methods

new() click to toggle source
# File lib/benry/cmdopt.rb, line 107
def initialize
  @schema = SCHEMA_CLASS.new
end

Public Instance Methods

add(key, optdef, help, type: nil, pattern: nil, enum: nil, &callback) click to toggle source
# File lib/benry/cmdopt.rb, line 111
def add(key, optdef, help, type: nil, pattern: nil, enum: nil, &callback)
  #; [!vmb3r] defines command option.
  @schema.add(key, optdef, help, type: type, pattern: pattern, enum: enum, &callback)
  #; [!tu4k3] returns self.
  self
end
each_option_help(&block) click to toggle source
# File lib/benry/cmdopt.rb, line 123
def each_option_help(&block)
  #; [!bw9qx] yields each option definition string and help message.
  @schema.each_option_help(&block)
  self
end
option_help(width_or_format=nil, all: false) click to toggle source
# File lib/benry/cmdopt.rb, line 118
def option_help(width_or_format=nil, all: false)
  #; [!dm4p8] returns option help message.
  return @schema.option_help(width_or_format, all: all)
end
parse(argv, &error_handler) click to toggle source
# File lib/benry/cmdopt.rb, line 129
def parse(argv, &error_handler)
  #; [!7gc2m] parses command options.
  #; [!no4xu] returns option values as dict.
  #; [!areof] handles only OptionError when block given.
  #; [!peuva] returns nil when OptionError handled.
  parser = PARSER_CLASS.new(@schema)
  return parser.parse(argv, &error_handler)
end