ui

package
v0.0.0-...-5119c6c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package ui implements a simple terminal UI for showing concurrent operations.

Used to display the process of loading of remote packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivityDone

func ActivityDone(ctx context.Context, msg string, args ...any)

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

func ActivityError(ctx context.Context, msg string, args ...any)

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

func ActivityProgress(ctx context.Context, msg string, args ...any)

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

func ActivityStart(ctx context.Context, a *Activity, msg string, args ...any) context.Context

ActivityStart sets the given activity as the current in the context and marks it as running.

func NewActivityGroup

func NewActivityGroup(ctx context.Context, title string) (context.Context, context.CancelFunc)

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).

func WithConfig

func WithConfig(ctx context.Context, cfg Config) context.Context

WithConfig configures how activities will be displayed.

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.

type Config

type Config struct {
	Fancy bool     // if true, allow fancy terminal output instead of plain logging
	Term  *os.File // a terminal for fancy output (unused if Fancy == false)
}

Config lives in the context and defines how activities are displayed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL