Method: String#cmd_fold

Defined in:
lib/wavefront-cli/stdlib/string.rb

#cmd_fold(twidth = TW, indent = 10) ⇒ Object

Fold long command lines. We can’t break on a space after an option or it confuses docopt.

Parameters:

  • twidth (Integer) (defaults to: TW)

    terminal width

  • indent (Integer) (defaults to: 10)

    size of hanging indent, in chars



12
13
14
15
# File 'lib/wavefront-cli/stdlib/string.rb', line 12

def cmd_fold(twidth = TW, indent = 10)
  gsub(/(-\w) /, '\\1^').scan_line(twidth - 12).join("\n#{' ' * indent}")
                        .restored
end