1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2009-02-01 07:10:08 +00:00
parent 132d0624ec
commit d99eeabea6
2 changed files with 13 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Sun Feb 1 16:10:06 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/optparse.rb (Switch#summarize): strips an equal sign from
short option, and fills right sides in shorter lines.
[ruby-talk:326414]
Sun Feb 1 05:19:43 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* variable.c (rb_const_get_0), vm_insnhelper.c (vm_get_ev_const):

View file

@ -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