1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

optparse.rb: into kwdarg

* lib/optparse.rb (OptionParser#order!): add `into` optional
  keyword argument to store the results.  [Feature #11191]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-01-06 08:23:10 +00:00
parent 4d0e0a3823
commit 49684589cd
4 changed files with 33 additions and 13 deletions

View file

@ -64,4 +64,15 @@ class TestOptionParser < Test::Unit::TestCase
assert_equal(%w"", no_error {@opt.parse!(%w"--regexp=/foo/n")})
assert_equal(/foo/n, @reopt)
end
def test_into
@opt.def_option "-h", "--host=HOST", "hostname"
@opt.def_option "-p", "--port=PORT", "port", Integer
@opt.def_option "-v", "--verbose" do @verbose = true end
@opt.def_option "-q", "--quiet" do @quiet = true end
result = {}
@opt.parse %w(--host localhost --port 8000 -v), into: result
assert_equal({host: "localhost", port: 8000, verbose: true}, result)
assert_equal(true, @verbose)
end
end