Answers for "rake pass multiple arguments to task"

0

rake pass multiple arguments to task

require 'optparse'

task :add do

  options = {}
  OptionParser.new do |opts|
    opts.banner = "Usage: rake add [options]"
    opts.on("-o", "--one ARG", Integer) { |num1| options[:num1] = num1 }
    opts.on("-t", "--two ARG", Integer) { |num2| options[:num2] = num2 }
  end.parse!

  puts options[:num1].to_i + options[:num2].to_i
  exit

end
Posted by: Guest on March-11-2020

Code answers related to "TypeScript"

Browse Popular Code Answers by Language