output

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attempt

func Attempt(t Theme, p runner.Progress) string

Attempt renders the progress line printed after a failed attempt of a request that is being retried.

func Body

func Body(w io.Writer, res *runner.Result)

Body writes only the response body, pretty-printed when it is JSON.

func BodyOrSummary

func BodyOrSummary(t Theme, res *runner.Result, body []byte) string

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

func Changes(t Theme, changes []history.Change, width int) string

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

func Checks(t Theme, res *runner.Result, width int, expected bool) string

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

func Deps(w io.Writer, res *runner.Result, verbose bool)

Deps writes the reports of the requests `# @ref` ran before res, each followed by a line saying why it ran.

func Describe

func Describe(t Theme, d *runner.Description, headers []httpfile.Header) string

Describe renders what `apic describe` shows. headers are the request's raw headers in file order.

func HighlightJSON

func HighlightJSON(t Theme, s string) string

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

func HistoryEntries(t Theme, entries []history.Entry) string

HistoryEntries renders a request's history, newest first: one row per entry with its number, time, status, duration and size.

func HistoryEntry

func HistoryEntry(e history.Entry) string

HistoryEntry names one entry: "#2 (2026-10-06 10:00:01, 200)".

func HistoryTime

func HistoryTime(at time.Time) string

HistoryTime is how history entries show their time: local, to the second.

func Human

func Human(w io.Writer, res *runner.Result, verbose bool)

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 Indent

func Indent(s string) string

Indent prefixes every line with two spaces.

func JSON

func JSON(w io.Writer, res *runner.Result) error

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

func JSONNested(w io.Writer, res *runner.Result) error

JSONNested writes one result as a single JSON line with the results of its `# @ref` dependencies nested under ran_first.

func Mask

func Mask(v runner.VarInfo) string

Mask returns a variable's value, or *** when it is a secret.

func Readiness

func Readiness(t Theme, d *runner.Description) string

Readiness renders the boxed verdict at the end of a description.

func RenderBody

func RenderBody(t Theme, raw []byte) string

RenderBody pretty-prints and highlights a JSON body; other bodies are returned as they are. The result has no trailing newline.

func RequestDetail

func RequestDetail(t Theme, res *runner.Result) string

RequestDetail renders the request headers and body (verbose mode).

func RequestLine

func RequestLine(t Theme, res *runner.Result) string

RequestLine renders "METHOD url" with the URL masked when redacting.

func ResponseHeaders

func ResponseHeaders(t Theme, res *runner.Result) string

ResponseHeaders renders the response headers sorted and lower-cased, with sensitive values masked and every value masked when redacting.

func Result

func Result(t Theme, res *runner.Result, o Options) string

Result renders the whole report for one request, as `apic run` prints it.

func Section

func Section(t Theme, title string) string

Section renders a bold section title preceded by a blank line.

func Size

func Size(n int) string

Size formats a byte count.

func StatusLine

func StatusLine(t Theme, res *runner.Result) string

StatusLine renders "200 OK · 87 ms · 412 B"; when the request never got a response it renders the errors instead.

func Summary

func Summary(w io.Writer, results []*runner.Result)

Summary writes the per-request table and totals of a flow.

func SummaryLine

func SummaryLine(t Theme, results []*runner.Result) string

SummaryLine renders "3 passed", "1 failed, 3 passed" or "3 passed, 1 skipped".

func SummaryTable

func SummaryTable(t Theme, results []*runner.Result) string

SummaryTable renders one row per request followed by the totals line, for flows of more than one request.

func Timings

func Timings(t Theme, res *runner.Result) string

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".

func Truncate

func Truncate(s string, n int) string

Truncate flattens newlines and cuts s to n runes, appending an ellipsis.

func Variables

func Variables(t Theme, vars []runner.VarInfo, hints bool) string

Variables renders a variable table: name, value (masked when secret) and source, with hints for missing ones.

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 Default

func Default() Theme

Default is the theme apic ships with.

func (Theme) Latency

func (t Theme) Latency(ms int64) string

Latency renders a duration in milliseconds, coloured by how long it took.

func (Theme) Mark

func (t Theme) Mark(pass bool) string

Mark renders a pass or fail tick.

func (Theme) Method

func (t Theme) Method(m string) string

Method renders an HTTP method in its colour.

func (Theme) Status

func (t Theme) Status(code int, text string) string

Status renders "200 OK" coloured by status class.

func (Theme) StatusCode

func (t Theme) StatusCode(code int) string

StatusCode renders the status number on its own, coloured by class, for the places too narrow for the reason phrase.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL