Documentation
¶
Index ¶
- Constants
- func EventId(ctx context.Context) string
- func IsNoOp(ctx context.Context) bool
- func MaybeWriteError(ctx context.Context, err error) error
- func Start(ctx context.Context, title string)
- func Stop(ctx context.Context)
- func WithContextWriter(ctx context.Context, writer Writer) context.Context
- func WithEventId(ctx context.Context, id string) context.Context
- func Write(ctx context.Context, events ...*Event)
- type Event
- func BuildingEvent(id string) *Event
- func BuiltEvent(id string) *Event
- func Done(ctx context.Context, args ...any) *Event
- func DoneEvent(id, verb string) *Event
- func Donef(ctx context.Context, format string, args ...any) *Event
- func Error(ctx context.Context, args ...any) *Event
- func ErrorMessageEvent(id string, msg string) *Event
- func Errorf(ctx context.Context, format string, args ...any) *Event
- func Info(ctx context.Context, args ...any) *Event
- func InfoMessageEvent(id string, msg string) *Event
- func Infof(ctx context.Context, format string, args ...any) *Event
- func NewEvent(id string, status EventStatus, statusText string) *Event
- func PrintDone(ctx context.Context, args ...any) *Event
- func PrintDonef(ctx context.Context, format string, args ...any) *Event
- func StartedEvent(id string) *Event
- func StartingEvent(id string) *Event
- func StoppedEvent(id string) *Event
- func Warning(ctx context.Context, args ...any) *Event
- func WarningMessageEvent(id string, msg string) *Event
- func Warningf(ctx context.Context, format string, args ...any) *Event
- func Working(ctx context.Context, args ...any) *Event
- func WorkingEvent(id, verb string) *Event
- func Workingf(ctx context.Context, format string, args ...any) *Event
- type EventStatus
- type Mode
- type Writer
Constants ¶
const ( // ModeAuto detect console capabilities. ModeAuto = Mode("auto") // ModeTTY use terminal capability for advanced rendering. ModeTTY = Mode("tty") // ModePlain dump raw events to output. ModePlain = Mode("plain") // ModeQuiet don't display events. ModeQuiet = Mode("quiet") // ModeJSON outputs a machine-readable JSON stream. ModeJSON = Mode("json") )
Variables ¶
This section is empty.
Functions ¶
func WithContextWriter ¶
WithContextWriter adds the writer to the context.
func WithEventId ¶ added in v2.23.4
Types ¶
type Event ¶
type Event struct {
ID string `json:"id,omitempty"`
Text string `json:"text,omitempty"`
Status EventStatus `json:"status,omitempty"`
StatusText string `json:"statusText,omitempty"`
Current int64 `json:"current,omitempty"`
Percent int `json:"percent,omitempty"`
Total int64 `json:"total,omitempty"`
StartTime time.Time `json:"startTime,omitzero"`
EndTime time.Time `json:"endTime,omitzero"`
// contains filtered or unexported fields
}
Event represents a progress event.
func BuildingEvent ¶
BuildingEvent creates a new Building in progress Event.
func ErrorMessageEvent ¶
ErrorMessageEvent creates a new Error Event with a message.
func InfoMessageEvent ¶ added in v2.23.4
InfoMessageEvent creates a new Error Event with a message.
func PrintDone ¶ added in v2.23.4
PrintDone is like Done but also enforces that the plain writer will print the output. The plain writer normally skips Working and Done events.
func PrintDonef ¶ added in v2.23.4
PrintDonef is like Donef but also enforces that the plain writer will print the output. The plain writer normally skips Working and Done events.
func StartedEvent ¶
StartedEvent creates a new Started in progress Event.
func StartingEvent ¶
StartingEvent creates a new Starting in progress Event.
func StoppedEvent ¶
StoppedEvent creates a new Stopping in progress Event.
func WarningMessageEvent ¶ added in v2.23.4
WarningMessageEvent creates a new Error Event with a message.
func WorkingEvent ¶
WorkingEvent creates a new <verb> in progress Event.
func (*Event) AddChild ¶ added in v2.23.4
func (e *Event) AddChild(status EventStatus, text, statusText string) *Event
func (*Event) PlainAlways ¶ added in v2.23.4
PlainAlways configures the event to always be printed when using the plain progress writer.
type EventStatus ¶
type EventStatus int
EventStatus indicates the status of an action.
const ( EventStatusWorking EventStatus = iota EventStatusDone EventStatusInfo EventStatusWarning EventStatusError )
func (EventStatus) MarshalJSONTo ¶ added in v2.23.4
func (s EventStatus) MarshalJSONTo(out *jsontext.Encoder) error
func (EventStatus) String ¶ added in v2.23.4
func (s EventStatus) String() string
type Writer ¶
type Writer interface {
// Start will start the writer in a new goroutine
Start(ctx context.Context, progressTitle string)
// Stop stops a started spinner
Stop()
// IsNoOp returns true for the noop spinner, false for every other spinner.
IsNoOp() bool
// Write writes progress events. If multiple events are given and the writer permits it, they will
// end up in different spinners and be reported individually based on their ID.
Write(...*Event)
// TriggerRefresh triggers a refresh of event output on the tty writer
TriggerRefresh()
}
Writer can write multiple progress events.
func ContextWriter ¶
ContextWriter returns the writer from the context.