Class: Pvectl::Formatters::Wide

Inherits:
Base
  • Object
show all
Defined in:
lib/pvectl/formatters/wide.rb

Overview

Formats data as a wide table with extended columns.

For collections: uses wide_columns and to_wide_row from presenter. For single resources (describe): delegates to Table (no wide variant).

Examples:

Wide table output

NAME    STATUS   NODE   MEMORY   CPU   UPTIME
vm-100  running  pve1   2048     2     3d 5h

See Also:

Instance Method Summary collapse

Instance Method Details

#format(data, presenter, color_enabled: true, describe: false, **context) ⇒ String

Formats data as wide table output.

Parameters:

  • data (Array, Object)

    collection of models or single model

  • presenter (Presenters::Base)

    presenter for column/row definitions

  • color_enabled (Boolean) (defaults to: true)

    whether to apply color formatting

  • describe (Boolean) (defaults to: false)

    whether this is a describe command

  • context (Hash)

    additional context passed to presenter

Returns:

  • (String)

    formatted wide table string



28
29
30
31
32
33
34
35
36
# File 'lib/pvectl/formatters/wide.rb', line 28

def format(data, presenter, color_enabled: true, describe: false, **context)
  # For describe (single resource), delegate to Table formatter
  # Wide format has no meaning for vertical key-value layout
  if describe || !collection?(data)
    Table.new.format(data, presenter, color_enabled: color_enabled, describe: true, **context)
  else
    format_wide_table(data, presenter, color_enabled, **context)
  end
end