class Thor::Shell::Basic

def print_table(table, options={})


colwidth:: Force the first column to colwidth spaces wide.
ident:: Indent the first column by ident value.
==== Options

Array[Array[String, String, ...]]
==== Parameters

Prints a table.
def print_table(table, options={})
  return if table.empty?
  formats, ident, colwidth = [], options[:ident].to_i, options[:colwidth]
  options[:truncate] = terminal_width if options[:truncate] == true
  formats << "%-#{colwidth + 2}s" if colwidth
  start = colwidth ? 1 : 0
  start.upto(table.first.length - 2) do |i|
    maxima ||= table.max{|a,b| a[i].size <=> b[i].size }[i].size
    formats << "%-#{maxima + 2}s"
  end
  formats[0] = formats[0].insert(0, " " * ident)
  formats << "%s"
  table.each do |row|
    sentence = ""
    row.each_with_index do |column, i|
      sentence << formats[i] % column.to_s
    end
    sentence = truncate(sentence, options[:truncate]) if options[:truncate]
    $stdout.puts sentence
  end
end