Documentation
¶
Index ¶
- Constants
- func Display(jm jsonstream.Message, out io.Writer, isTerminal bool, width uint16) error
- func DisplayJSONMessages(messages JSONMessagesStream, out io.Writer, terminalFd uintptr, ...) error
- func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr, isTerminal bool, ...) error
- func RenderTUIProgress(p jsonstream.Progress, width uint16) string
- type JSONMessagesStream
Constants ¶
const RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
RFC3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to ensure the formatted time isalways the same number of characters.
Variables ¶
This section is empty.
Functions ¶
func Display ¶
Display prints the JSONMessage to out. If isTerminal is true, it erases the entire current line when displaying the progressbar. It returns an error if the [JSONMessage.Error] field is non-nil.
func DisplayJSONMessages ¶
func DisplayJSONMessages(messages JSONMessagesStream, out io.Writer, terminalFd uintptr, isTerminal bool, auxCallback func(jsonstream.Message)) error
DisplayJSONMessages writes each [JSONMessage] from stream to out. It returns an error if an invalid JSONMessage is received, or if a JSONMessage containers a non-zero [JSONMessage.Error].
Presentation of the JSONMessage depends on whether a terminal is attached, and on the terminal width. Progress bars ([JSONProgress]) are suppressed on narrower terminals (< 110 characters).
- isTerminal describes if out is a terminal, in which case it prints a newline ("\n") at the end of each line and moves the cursor while displaying.
- terminalFd is the fd of the current terminal (if any), and used to get the terminal width.
- auxCallback allows handling the [JSONMessage.Aux] field. It is called if a JSONMessage contains an Aux field, in which case DisplayJSONMessagesStream does not present the JSONMessage.
func DisplayJSONMessagesStream ¶
func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr, isTerminal bool, auxCallback func(jsonstream.Message)) error
DisplayJSONMessagesStream reads a JSON message stream from in, and writes each [JSONMessage] to out. see DisplayJSONMessages for details
func RenderTUIProgress ¶
func RenderTUIProgress(p jsonstream.Progress, width uint16) string
Types ¶
type JSONMessagesStream ¶
type JSONMessagesStream iter.Seq2[jsonstream.Message, error]