builder/extra/cluster-home/lib/ruby/tungsten/util.rb
# Display information about the argument formatting {msg} so all lines
# appear formatted correctly
Display information about the argument formatting {msg} so all lines
appear formatted correctly
Display information about the argument formatting { msg } so all lines appear formatted correctly
def output_usage_line(argument, msg = "", default = nil, max_line = nil, additional_help = "")
    if max_line == nil
      max_line = detect_terminal_size()[0]-5
    end
    if msg.is_a?(String)
      msg = msg.split("\n").join(" ")
    else
      msg = msg.to_s()
    end
    msg = msg.gsub(/^\s+/, "").gsub(/\s+$/, $/)
    if default.to_s() != ""
      if msg != ""
        msg += " "
      end
      msg += "[#{default}]"
    end
    if argument.length > 28 || (argument.length + msg.length > max_line)
      output(argument)
      wrapped_lines(msg, 29).each{
        |line|
        output(line)
      }
    else
      output(format("%-29s", argument) + " " + msg)
    end
    if additional_help.to_s != ""
      additional_help = additional_help.split("\n").map!{
        |line|
        line.strip()
      }.join(' ')
      additional_help.split("<br>").each{
        |line|
        output_usage_line("", line, nil, max_line)
      }
    end
  end
def output_usage_line ( argument , msg = "" , default = nil , max_line = nil , additional_help = "" ) if max_line == nil max_line = detect_terminal_size ( ) [ 0 ] - 5 end if msg . is_a? ( String ) msg = msg . split ( "\n" ) . join ( " " ) else msg = msg . to_s ( ) end msg = msg . gsub ( / ^ \s + / , "" ) . gsub ( / \s +$ / , $/ ) if default . to_s ( ) != "" if msg != "" msg += " " end msg += "[#{default}]" end if argument . length > 28 || ( argument . length + msg . length > max_line ) output ( argument ) wrapped_lines ( msg , 29 ) . each { | line | output ( line ) } else output ( format ( "%-29s" , argument ) + " " + msg ) end if additional_help . to_s != "" additional_help = additional_help . split ( "\n" ) . map! { | line | line . strip ( ) } . join ( ' ' ) additional_help . split ( "<br>" ) . each { | line | output_usage_line ( "" , line , nil , max_line ) } end end
Display information about the argument formatting {msg} so all lines
appear formatted correctly
Display information about the argument formatting { msg } so all lines appear formatted correctly
argument
msg
default
max_line
additional_help