Documentation
¶
Overview ¶
Package term renders tops output: errors, symbols, tables and JSON.
Index ¶
- func ColorEnabled(getenv func(string) string, isTerminal bool) bool
- func ExitCode(err error) int
- func Mark(s Symbol, unicode bool) string
- func Paint(text string, s Symbol, color bool) string
- func PrintError(w io.Writer, style Style, err error) error
- func UnicodeLocale(getenv func(string) string) bool
- func WriteErrorJSON(w io.Writer, version string, err error) error
- func WriteJSON(w io.Writer, doc any) error
- type Exit
- type Reported
- type Style
- type Symbol
- type UserError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColorEnabled ¶
ColorEnabled reports whether output may use colour: only on a terminal, and never when NO_COLOR is set or TERM is dumb.
func Mark ¶
Mark returns s as printed: a UTF-8 symbol, or a 4-character word when the locale is not UTF-8.
func PrintError ¶
PrintError writes err for the operator: what happened, why, and how to fix it.
func UnicodeLocale ¶
UnicodeLocale reports whether the locale allows UTF-8 output. LC_ALL overrides LC_CTYPE, which overrides LANG; the first one that is set decides.
func WriteErrorJSON ¶
WriteErrorJSON writes err as one JSON document of kind Error. Errors that are not a UserError get the code "unexpected".
Types ¶
type Exit ¶
type Exit struct {
Code int
}
Exit is an exit code a command chose itself, such as the helper's 0, 1 or 2
type Reported ¶
type Reported struct {
Err error
}
Reported wraps an error whose details a command has already written as its result, such as the Validation document of an invalid spec. main uses it only for the exit code.