Documentation
¶
Overview ¶
Package console is what a command says on stderr: its notes, warnings and errors, each an entry of one log; with --verbose, a debug line for each request; and, while a command waits on a terminal, the live line of the wait. A note is the bare sentence, as a script reading stderr has always seen it; a warning and an error carry their tags. --log-format says them as JSON or logfmt instead, an entry a line, each stamped with its time.
Index ¶
- func Underlying(stream io.Writer) io.Writer
- type Format
- type Look
- type Notes
- func (n Notes) Debug(sentence string)
- func (n Notes) DebugWriter() io.Writer
- func (n Notes) Fail(err error, status int)
- func (n Notes) Note(sentence string)
- func (n Notes) To(stream io.Writer) Notes
- func (n Notes) Unwatched(wait func(Wait) error) error
- func (n Notes) Warn(sentence string)
- func (n Notes) Watched(look Look, wait func(Wait) error) error
- func (n Notes) Writer() io.Writer
- type Options
- type Stream
- type Verbosity
- type Wait
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Format ¶
type Format int
Format is how the notes are written: as text, the sentences a person reads, or as JSON or logfmt, an entry a line for a log collector.
func ParseFormat ¶
ParseFormat is the format name names, as --log-format takes it.
type Look ¶ added in v0.12.0
Look is how a live line is drawn: in plain ASCII, for a terminal or font without the Unicode marks — ui.ascii, or status --plain — and still, its mark held rather than turning, for anyone motion distracts — ui.motion reduce.
type Notes ¶
type Notes struct {
// contains filtered or unexported fields
}
Notes is what a command says on stderr, through one log: a note about what it did, a warning about what it could not, the error it ended with, and, when verbose, a debug line about how it went. Copies share the log they were made with.
func New ¶
New is the notes said on stderr as opts asks, colored as the terminal there and the variables opts reads allow.
func (Notes) DebugWriter ¶
DebugWriter is the debug lines as a stream, for the request log's outlines: each line written to it is a debug line, its runs of spaces closed up and a leading RFC 3339 time dropped, since the log stamps its own entries where its format carries a time.
func (Notes) Fail ¶
Fail says err, the error the command ended with, and, in a structured format, the status it exits with, for a script reading the log to act on.
func (Notes) Note ¶
Note says sentence, a note about what the command did or found: on a pipe, the sentence alone. --quiet drops it.
func (Notes) To ¶
To is the notes said to stream instead, tagged and colored as they were: for a stream that passes on to the one they were made for, such as one that clears a line kept there first.
func (Notes) Unwatched ¶
Unwatched runs wait with no live line kept, for stderr that no person watches — a pipe, a file: what it does goes unsaid, and only what it says prints.
func (Notes) Warn ¶
Warn says sentence as a warning: the command goes on, but something it was asked for did not happen.
func (Notes) Watched ¶
Watched runs wait with a live line kept at the foot of stderr, a terminal a person watches, drawn as look asks: a mark, turning unless look holds it still, what the wait is doing, and, once it counts, a bar and how many of how many. Whatever is written to stderr while it runs, through these notes or a Stream they are said on, prints above the line, which is erased once the wait is over; the wait's error is Watched's.
The line is a Bubble Tea program, inline and taking no input, so it sends the terminal no query whose answer would reach the shell, and catching no signal, which the command's context hears instead. The wait runs as the program's first command, so nothing here starts a goroutine of its own, and the program ends when the wait does: a wait stopped by ctrl+c still says why before the line goes.
type Options ¶
Options are how a command's notes are said: in which format, how much of them, and Getenv, which reads the variables that decide color — NO_COLOR, CLICOLOR_FORCE, TERM and the like — which no note reads from the process itself. A nil Getenv reads none.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream is stderr as a command says everything on it: each write passed straight through, until a wait's live line is drawn there, when each is printed above the line instead, so nothing said lands on it — a note, a request's debug line from another goroutine, or a line written by code that knows only stderr.
type Wait ¶
type Wait struct {
// contains filtered or unexported fields
}
Wait is what a wait a person may be watching tells its live line — what it is doing, and how much of it is done — and where it says what it finds while the line is kept: its notes, and what it prints above the line.
func (Wait) Above ¶
Above is a stream printed above the live line, on stderr, a write at a time; with no line kept, it is the notes' stream, each line a note.
func (Wait) Counted ¶
Counted says how much of the wait is done: done of total, which the live line shows as a bar and in words.