ExStorageServiceCli.Output (ex_storage_service_cli v0.1.10)

Copy Markdown View Source

Output formatting for the CLI.

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

Summary

Functions

Returns the current system datetime formatted in the local timezone.

Prints an error message to stderr with red color.

Formats a byte count into a human-readable string.

Formats a byte count into a short representation like 36B, 12KB, 2.4MB, 1.2GB.

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

Formats an ISO 8601 datetime string to local timezone display format [YYYY-MM-DD HH:MM:SS TZ].

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

current_datetime_local()

Returns the current system datetime formatted in the local timezone.

error(message)

Prints an error message to stderr with red color.

format_bytes(bytes)

Formats a byte count into a human-readable string.

format_bytes_short(bytes)

Formats a byte count into a short representation like 36B, 12KB, 2.4MB, 1.2GB.

format_datetime(iso_string)

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

format_datetime_local(iso_string)

Formats an ISO 8601 datetime string to local timezone display format [YYYY-MM-DD HH:MM:SS TZ].

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.