Module: CommandKit::Printing

Defined in:
lib/command_kit/printing.rb

Overview

Extends CommandKit::Printing with color-aware table printing.

Computes column widths from raw text, then applies ANSI color after padding so escape sequences don’t break alignment.

Instance Method Summary collapse

Instance Method Details



7
8
9
10
11
12
13
14
15
# File 'lib/command_kit/printing.rb', line 7

def print_table_color(rows, header: nil, color: :green, index: 0, **)
  all_rows = header ? [header] + rows : rows
  widths = column_widths(all_rows)
  print_header(header, widths) if header
  rows.each do |row|
    line = format_row(row, widths, color, index)
    puts line.join("  ")
  end
end