Documentation
¶
Overview ¶
Package output renders run results for humans (coloured, readable) and for machines (one JSON object per result). The string-returning renderers in render.go are shared with the terminal UI; the functions here are the io.Writer wrappers the CLI uses.
Index ¶
- func Attempt(t Theme, p runner.Progress) string
- func Body(w io.Writer, res *runner.Result)
- func BodyOrSummary(t Theme, res *runner.Result, body []byte) string
- func Changes(t Theme, changes []history.Change, width int) string
- func Checks(t Theme, res *runner.Result, width int, expected bool) string
- func Deps(w io.Writer, res *runner.Result, verbose bool)
- func Describe(t Theme, d *runner.Description, headers []httpfile.Header) string
- func HighlightJSON(t Theme, s string) string
- func HistoryEntries(t Theme, entries []history.Entry) string
- func HistoryEntry(e history.Entry) string
- func HistoryTime(at time.Time) string
- func Human(w io.Writer, res *runner.Result, verbose bool)
- func Indent(s string) string
- func JSON(w io.Writer, res *runner.Result) error
- func JSONNested(w io.Writer, res *runner.Result) error
- func Mask(v runner.VarInfo) string
- func Readiness(t Theme, d *runner.Description) string
- func RenderBody(t Theme, raw []byte) string
- func RequestDetail(t Theme, res *runner.Result) string
- func RequestLine(t Theme, res *runner.Result) string
- func ResponseHeaders(t Theme, res *runner.Result) string
- func Result(t Theme, res *runner.Result, o Options) string
- func Section(t Theme, title string) string
- func Size(n int) string
- func StatusLine(t Theme, res *runner.Result) string
- func Summary(w io.Writer, results []*runner.Result)
- func SummaryLine(t Theme, results []*runner.Result) string
- func SummaryTable(t Theme, results []*runner.Result) string
- func Timings(t Theme, res *runner.Result) string
- func Truncate(s string, n int) string
- func Variables(t Theme, vars []runner.VarInfo, hints bool) string
- type Options
- type Theme
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Attempt ¶
Attempt renders the progress line printed after a failed attempt of a request that is being retried.
func BodyOrSummary ¶
BodyOrSummary renders a body, or for one that is not text, a line with its size and content type instead of the bytes.
func Changes ¶
Changes renders the differences between two responses, one per line: ~ for a changed value, + for an added one, - for a removed one. Values are cut at width.
func Checks ¶
Checks renders the assertions, captures and errors of a result. With expected set, failed assertions show the expected value as well as the actual one.
func Deps ¶
Deps writes the reports of the requests `# @ref` ran before res, each followed by a line saying why it ran.
func Describe ¶
Describe renders what `apic describe` shows. headers are the request's raw headers in file order.
func HighlightJSON ¶
HighlightJSON colours the keys, strings, numbers and literals of an already-indented, valid JSON document. It works line by line (JSON strings never span lines) and passes anything unexpected through untouched, so a document that is not JSON comes back unchanged.
func HistoryEntries ¶
HistoryEntries renders a request's history, newest first: one row per entry with its number, time, status, duration and size.
func HistoryEntry ¶
HistoryEntry names one entry: "#2 (2026-10-06 10:00:01, 200)".
func HistoryTime ¶
HistoryTime is how history entries show their time: local, to the second.
func Human ¶
Human writes a readable report of a result, after the reports of the requests `# @ref` ran first, each under a line saying why it ran.
func JSON ¶
JSON writes one result as a single JSON line. The results of requests `# @ref` ran first are written as lines of their own, before it, so a consumer of `apic run --json` sees exactly one object per request sent; the object itself carries no ran_first.
func JSONNested ¶
JSONNested writes one result as a single JSON line with the results of its `# @ref` dependencies nested under ran_first.
func Readiness ¶
func Readiness(t Theme, d *runner.Description) string
Readiness renders the boxed verdict at the end of a description.
func RenderBody ¶
RenderBody pretty-prints and highlights a JSON body; other bodies are returned as they are. The result has no trailing newline.
func RequestDetail ¶
RequestDetail renders the request headers and body (verbose mode).
func RequestLine ¶
RequestLine renders "METHOD url" with the URL masked when redacting.
func ResponseHeaders ¶
ResponseHeaders renders the response headers sorted and lower-cased, with sensitive values masked and every value masked when redacting.
func StatusLine ¶
StatusLine renders "200 OK · 87 ms · 412 B"; when the request never got a response it renders the errors instead.
func SummaryLine ¶
SummaryLine renders "3 passed", "1 failed, 3 passed" or "3 passed, 1 skipped".
func SummaryTable ¶
SummaryTable renders one row per request followed by the totals line, for flows of more than one request.
func Timings ¶
Timings renders where the round trip went, when the response carries a breakdown: "dns 12 ms · connect 18 ms · tls 41 ms · ttfb 60 ms · total 87 ms · new connection".
Types ¶
type Options ¶
type Options struct {
Verbose bool // request headers and body, response headers
Width int // where long values are cut; 0 means 80
}
Options controls how a result is rendered for humans.
type Theme ¶
type Theme struct {
Bold lipgloss.Style
Dim lipgloss.Style
OK lipgloss.Style
Warn lipgloss.Style
Fail lipgloss.Style
URL lipgloss.Style
Header lipgloss.Style
Capture lipgloss.Style
Accent lipgloss.Style
// JSON syntax highlighting.
Key lipgloss.Style
Str lipgloss.Style
Num lipgloss.Style
Lit lipgloss.Style
// contains filtered or unexported fields
}
Theme holds every style apic uses for human output, shared by the CLI renderers and the terminal UI so both look the same. Colours collapse to plain text automatically when lipgloss's colour profile is Ascii (--no-color, NO_COLOR, --json, or output that is not a terminal).
func (Theme) StatusCode ¶
StatusCode renders the status number on its own, coloured by class, for the places too narrow for the reason phrase.