s3-orchestrator

output

import "github.com/afreidah/s3-orchestrator/internal/cli/output"

Index

func FormatBytes

func FormatBytes(n int64) string

FormatBytes renders a byte count in IEC units (KiB, MiB, GiB, …) with one decimal place. Values under 1024 render as plain bytes, e.g. “512 B”.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration renders d for operator-facing output. Values under one second show milliseconds (“340ms”), under one minute show seconds with one decimal (“1.2s”), and above show minutes with one decimal (“2.5m”).

func KeyValues

func KeyValues(w io.Writer, pairs [][2]string) error

KeyValues writes a left-aligned key/value block to w, padding keys to a common width so the values line up. Used for single-record summaries where a full table would be noise.

func PrettyJSON

func PrettyJSON(w io.Writer, raw []byte) error

PrettyJSON writes raw JSON bytes to w, indented for readability. Bytes that do not parse as JSON are written through unchanged so a non-JSON error body still reaches the operator. Operating on raw bytes (rather than a decoded value) keeps key order and shape identical to what the server emitted.

func RenderValue

func RenderValue(w io.Writer, raw []byte) error

RenderValue decodes raw JSON and writes it as an indented, YAML-like text block to w. Non-JSON input is written through unchanged.

func Table

func Table(w io.Writer, headers []string, rows [][]string) error

Table writes a column-aligned table to w with a header row, a dashed separator sized to each header, and one line per row. Column widths are computed by text/tabwriter. Rows shorter than the header are padded with blanks so ragged input still aligns.

type Format

Format selects how a command renders its result.

type Format string

const (
    FormatText Format = "text"
    FormatJSON Format = "json"
)

func FromJSON

func FromJSON(jsonFlag bool) Format

FromJSON maps the --json boolean flag onto a Format. Absent flag renders human-readable text; present flag renders raw JSON.

func (Format) IsJSON

func (f Format) IsJSON() bool

IsJSON reports whether the format is raw JSON.

Generated by gomarkdoc