mirror of
https://github.com/internetee/registry.git
synced 2025-06-11 23:24:48 +02:00
Add argument-supported rake task boilerplate
This commit is contained in:
parent
550c5abd6c
commit
e110924968
2 changed files with 39 additions and 1 deletions
14
lib/rake_option_parser_boilerplate.rb
Normal file
14
lib/rake_option_parser_boilerplate.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue