зеркало из https://github.com/github/ruby.git
* lib/optparse.rb (SPLAT_PROC): splat values by hand.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
1cf4744a83
Коммит
39c4d6928b
|
@ -1,10 +1,6 @@
|
||||||
Sun Dec 21 14:48:51 2008 TAKAO Kouji <kouji@takao7.net>
|
Sun Dec 21 14:55:18 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* test/readline/test_readline_history.rb: checked encoding.
|
* lib/optparse.rb (SPLAT_PROC): splat values by hand.
|
||||||
|
|
||||||
Sun Dec 21 14:45:58 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|
||||||
|
|
||||||
* lib/optparse.rb (parse_in_order): splat values to be passed.
|
|
||||||
|
|
||||||
Sun Dec 21 13:50:37 2008 TAKAO Kouji <kouji@takao7.net>
|
Sun Dec 21 13:50:37 2008 TAKAO Kouji <kouji@takao7.net>
|
||||||
|
|
||||||
|
|
|
@ -996,7 +996,7 @@ class OptionParser
|
||||||
end
|
end
|
||||||
private :notwice
|
private :notwice
|
||||||
|
|
||||||
SPLAT_PROC = proc {|*a| next *a}
|
SPLAT_PROC = proc {|*a| a.length <= 1 ? a.first : a}
|
||||||
#
|
#
|
||||||
# Creates an OptionParser::Switch from the parameters. The parsed argument
|
# Creates an OptionParser::Switch from the parameters. The parsed argument
|
||||||
# value is passed to the given block, where it can be processed.
|
# value is passed to the given block, where it can be processed.
|
||||||
|
@ -1263,7 +1263,7 @@ class OptionParser
|
||||||
end
|
end
|
||||||
begin
|
begin
|
||||||
opt, cb, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
|
opt, cb, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
|
||||||
val = cb.call(*val) if cb
|
val = cb.call(val) if cb
|
||||||
setter.call(sw.switch_name, val) if setter
|
setter.call(sw.switch_name, val) if setter
|
||||||
rescue ParseError
|
rescue ParseError
|
||||||
raise $!.set_option(arg, rest)
|
raise $!.set_option(arg, rest)
|
||||||
|
@ -1294,7 +1294,7 @@ class OptionParser
|
||||||
opt, cb, val = sw.parse(val, argv) {|*exc| raise(*exc) if eq}
|
opt, cb, val = sw.parse(val, argv) {|*exc| raise(*exc) if eq}
|
||||||
raise InvalidOption, arg if has_arg and !eq and arg == "-#{opt}"
|
raise InvalidOption, arg if has_arg and !eq and arg == "-#{opt}"
|
||||||
argv.unshift(opt) if opt and (opt = opt.sub(/\A-*/, '-')) != '-'
|
argv.unshift(opt) if opt and (opt = opt.sub(/\A-*/, '-')) != '-'
|
||||||
val = cb.call(*val) if cb
|
val = cb.call(val) if cb
|
||||||
setter.call(sw.switch_name, val) if setter
|
setter.call(sw.switch_name, val) if setter
|
||||||
rescue ParseError
|
rescue ParseError
|
||||||
raise $!.set_option(arg, arg.length > 2)
|
raise $!.set_option(arg, arg.length > 2)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче