Module: Inform::Options
- Included in:
- App
- Defined in:
- lib/runtime/options.rb
Overview
The Options module
Defined Under Namespace
Classes: ArgumentsParser
Instance Method Summary collapse
-
#demand(options, arg, positional = false) ⇒ Object
class ArgumentsParser.
- #parse_arguments(args = ARGV, _file_path = ARGF) ⇒ Object
Instance Method Details
#demand(options, arg, positional = false) ⇒ Object
class ArgumentsParser
83 84 85 86 87 |
# File 'lib/runtime/options.rb', line 83 def demand(, arg, positional = false) return [arg] unless [arg].nil? required_arg = positional ? "<#{arg}>" : "--#{arg.to_s.gsub(/_/, '-')}" raise UserError, "Required argument: #{required_arg}" end |
#parse_arguments(args = ARGV, _file_path = ARGF) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/runtime/options.rb', line 89 def parse_arguments(args = ARGV, _file_path = ARGF) arguments_parser = ArgumentsParser.new(args) demand(arguments_parser., :game_path) arguments_parser. rescue OptionParser::InvalidArgument, OptionParser::InvalidOption, OptionParser::MissingArgument, OptionParser::NeedlessArgument => e puts e. puts arguments_parser.parser exit rescue OptionParser::AmbiguousOption => e abort e. end |