Documentation
¶
Overview ¶
Package out provides the output formatting for the CLI
Index ¶
- func DisableColor()
- func GetShortDate(date string) string
- func InputSchema(v any) bool
- func IsJSON() bool
- func IsPretty() bool
- func IsSchemaMode() bool
- func Link(value string) string
- func LinkURL(value string) string
- func Log(pretty string)
- func Print(data any, pretty string)
- func PrintError(err error)
- func Schema(v any) bool
- func SetInputSchema(v bool)
- func SetOutput(o string) error
- func SetupTerminalLog()
- func StopTerminalLog()
- func Table(data any, tableMaker func() []string)
- func TagText(name string, hexRGB string) string
- type Message
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableColor ¶ added in v0.3.10
func DisableColor()
DisableColor disables color output called if the ESCAPE_NO_COLOR environment variable is set
func GetShortDate ¶ added in v0.3.0
GetShortDate returns the short date format of the given date
func InputSchema ¶ added in v1.0.0
InputSchema prints the JSON Schema for the input type and returns true if input-schema was requested Commands that accept stdin input should call this to show their expected input format
func IsJSON ¶
func IsJSON() bool
IsJSON reports whether stdout is reserved for a single JSON document.
func IsSchemaMode ¶ added in v1.0.0
func IsSchemaMode() bool
IsSchemaMode returns true if the output mode is schema
func LinkURL ¶ added in v1.4.0
LinkURL renders a hyperlink with the URL as visible text (for messages, not tables).
func Log ¶
func Log(pretty string)
Log prints a human-readable status line. JSON mode keeps a single stdout document. When Print or Table already wrote that document, the line goes to stderr. When Log is the only output, it prints {"msg":"..."} so `command -o json | jq` still works.
func Print ¶
Print prints the data in the output format. In JSON mode this is the command's one stdout document.
func PrintError ¶
func PrintError(err error)
PrintError writes the error chain to stderr. stdout stays the command document. A failed `scans watch -o json` prints one scan document there, then main exits 1 with this text on stderr.
func Schema ¶ added in v1.0.0
Schema prints the JSON Schema for the given type and returns true if in schema mode Commands should call this at the start and return early if it returns true
func SetInputSchema ¶ added in v1.0.0
func SetInputSchema(v bool)
SetInputSchema sets the input schema flag