ExStorageServiceCli.Output (ex_storage_service_cli v0.1.3)

Copy Markdown View Source

Output formatting for the CLI.

Supports human-readable table output with ANSI colors and machine-readable JSON output.

Summary

Functions

Prints an error message to stderr with red color.

Formats a byte count into a human-readable string.

Formats an ISO 8601 datetime string into a shorter display format.

Safely converts an error reason to a printable string.

Prints an informational message to stdout.

Prints data in the appropriate format based on context.

Prints a success message to stdout with green color.

Prints a table with headers and rows.

Prints a warning message to stderr with yellow color.

Functions

error(message)

Prints an error message to stderr with red color.

format_bytes(bytes)

Formats a byte count into a human-readable string.

format_datetime(iso_string)

Formats an ISO 8601 datetime string into a shorter display format.

format_error(reason)

Safely converts an error reason to a printable string.

Handles exceptions (e.g. Req.TransportError), strings, atoms, and arbitrary terms.

info(message)

Prints an informational message to stdout.

render(data, ctx, formatter)

Prints data in the appropriate format based on context.

When ctx.json is true, outputs JSON. Otherwise, uses the provided formatter function for human-readable output.

success(message)

Prints a success message to stdout with green color.

table(headers, rows)

Prints a table with headers and rows.

Parameters

  • headers - List of column header strings
  • rows - List of row lists (each row is a list of cell values)

warn(message)

Prints a warning message to stderr with yellow color.