Documentation
¶
Overview ¶
Package ui implements a simple terminal UI for showing concurrent operations.
Used to display the process of loading of remote packages.
Index ¶
- func ActivityDone(ctx context.Context, msg string, args ...any)
- func ActivityError(ctx context.Context, msg string, args ...any)
- func ActivityProgress(ctx context.Context, msg string, args ...any)
- func ActivityStart(ctx context.Context, a *Activity, msg string, args ...any) context.Context
- func NewActivityGroup(ctx context.Context, title string) (context.Context, context.CancelFunc)
- func WithConfig(ctx context.Context, cfg Config) context.Context
- type Activity
- type ActivityInfo
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActivityDone ¶
ActivityDone closes the activity as finished successfully.
If `msg` is empty, will retain the last state reported via ActivityProgress, otherwise will override it.
Just logs the message if the context doesn't have an activity.
func ActivityError ¶
ActivityError closes the activity as failed.
If `msg` is empty, will retain the last state reported via ActivityProgress, otherwise will override it.
Just logs the message if the context doesn't have an activity.
func ActivityProgress ¶
ActivityProgress updates the state of the running activity in the context.
Just logs the message if the context doesn't have an activity.
func ActivityStart ¶
ActivityStart sets the given activity as the current in the context and marks it as running.
func NewActivityGroup ¶
NewActivityGroup returns a new context with a new activity group.
Call the returned context.CancelFunc to finalize the activity group when all activities are finished and no new activities are expected. This will also cancel the context (to make sure no new activities can run in the finalized group).
Types ¶
type Activity ¶
type Activity struct {
// contains filtered or unexported fields
}
Activity represents some process that runs concurrently in a group with other similar processes.
State of such concurrent activities will be displayed in a coordinated way via an ActivityGroup.
func NewActivity ¶
func NewActivity(ctx context.Context, info ActivityInfo) *Activity
NewActivity creates a new activity and registers it in the current activity group.
Does nothing (and returns a noop *Activity) if the context doesn't have an ActivityGroup set.
type ActivityInfo ¶
type ActivityInfo struct {
Package string // the package being worked on (required)
Version string // the version being worked on (or "" if not important)
}
ActivityInfo is a description of the activity.