Project

General

Profile

Bug #15774

OptionParser doesn't accept Date options as stated in the docs

Added by rosenfeld (Rodrigo Rosenfeld Rosas) about 1 month ago. Updated 26 days ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux]
[ruby-core:92321]

Description

The documentation for OptionParser states that Date, Time and DateTime are supported types for automatic coertion, however, it raises an error if any of those types are provided to the "on" method: "unsupported argument type: Date".

Either the documentation is wrong or there's a bug in the implementation of OptionParser I guess.

Thanks for taking a look into this.

History

Updated by oleynikov (Alexander Oleynikov) 29 days ago

You need to require 'optparse/time' to use built-in Time conversion (it doesn't seem to be stated explicitly in the documentation, but it is demonstrated throughout the examples) and you need to require 'optparse/date' to use Date or DateTime conversions. Or you can define custom conversions.

Updated by rosenfeld (Rodrigo Rosenfeld Rosas) 26 days ago

Oh, thanks, I wasn't aware of that. Now that you said I re-read the documentation and found the instructions to use those built-in conversions. Thanks. This ticket can be closed. I'm not allowed to close it myself.

#3

Updated by nagachika (Tomoyuki Chikanaga) 26 days ago

  • Status changed from Open to Closed

Also available in: Atom PDF