summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-01 07:14:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-01 07:14:38 +0000
commitc737e6d90dfbf14b3d3701a67fc2f478cff00794 (patch)
treec686f8d7095b3d85ce027f79c1c2fa6add35408b /lib
parent37a19c7d52c01ba8a9c07ebb4374ab66a22b4e06 (diff)
* lib/optparse.rb (Switch#summarize): strips an equal sign from
short option, and fills right sides in shorter lines. [ruby-talk:326414] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@21927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/optparse.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/optparse.rb b/lib/optparse.rb
index b71157f7da..d19e940067 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -384,10 +384,16 @@ class OptionParser
left[-1] << if left[-1].empty? then ' ' * 4 else ', ' end << s
end
- left[0] << arg if arg
+ if arg
+ left[0] << (left[1] ? arg.sub(/\A(\[?)=/, '\1') + ',' : arg)
+ end
mlen = left.collect {|s| s.length}.max.to_i
while mlen > width and l = left.shift
mlen = left.collect {|s| s.length}.max.to_i if l.length == mlen
+ if l.length < width and (r = right[0]) and !r.empty?
+ l = l.to_s.ljust(width) + ' ' + r
+ right.shift
+ end
yield(indent + l)
end