You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OptionParser object doesn't work correctly when both Integer and enum values (such as [1, 2, 3] or ["1", "2", "3"]) specified.
When Integer and [1, 2, 3] specified, OptionParser::InvalidArgument will be raised unexpectedly.
When Integer and ["1", "2", "3"] specified, no exceptions will be raised but the option value will be remained as a string (expected to be converted into an integer value).
Example script:
require'optparse'parser=OptionParser.newparser.on("-a <N>","int #1",Integer)parser.on("-b <N>","int #2",Integer,[1,2,3])# with enum (integer)parser.on("-c <N>","int #3",Integer,["1","2"])# with enum (string)## Without enum, parser parses args successfully.opts={}parser.parse(["-a","2"],into: opts)# okpopts#=> {:a=>2}## [BUG] With enum (integer), parser raises InvalidArgument error.opts={}#parser.parse(["-b", "2"], into: opts) #=> OptionParser::InvalidArgument## [BUG] With enum (string), parser doesn't convert value into an integer.opts={}parser.parse(["-c","2"],into: opts)# no exceptionpopts#=> {:c=>"2"} (expected: {:c=>2})
Environment:
Version: optparse 0.4.0 & 0.5.0 (github repo)
Ruby: 3.3.5
If allowed, I can submit a pull request for this bug. Let me know if you need it.
The text was updated successfully, but these errors were encountered:
OptionParser object doesn't work correctly when both
Integer
and enum values (such as[1, 2, 3]
or["1", "2", "3"]
) specified.Integer
and[1, 2, 3]
specified,OptionParser::InvalidArgument
will be raised unexpectedly.Integer
and["1", "2", "3"]
specified, no exceptions will be raised but the option value will be remained as a string (expected to be converted into an integer value).Example script:
Environment:
If allowed, I can submit a pull request for this bug. Let me know if you need it.
The text was updated successfully, but these errors were encountered: