[#49675] Request to update LEGAL file for zlib, UCD license — Jun Aruga <jaruga@...>

こんにちは。有賀と申します。

10 messages 2016/06/20

[ruby-dev:49644] [Ruby trunk Feature#12459][Feedback] Add type coercion option to ARGV.getopts arguements.

From: nobu@...
Date: 2016-06-05 10:06:42 UTC
List: ruby-dev #49644
Issue #12459 has been updated by Nobuyoshi Nakada.

Description updated
Status changed from Open to Feedback

First, `ARGV.getopts` is a easy wrapper for old getopts.rb, not recommended.
And I don't like the idea to use **names** there.

```ruby
ARGV.getopts("", ["strval:string option", String], ["intval:integer"=>Integer])
```

or

```ruby
ARGV.getopts("", "strval:string option"=>String, "intval:integer"=>Integer)
```

may be acceptable?


----------------------------------------
Feature #12459: Add type coercion option to ARGV.getopts arguements.
https://bugs.ruby-lang.org/issues/12459#change-59019

* Author: Seiji Takahashi
* Status: Feedback
* Priority: Normal
* Assignee: 
----------------------------------------
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.

~~~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', 'optwithval:val(String)')
~~~

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



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next