Module: RakeCommander::Options::Error::ClassMethods
- Defined in:
- lib/rake-commander/options/error.rb
Instance Method Summary collapse
-
#parse_options(argv = ARGV, results: {}, leftovers: [], &block) ⇒ Object
Re-open method to add all the error handling.
Instance Method Details
#parse_options(argv = ARGV, results: {}, leftovers: [], &block) ⇒ Object
Re-open method to add all the error handling.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rake-commander/options/error.rb', line 23 def (argv = ARGV, results: {}, leftovers: [], &block) with_error_handling(argv, results, leftovers) do super.tap do |_| check_on_leftovers(leftovers) check_required_presence(results) end rescue OptionParser::InvalidOption => e eklass = RakeCommander::Options::Error::InvalidOption raise eklass.new(e, from: self), nil, cause: nil rescue OptionParser::MissingArgument => e eklass = RakeCommander::Options::Error::MissingArgument opt = error_option(e, eklass) msg = e. msg = "missing required argument: #{opt.name_hyphen} (#{opt.short_hyphen})" if opt raise eklass.new(from: self, option: opt), msg, cause: nil rescue OptionParser::InvalidArgument => e eklass = RakeCommander::Options::Error::InvalidArgument opt = error_option(e, eklass) raise eklass.new(e, from: self, option: opt), nil, cause: nil unless opt&.argument_required? eklass = RakeCommander::Options::Error::MissingArgument msg = "missing required argument in option: #{opt.name_hyphen} (#{opt.short_hyphen})" raise eklass.new(from: self, option: opt), msg, cause: nil end end |