Module: MysqlInspector::CLI::Formatting

Included in:
DiffCommand, GrepCommand
Defined in:
lib/mysql_inspector/cli.rb

Instance Method Summary collapse

Instance Method Details

#format_items(label, items, &formatter) ⇒ Object

Print table item details.

Examples

LABEL    item1
         item2


40
41
42
43
44
45
46
47
48
49
50
# File 'lib/mysql_inspector/cli.rb', line 40

def format_items(label, items, &formatter)
  pad = " " * 4
  formatter ||= proc { |item | item.to_sql }
  items.each.with_index { |item, i|
    if i == 0
      puts [label, pad, formatter.call(item)] * ""
    else
      puts [" " * label.size, pad, formatter.call(item)] * ""
    end
  }
end