* lib/optparse.rb (OptionParser#order!): call handlers iff matches
non-switch. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c7151a3f5e
commit
4eede6b4a1
@ -1,3 +1,8 @@
|
|||||||
|
Wed Apr 13 22:12:16 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/optparse.rb (OptionParser#order!): call handlers iff matches
|
||||||
|
non-switch.
|
||||||
|
|
||||||
Wed Apr 13 21:20:35 2005 WATANABE Hirofumi <eban@ruby-lang.org>
|
Wed Apr 13 21:20:35 2005 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* configure.in (mingw32): extract msvcr*.dll from objdump result.
|
* configure.in (mingw32): extract msvcr*.dll from objdump result.
|
||||||
|
@ -417,13 +417,17 @@ class OptionParser
|
|||||||
end
|
end
|
||||||
|
|
||||||
def add_banner(to)
|
def add_banner(to)
|
||||||
if @short and @short.empty? and @long and @long.empty?
|
unless @short or @long
|
||||||
s = desc.join
|
s = desc.join
|
||||||
to << " [" + s + "]..." unless s.empty?
|
to << " [" + s + "]..." unless s.empty?
|
||||||
end
|
end
|
||||||
to
|
to
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def match_nonswitch?(str)
|
||||||
|
@pattern =~ str unless @short or @long
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Switch that takes no arguments.
|
# Switch that takes no arguments.
|
||||||
#
|
#
|
||||||
@ -1211,13 +1215,13 @@ class OptionParser
|
|||||||
if !(short.empty? and long.empty?)
|
if !(short.empty? and long.empty?)
|
||||||
s = (style || default_style).new(pattern || default_pattern,
|
s = (style || default_style).new(pattern || default_pattern,
|
||||||
conv, sdesc, ldesc, arg, desc, block)
|
conv, sdesc, ldesc, arg, desc, block)
|
||||||
elsif !block
|
elsif !block_given?
|
||||||
raise ArgumentError, "no switch given" if style or pattern
|
raise ArgumentError, "no switch given" if style or pattern
|
||||||
s = desc
|
s = desc
|
||||||
else
|
else
|
||||||
short << pattern
|
short << pattern
|
||||||
s = (style || default_style).new(pattern,
|
s = (style || default_style).new(pattern,
|
||||||
conv, sdesc, ldesc, arg, desc, block)
|
conv, nil, nil, arg, desc, block)
|
||||||
end
|
end
|
||||||
return s, short, long,
|
return s, short, long,
|
||||||
(not_style.new(not_pattern, not_conv, sdesc, ldesc, nil, desc, block) if not_style),
|
(not_style.new(not_pattern, not_conv, sdesc, ldesc, nil, desc, block) if not_style),
|
||||||
@ -1347,8 +1351,10 @@ class OptionParser
|
|||||||
# non-option argument
|
# non-option argument
|
||||||
else
|
else
|
||||||
catch(:prune) do
|
catch(:prune) do
|
||||||
|
require 'pp'
|
||||||
|
pp @stack
|
||||||
visit(:each_option) do |sw|
|
visit(:each_option) do |sw|
|
||||||
sw.block.call(arg) if sw.pattern and sw.pattern =~ arg
|
sw.block.call(arg) if Switch === sw and sw.match_nonswitch?(arg)
|
||||||
end
|
end
|
||||||
nonopt.call(arg)
|
nonopt.call(arg)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user