Actions
Bug #14728
closedOptionParser takes other options as argument values
Bug #14728:
OptionParser takes other options as argument values
Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
Description
test.rb
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:
This is not the expected behaviour as --verbose should not be set as the option value.
Updated by xz0r (xz0r xz0r) over 8 years ago
- Description updated (diff)
Updated by nobu (Nobuyoshi Nakada) over 8 years ago
- Description updated (diff)
- Status changed from Open to Rejected
Updated by xz0r (xz0r xz0r) over 8 years ago
Updated by nobu (Nobuyoshi Nakada) over 8 years ago
In common, an argument is determined by the preceding option, consider grep command's -e option.
If you want to disallow an argument starting with -, you'd need to specify a pattern
or allowed values
Updated by xz0r (xz0r xz0r) over 8 years ago
nobu (Nobuyoshi Nakada) wrote:
In common, an argument is determined by the preceding option, consider
grepcommand's-eoption.
If you want to disallow an argument starting with-, you'd need to specify a patternor allowed values
Thanks!
Actions