Project

General

Profile

Feature #12459

Updated by nobu (Nobuyoshi Nakada) over 3 years ago

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

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

~~~ruby ~~~
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:

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

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

Back