From d99eeabea61dbe0bdf132afb6d02312332f281ea Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 1 Feb 2009 07:10:08 +0000 Subject: * 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/trunk@21926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/optparse.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/optparse.rb') diff --git a/lib/optparse.rb b/lib/optparse.rb index 9c6b3924f0..19793f8d4d 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 {|ss| ss.length}.max.to_i while mlen > width and l = left.shift mlen = left.collect {|ss| ss.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 -- cgit v1.2.3