lib/support/help.rb in gli-1.3.2 vs lib/support/help.rb in gli-1.3.3
- old
+ new
@@ -143,10 +143,11 @@
# Wraps the line at the given column length, using the given line padding.
# Assumes that the first line doesn't need the padding, as its filled
# up with other stuff
def wrap(line,pad_length=0,line_length=nil)
+ line ||= ''
if line_length.nil?
line_length = Terminal.instance.size[0]
end
line_padding = sprintf("%#{pad_length}s",'')
words = line.split(/\s+/)
@@ -163,10 +164,10 @@
return wrapped if words.empty?
end
wrapped += "\n"
this_line = line_padding
words.each do |word|
- if this_line.length + word.length > line_length
+ if this_line.length + word.length >= line_length
wrapped += this_line
wrapped += "\n"
this_line = line_padding + word
else
this_line += ' ' if this_line.length > line_padding.length