progress

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package progress provides structured status reporting for the derive flow.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Provider string // provider type, e.g. "ssh-agent", "fido2"
	ID       string // provider config ID, e.g. "fido2-1"
	Status   Status
	Message  string // e.g. "waiting for touch...", "no keys loaded", "timeout"
}

Event is emitted to report provider progress during derivation.

type Status

type Status int

Status represents a provider's current state during derivation.

const (
	StatusRunning   Status = iota // in progress
	StatusWaiting                 // blocking on hardware touch/browser
	StatusSucceeded               // derived successfully
	StatusSkipped                 // skipped with a reason
	StatusFailed                  // failed with an error
)

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer formats and emits progress lines to an io.Writer (typically stderr).

func New

func New(w io.Writer, isTTY, noTUI, quiet bool) *Writer

New creates a Writer.

isTTY indicates whether the writer's target is a terminal. noTUI, if true, forces plain-line output even on a TTY (script mode). quiet suppresses all non-fatal output.

When both isTTY and !noTUI are true, the Writer renders colors, in-place countdowns, and raw-mode inline prompts. Otherwise it falls back to plain stdin reads and line-based output.

func (*Writer) Countdown

func (pw *Writer) Countdown(providerName, waitingMsg, detail string, remaining time.Duration)

Countdown overwrites the current line with a provider-specific waiting message followed by the remaining seconds. When detail is non-empty it is embedded inline next to the message with an arrow separator ("waiting for browser → http://localhost:N/") so the actionable text is obvious without the user having to scan to the edge of the terminal. The hint ("esc skip • ctrl+c quit") is kept when it fits, dropped when the line would overflow. No-op when the output isn't interactive.

func (*Writer) Emit

func (pw *Writer) Emit(e Event)

Emit writes a progress event as a single line. In interactive mode the committed statuses (Succeeded / Failed / Skipped) clear any pending transient line with \r\033[2K first, so they don't visually collide with a Waiting event or countdown that lacked a trailing newline.

func (*Writer) Fatal

func (pw *Writer) Fatal(msg string)

Fatal writes an error message regardless of quiet mode.

func (*Writer) FinishLine

func (pw *Writer) FinishLine()

FinishLine clears the current in-place line and moves to a new line, so the next Emit starts clean. Call after a waiting/countdown sequence.

func (*Writer) Info

func (pw *Writer) Info(msg string)

Info writes a message on its own line, clearing any in-progress countdown line first so the output doesn't collide. The countdown ticker will re-paint on its next tick.

func (pw *Writer) Link(prefix, url string)

Link writes a labeled URL where the URL portion is rendered in dim styling on interactive terminals.

func (*Writer) PromptLine

func (pw *Writer) PromptLine(providerType, label, hint string) (string, error)

PromptLine prompts for a plain echoed line (e.g. a file path).

func (*Writer) PromptPassword

func (pw *Writer) PromptPassword(providerType, label, hint string) (string, error)

PromptPassword prompts for a secret with masked bullets. hint is rendered in dim text next to the label (e.g. "esc to skip") and may be empty.

func (*Writer) Starting

func (pw *Writer) Starting(providerName, id, msg string)

Starting emits a committed "starting" line for a provider. Used by flows (rekey's enroll phase, for example) that kick off a provider operation the provider itself may annotate with direct stderr writes. Committing the line immediately means those provider writes don't smear into our formatted prefix.

Jump to

Keyboard shortcuts

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