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 Body(w io.Writer, res *runner.Result)
- func Checks(t Theme, res *runner.Result, width int, expected bool) string
- func Describe(t Theme, d *runner.Description, headers []httpfile.Header) string
- func HighlightJSON(t Theme, s string) 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 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 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 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 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 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" or "1 failed, 3 passed".
func SummaryTable ¶
SummaryTable renders one row per request followed by the totals line, for flows of more than one request.
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.