Add argument-supported rake task boilerplate

This commit is contained in:
Alex Sherman 2021-06-30 17:11:09 +05:00
parent 550c5abd6c
commit e110924968
2 changed files with 39 additions and 1 deletions

View file

@ -0,0 +1,14 @@
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