Ragex.CLI.Output
(Ragex v0.9.1)
View Source
Rich output formatting utilities for tables, lists, and structured data.
Provides functions to render tabular data, lists, and other formatted output for the CLI.
Summary
Functions
Renders a formatted diff with colors.
Formats a comprehensive analysis report as text.
Renders a key-value list.
Renders a simple list with bullets.
Renders a section header with optional underline.
Renders a horizontal separator line.
Renders a progress summary with statistics.
Renders a table with headers and rows.
Types
Functions
@spec diff([{:add | :delete | :context, String.t()}]) :: :ok
Renders a formatted diff with colors.
Examples
iex> Output.diff([{:add, "new line"}, {:delete, "old line"}, {:context, "same"}])
# Renders with colors:
# + new line (green)
# - old line (red)
# same (muted)
Formats a comprehensive analysis report as text.
Takes a report map from mix ragex.analyze and formats it for display.
Examples
text = Output.format_analysis_report(report)
IO.puts(text)
Renders a key-value list.
Options
:separator- Separator between key and value (default: ": "):indent- Indentation level (default: 0):key_width- Fixed width for keys (default: auto):key_color- Color for keys (default: :cyan)
Examples
iex> Output.key_value([{"Name", "Alice"}, {"Age", "30"}])
# Renders:
# Name: Alice
# Age: 30
Renders a simple list with bullets.
Options
:bullet- Bullet character (default: "•"):indent- Indentation level (default: 0):color- Color function to apply (default: nil)
Examples
iex> Output.list(["Item 1", "Item 2", "Item 3"])
# Renders:
# • Item 1
# • Item 2
# • Item 3
Renders a section header with optional underline.
Options
:underline- Character for underline (default: "="):color- Color for header (default: :cyan)
Examples
iex> Output.section("Statistics")
# Renders:
# Statistics
# ==========
@spec separator(keyword()) :: :ok
Renders a horizontal separator line.
Options
:char- Character to use (default: "-"):width- Line width (default: 80):color- Color for line (default: nil)
Examples
iex> Output.separator()
# Renders:
# --------------------------------------------------------------------------------
@spec summary(map()) :: :ok
Renders a progress summary with statistics.
Examples
iex> Output.summary(%{total: 100, success: 95, errors: 5, duration: 1.5})
# Renders formatted summary with colors
Renders a table with headers and rows.
Options
:alignments- List of alignments for each column (default: all :left):borders- Whether to draw borders (default: true):padding- Space between columns (default: 2)
Examples
iex> Output.table(["Name", "Age"], [["Alice", 30], ["Bob", 25]])
# Renders:
# Name | Age
# -------|-----
# Alice | 30
# Bob | 25