module Cradare2::Util::CLIFormatter

Overview

Centralized CLI formatting helper leveraging Opal's one-shot component print mode. Provides styled tables, boxes, rules, badges, syntax-highlighted code views, and rendered markdown for rich terminal diagnostics while respecting NO_COLOR and non-TTY modes.

Extended Modules

Defined in:

cradare2/util/cli_formatter.cr

Instance Method Summary

Instance Method Detail

def badge(label : String, bg : Opal::Color | Symbol | String = :blue, fg : Opal::Color | Symbol | String = :white, bold : Bool = true, color : Bool | Nil = nil) : String #

Renders a pill badge with custom background and foreground colors.


[View source]
def box(text : String, title : String | Nil = nil, border : Symbol | Opal::Border | String = :rounded, border_fg : Opal::Color | Symbol | String = Opal::Color.none, padding : Int32 = 1, width : Int32 | Nil = nil, color : Bool | Nil = nil) : String #

Renders a bordered container box around text content.


[View source]
def code(source : String, language : Symbol | String = :crystal, show_line_numbers : Bool = true, start_line : Int32 = 1, width : Int32 | Nil = nil, color : Bool | Nil = nil) : String #

Renders syntax-highlighted source code with optional line numbers.


[View source]
def markdown(text : String, width : Int32 | Nil = nil) : String #

Renders GitHub-flavored Markdown text directly into an ANSI-formatted string.


[View source]
def rule(text : String | Nil = nil, char : Char = '─', fg : Opal::Color | Symbol | String = Opal::Color.none, align : Symbol = :center, width : Int32 | Nil = nil, color : Bool | Nil = nil) : String #

Renders a horizontal divider rule with centered label text.


[View source]
def table(headers : Array(String), rows : Array(Array(String)), width : Int32 | Nil = nil, zebra : Bool = false, border_style : Opal::Border | Symbol | String | Nil = :rounded, color : Bool | Nil = nil) : String #

Renders a formatted data table with headers, rows, and optional zebra striping.


[View source]