OptionParser, требующий подпараметров

Я пытаюсь выяснить, как определить подпараметры для одного из моих параметров. Это то, что у меня не работает:

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

0 ответов

Другие вопросы по тегам