status

package
v0.1.0-dev.20260902034506 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package status owns the side-channel for human-facing user-interface output.

This is the categorized narration stream that accompanies a tool's primary work.

The package's surface is the Narrator concrete type, which wraps a pkg/sink.Sink with the six categorized emission methods (Note, Warn, Error, Succeed, Fail, Print) and the program-name prefix. Color decoration is keyed off the sink's pkg/sink.Sink.IsTTY query — TTYs get ANSI color codes around the category symbol; non-TTYs get plain bytes.

Narrator emissions form a progress arc that conventionally concludes with Narrator.Succeed (positive resolution) or Narrator.Fail (negative resolution). The narration is event-stream in shape but story-shaped in semantic — successive Notes and Warns build context for the terminal Succeed/Fail.

Construction is immutable: callers pass program name + sink to NewNarrator once; no setters mutate the instance after construction. Silence is selected by passing pkg/sink.Discard as the sink, not by toggling a Narrator field.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Narrator

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

Narrator is the categorized narration wrapper.

Methods emit "[<programName>] [<colored symbol>] <msg>\n" through the configured sink.Sink; Narrator.Print emits the raw message followed by a newline, with no decoration. All fields are unexported and set at construction by NewNarrator; the value is immutable from the caller's perspective. Mid-run reconfiguration (writer redirect, program rename) requires constructing a new Narrator and replacing the runtime environment's Status reference.

Color decoration is keyed off sink.Sink.IsTTY at construction — true → wrap symbols in ANSI codes, false → plain bytes. To suppress all output, construct with sink.Discard as the sink.

func NewNarrator

func NewNarrator(programName string, s sink.Sink) *Narrator

NewNarrator constructs an immutable Narrator writing through the supplied sink.

Parameters:

  • `programName`: name shown in the "[program]" prefix on categorized messages (e.g., "lore").
  • `s`: the sink.Sink to write through. Must not be nil. Pass sink.Discard to suppress all narration; pass sink.Stderr for the standard cli case.

Returns:

  • `*Narrator`: the constructed value, ready to install on a runtime environment spec.

func (*Narrator) Error

func (n *Narrator) Error(msg string)

Error emits a non-fatal error status message in red.

Parameters:

  • `msg`: the error message to emit.

func (*Narrator) Fail

func (n *Narrator) Fail(msg string) error

Fail emits a fatal error status message in red and returns a Go error wrapping the message.

Parameters:

  • `msg`: the fatal-error message to emit.

Returns:

  • `error`: a non-nil error wrapping msg. Callers typically return this to abort the operation.

func (*Narrator) Note

func (n *Narrator) Note(msg string)

Note emits an informational status message in gray.

Parameters:

  • `msg`: the informational message to emit.

func (*Narrator) Print

func (n *Narrator) Print(msg string)

Print emits raw text followed by a newline.

No decoration; intended for starlark `print()` output where the script's exact bytes are what the user expects.

Parameters:

  • `msg`: the raw text to emit.

func (*Narrator) Succeed

func (n *Narrator) Succeed(msg string)

Succeed emits a positive-outcome status message in green.

Parameters:

  • `msg`: the success message to emit.

func (*Narrator) Warn

func (n *Narrator) Warn(msg string)

Warn emits a warning status message in yellow.

Parameters:

  • `msg`: the warning message to emit.

Jump to

Keyboard shortcuts

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