Module: Legion::CLI::Output

Defined in:
lib/legion/cli/output.rb

Defined Under Namespace

Classes: Formatter

Constant Summary collapse

COLORS =

Purple-only palette mapped to semantic names. Legacy ANSI names (red, green, etc.) remap to purple intensity shades so all existing code works but renders on-brand.

{
  reset:    "\e[0m",
  bold:     "\e[1m",
  dim:      "\e[2m",

  # Legacy names → purple intensity equivalents
  red:      Theme.c(:self_point),     # errors: brightest
  green:    Theme.c(:cardinal),       # success: calm/nominal
  yellow:   Theme.c(:innermost),      # warnings: medium-bright
  blue:     Theme.c(:mid_nodes),
  magenta:  Theme.c(:inner_nodes),
  cyan:     Theme.c(:mid_nodes),
  white:    Theme.c(:near_white),
  gray:     Theme.c(:mid_arcs),

  # Semantic theme names
  title:    Theme.c(:self_point),
  heading:  Theme.c(:near_white),
  body:     Theme.c(:inner_nodes),
  label:    Theme.c(:cardinal),
  accent:   Theme.c(:mid_nodes),
  muted:    Theme.c(:diagonal_nodes),
  disabled: Theme.c(:skip),
  border:   Theme.c(:inner_tier),
  node:     Theme.c(:cardinal),

  # Status intensity (no traffic lights)
  nominal:  Theme.c(:cardinal),
  caution:  Theme.c(:innermost),
  critical: Theme.c(:self_point)
}.freeze
STATUS_ICONS =

Status → intensity mapping. Brightness communicates urgency.

{
  ok:        'nominal',
  ready:     'nominal',
  running:   'nominal',
  enabled:   'nominal',
  loaded:    'nominal',
  completed: 'nominal',
  warning:   'caution',
  pending:   'caution',
  disabled:  'muted',
  error:     'critical',
  failed:    'critical',
  dead:      'critical',
  unknown:   'disabled'
}.freeze

Class Method Summary collapse

Class Method Details

.encode_json(data) ⇒ Object

Use Legion::JSON if available, fall back to stdlib



10
11
12
13
14
15
16
# File 'lib/legion/cli/output.rb', line 10

def self.encode_json(data)
  if defined?(Legion::JSON) && Legion::JSON.respond_to?(:dump)
    Legion::JSON.dump(data)
  else
    JSON.pretty_generate(data)
  end
end