Project

General

Profile

Bug #14728

Updated by nobu (Nobuyoshi Nakada) almost 2 years ago

`test.rb` 

 ~~~ ruby 
 require 'optparse' 

 options = {} 
 OptionParser.new do |opts| 
   opts.banner = "Usage: test.rb [options]" 

   opts.on("--verbose", "Run verbosely") do |v| 
     options[:verbose] = v 
   end 
   opts.on("--custom MANDATORY", "custom") do |x| 
     options[:custom] = x 
   end 
 end.parse! 

 p options 
 ~~~ 

 If I run the above script as follows below is output:  

 ``` 
  
 $ ruby test.rb --custom --verbose 
 {:custom=>"--verbose"} 
 ``` 

 This is not the expected behaviour as `--verbose` should not be set as the option value.

Back