1

我试图弄清楚如何为我的一个参数定义子参数。这就是我所拥有的不起作用:

require 'optparse'

options = {}
OptionParser.new do |parser|
  parser.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script") do |lib|
    parser.make_switch(["-p"], '--pop THING') do |o|
         puts "You required #{o}!"
    end
 end
 parser.on("-f", '--file FILE', 'File to be processed') do |file|
    puts "This is the file: #{file}"
 end
end.parse!

我想做:

 ruby myapp -r Library -p thing #<--required params

或者

 ruby myapp -f
4

0 回答 0