Project

General

Profile

Actions

Feature #12459

closed

Add type coercion option to ARGV.getopts arguements.

Added by timakin (Seiji Takahashi) almost 8 years ago. Updated almost 8 years ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-dev:49643]

Description

I suggest a little new feature to lib/optparse.rb.

When I created CLI tool I defined option parser with ARGV.getopts function like following.

ARGV.getopts('abc:', 'logopt, 'optwithval:val')

It was so easy and short to recognize what is declared as options, but I could't force a type of the values.
Maybe it looks unshapely, but I'd like to confirm the types like this:

ARGV.getopts('strval:(String)intval:(Integer)', 'logopt', 'optwithval:val(String)')

Normal OptParser has type coercion but extended function ARGV.getopts has no feature like this.
This difference is trivial but inconvenient.

Actions

Also available in: Atom PDF

Like0
Like0Like0