internetee-registry/lib/rake_option_parser_boilerplate.rb
2021-10-07 16:13:48 +05:00

14 lines
359 B
Ruby

module RakeOptionParserBoilerplate
module_function
def process_args(options:, banner:, hash: {})
o = OptionParser.new
o.banner = banner
hash.each do |command_line_argument, setup_value|
o.on(*setup_value) { |result| options[command_line_argument] = result }
end
args = o.order!(ARGV) {}
o.parse!(args)
options
end
end