mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/optparse.rb (OptionParser::make_switch): NoArgument doesn't
override other styles. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1c37352f8a
commit
e13bfb1509
2 changed files with 16 additions and 5 deletions
|
@ -1,8 +1,11 @@
|
||||||
Fri Jan 31 02:50:34 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
Fri Jan 31 09:40:07 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
* lib/optparse.rb (OptionParser::List::accept): default
|
* lib/optparse.rb (OptionParser::List::accept): default
|
||||||
pattern must not be nil.
|
pattern must not be nil.
|
||||||
|
|
||||||
|
* lib/optparse.rb (OptionParser::make_switch): NoArgument doesn't
|
||||||
|
override other styles.
|
||||||
|
|
||||||
Thu Jan 30 16:46:43 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
Thu Jan 30 16:46:43 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
* lib/optparse.rb (OptionParser::Switch::PlacedArgument): added.
|
* lib/optparse.rb (OptionParser::Switch::PlacedArgument): added.
|
||||||
|
|
|
@ -158,6 +158,10 @@ Individual switch class.
|
||||||
raise ArgumentError, "#{arg}: incompatible argument styles\n #{self}, #{t}"
|
raise ArgumentError, "#{arg}: incompatible argument styles\n #{self}, #{t}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.pattern
|
||||||
|
NilClass
|
||||||
|
end
|
||||||
|
|
||||||
=begin private
|
=begin private
|
||||||
--- OptionParser::Switch.new
|
--- OptionParser::Switch.new
|
||||||
=end #'#"#`#
|
=end #'#"#`#
|
||||||
|
@ -294,6 +298,9 @@ Switch that takes no arguments.
|
||||||
end
|
end
|
||||||
def self.incompatible_argument_styles(*)
|
def self.incompatible_argument_styles(*)
|
||||||
end
|
end
|
||||||
|
def self.pattern
|
||||||
|
Object
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin private
|
=begin private
|
||||||
|
@ -336,7 +343,8 @@ Switch that can omit argument.
|
||||||
|
|
||||||
class PlacedArgument < self
|
class PlacedArgument < self
|
||||||
def parse(arg, argv, &error)
|
def parse(arg, argv, &error)
|
||||||
unless arg or argv.empty? or /\A-/ =~ argv[0]
|
unless arg
|
||||||
|
return nil, block, nil if argv.empty? or /\A-/ =~ argv[0]
|
||||||
arg = argv.shift
|
arg = argv.shift
|
||||||
end
|
end
|
||||||
super(*parse_arg(arg, &error))
|
super(*parse_arg(arg, &error))
|
||||||
|
@ -981,8 +989,8 @@ Default options, which never appear in option summary.
|
||||||
nolong << 'no-' + o
|
nolong << 'no-' + o
|
||||||
when /^--([^][=\s]*)(.+)?/
|
when /^--([^][=\s]*)(.+)?/
|
||||||
q, a = $1, $2
|
q, a = $1, $2
|
||||||
o = notwice(a ? NilClass : TrueClass, klass, 'type')
|
|
||||||
if a
|
if a
|
||||||
|
o = notwice(NilClass, klass, 'type')
|
||||||
default_style = default_style.guess(arg = a)
|
default_style = default_style.guess(arg = a)
|
||||||
default_pattern, conv = search(:atype, o) unless default_pattern
|
default_pattern, conv = search(:atype, o) unless default_pattern
|
||||||
end
|
end
|
||||||
|
@ -999,8 +1007,8 @@ Default options, which never appear in option summary.
|
||||||
short << Regexp.new(q)
|
short << Regexp.new(q)
|
||||||
when /^-(.)(.+)?/
|
when /^-(.)(.+)?/
|
||||||
q, a = $1, $2
|
q, a = $1, $2
|
||||||
o = notwice((a ? Object : TrueClass), klass, 'type')
|
|
||||||
if a
|
if a
|
||||||
|
o = notwice(NilClass, klass, 'type')
|
||||||
default_style = default_style.guess(arg = a)
|
default_style = default_style.guess(arg = a)
|
||||||
default_pattern, conv = search(:atype, o) unless default_pattern
|
default_pattern, conv = search(:atype, o) unless default_pattern
|
||||||
end
|
end
|
||||||
|
@ -1014,7 +1022,7 @@ Default options, which never appear in option summary.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
default_pattern, conv = search(:atype, Object) unless default_pattern
|
default_pattern, conv = search(:atype, default_style.pattern) unless default_pattern
|
||||||
s = if short.empty? and long.empty?
|
s = if short.empty? and long.empty?
|
||||||
raise ArgumentError, "no switch given" if style or pattern or block
|
raise ArgumentError, "no switch given" if style or pattern or block
|
||||||
desc
|
desc
|
||||||
|
|
Loading…
Reference in a new issue