def print_big_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 << "%s"
formats[0] = formats[0].insert(0, " " * ident)
header_printed = false
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
say(set_color("-" * sentence.size, :green)) unless header_printed
header_printed = true
end
end