summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-14 08:20:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-14 08:20:26 +0000
commit99ad512486bc0a216d297e16f5346762230015e4 (patch)
tree630348515e1f28eac5865d28f67d1539774e1cbe /lib
parentdef1fbde5cd9586b3d661ded03ccd58183b78049 (diff)
optparse.rb: hyphenize
* lib/optparse.rb (make_switch, parse_in_order): unify underscores to hyphens. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/optparse.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/optparse.rb b/lib/optparse.rb
index 7ff7b8e499..afeff80740 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -1386,7 +1386,8 @@ XXX
default_style = Switch::NoArgument
default_pattern, conv = search(:atype, FalseClass) unless default_pattern
ldesc << "--no-#{q}"
- long << 'no-' + (q = q.downcase)
+ (q = q.downcase).tr!('_', '-')
+ long << "no-#{q}"
nolong << q
when /^--\[no-\]([^\[\]=\s]*)(.+)?/
q, a = $1, $2
@@ -1396,10 +1397,11 @@ XXX
default_pattern, conv = search(:atype, o) unless default_pattern
end
ldesc << "--[no-]#{q}"
- long << (o = q.downcase)
+ (o = q.downcase).tr!('_', '-')
+ long << o
not_pattern, not_conv = search(:atype, FalseClass) unless not_style
not_style = Switch::NoArgument
- nolong << 'no-' + o
+ nolong << "no-#{o}"
when /^--([^\[\]=\s]*)(.+)?/
q, a = $1, $2
if a
@@ -1408,7 +1410,8 @@ XXX
default_pattern, conv = search(:atype, o) unless default_pattern
end
ldesc << "--#{q}"
- long << (o = q.downcase)
+ (o = q.downcase).tr!('_', '-')
+ long << o
when /^-(\[\^?\]?(?:[^\\\]]|\\.)*\])(.+)?/
q, a = $1, $2
o = notwice(Object, klass, 'type')
@@ -1538,6 +1541,7 @@ XXX
# long option
when /\A--([^=]*)(?:=(.*))?/m
opt, rest = $1, $2
+ opt.tr!('_', '-')
begin
sw, = complete(:long, opt, true)
rescue ParseError