Documentation
¶
Index ¶
- Constants
- func Aux(out Output, a any)
- func Display(jm jsonstream.Message, out io.Writer, isTerminal bool, width uint16) error
- func DisplayJSONMessages(messages iter.Seq2[jsonstream.Message, error], out io.Writer, ...) error
- func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr, isTerminal bool, ...) error
- func DisplayMessages(messages iter.Seq2[jsonstream.Message, error], out io.Writer, ...) error
- func DisplayStream(in io.Reader, out io.Writer, opts ...DisplayOpt) error
- func Message(out Output, id, message string)
- func Messagef(out Output, id, format string, a ...any)
- func RenderTUIProgress(p jsonstream.Progress, width uint16) string
- func Update(out Output, id, action string)
- func Updatef(out Output, id, format string, a ...any)
- type DisplayOpt
- type JSONMessagesStream
- type Output
- type Progress
- type Reader
Constants ¶
const RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
RFC3339NanoFixed is time.RFC3339Nano with nanoseconds padded using zeros to ensure the formatted time is always the same number of characters.
Variables ¶
This section is empty.
Functions ¶
func Aux ¶
Aux sends auxiliary information over a progress interface, which will not be formatted for the UI. This is used for things such as push signing.
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 iter.Seq2[jsonstream.Message, error], out io.Writer, terminalFd uintptr, isTerminal bool, auxCallback func(jsonstream.Message)) error
DisplayJSONMessages is like DisplayMessages, but allows the caller to explicitly provide the terminal file descriptor and whether out is a terminal.
func DisplayJSONMessagesStream ¶
func DisplayJSONMessagesStream(in io.Reader, out io.Writer, terminalFd uintptr, isTerminal bool, auxCallback func(jsonstream.Message)) error
DisplayJSONMessagesStream is like DisplayStream, but allows the caller to explicitly provide the terminal file descriptor and whether out is a terminal.
func DisplayMessages ¶
func DisplayMessages(messages iter.Seq2[jsonstream.Message, error], out io.Writer, opts ...DisplayOpt) error
DisplayMessages writes each jsonstream.Message from stream to out. It returns an error if an invalid jsonstream.Message is received, or if a message contains a non-zero jsonstream.Message.Error.
func DisplayStream ¶
DisplayStream reads a JSON message stream from in, and writes each jsonstream.Message to out. See DisplayMessages for details.
func Messagef ¶
Messagef is a convenience function to write a printf-formatted progress message to the channel.
func RenderTUIProgress ¶
func RenderTUIProgress(p jsonstream.Progress, width uint16) string
Types ¶
type DisplayOpt ¶
type DisplayOpt func(*displayOpts) error
DisplayOpt configures behavior for DisplayStream and DisplayMessages. Options are applied in order; if an option returns an error, processing stops and the error is returned to the caller.
func WithAuxCallback ¶
func WithAuxCallback(fn func(jsonstream.Message)) DisplayOpt
WithAuxCallback registers a callback that is invoked for auxiliary jsonstream messages as they are processed. The callback is optional; if not provided, auxiliary messages are ignored.
type JSONMessagesStream ¶
type JSONMessagesStream = iter.Seq2[jsonstream.Message, error]
type Output ¶
Output is an interface for writing progress information. It's like a writer for progress, but we don't call it Writer because that would be confusing next to ProgressReader (also, because it doesn't implement the io.Writer interface).
func ChanOutput ¶
ChanOutput returns an Output that writes progress updates to the supplied channel.
func DiscardOutput ¶
func DiscardOutput() Output
DiscardOutput returns an Output that discards progress
func NewJSONProgressOutput ¶
NewJSONProgressOutput returns a progress.Output that formats output using JSON objects
func NewProgressOutput ¶
NewProgressOutput returns a progress.Output object that can be passed to progress.NewProgressReader.
type Progress ¶
type Progress struct {
ID string
// Progress contains a Message or...
Message string
// ...progress of an action
Action string
Current int64
Total int64
// If true, don't show xB/yB
HideCounts bool
// If not empty, use units instead of bytes for counts
Units string
// Aux contains extra information not presented to the user, such as
// digests for push signing.
Aux any
LastUpdate bool
}
Progress represents the progress of a transfer.