Documentation
¶
Overview ¶
Package laslig provides helpers for attractive, structured terminal output in Go CLI tools.
Laslig is designed to sit above low-level styling and layout primitives and below command frameworks. It focuses on ordinary command output such as sections, notices, records, KV blocks, lists, tables, panels, paragraphs, status lines, transient spinners, Markdown blocks, code blocks, and log blocks.
The package is intentionally small and data-oriented. Callers provide an io.Writer and a Policy, then render semantic blocks through a Printer. Policy may also carry a Layout when a command wants to tune the default document rhythm, section indentation, or list marker shape, a Theme when one command wants to swap the default styles directly, or a built-in spinner style when one command wants a different transient progress frame set. Laslig does not own logging, command parsing, or process lifecycle. Callers may render explicit log excerpts or transcripts through laslig, but logging policy and sinks remain application concerns.
Policy resolution supports three useful surfaces:
- human output for terminals
- plain text for non-terminal writers
- JSON payloads for machine-readable consumers
A specialist gotestout package provides structured rendering for go test -json streams in Mage targets, ordinary Go CLI commands, and small Go helpers invoked from tools such as make or just, including an optional live spinner footer for styled human terminals while a test stream is active.
Index ¶
- type CodeBlock
- type Field
- type Format
- type GlamourStyle
- type KV
- type Layout
- type List
- type ListItem
- type ListMarker
- type LogBlock
- type Markdown
- type Mode
- type Notice
- type NoticeLevel
- type Panel
- type Paragraph
- type Policy
- type Printer
- func (p *Printer) CodeBlock(block CodeBlock) error
- func (p *Printer) KV(kv KV) error
- func (p *Printer) List(list List) error
- func (p *Printer) LogBlock(block LogBlock) error
- func (p *Printer) Markdown(block Markdown) error
- func (p *Printer) Mode() Mode
- func (p *Printer) NewSpinner() *Spinner
- func (p *Printer) NewSpinnerWithStyle(style SpinnerStyle) *Spinner
- func (p *Printer) Notice(notice Notice) error
- func (p *Printer) Panel(panel Panel) error
- func (p *Printer) Paragraph(paragraph Paragraph) error
- func (p *Printer) Record(record Record) error
- func (p *Printer) Section(title string) error
- func (p *Printer) StatusLine(line StatusLine) error
- func (p *Printer) Table(table Table) error
- type Record
- type Spinner
- type SpinnerStyle
- type StatusLine
- type StylePolicy
- type Table
- type TableWrapMode
- type Theme
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodeBlock ¶
type CodeBlock struct {
Title string `json:"title,omitempty"`
Language string `json:"language,omitempty"`
Body string `json:"body"`
// MaxWidth caps the total frame width (content + frame) in styled human
// mode. When omitted, the block shrinks toward content width, stays within
// the available terminal width, and uses Läslig's readable default cap.
MaxWidth int `json:"maxWidth,omitempty"`
// WrapMode controls how long block text is compacted when constrained.
WrapMode TableWrapMode `json:"wrapMode,omitempty"`
}
CodeBlock describes one titled code-style block with optional language hinting.
type Field ¶
type Field struct {
Label string `json:"label"`
Value string `json:"value"`
Identifier bool `json:"identifier,omitempty"`
Muted bool `json:"muted,omitempty"`
Badge bool `json:"badge,omitempty"`
}
Field describes one labeled value in records and list items.
type Format ¶
type Format string
Format identifies the output representation used for a render operation.
const ( // FormatAuto resolves to a human-oriented format on terminals and plain text otherwise. FormatAuto Format = "auto" // FormatHuman renders human-oriented structured output. FormatHuman Format = "human" // FormatPlain renders plain text without terminal styling. FormatPlain Format = "plain" // FormatJSON renders machine-readable JSON payloads. FormatJSON Format = "json" )
type GlamourStyle ¶
type GlamourStyle string
GlamourStyle identifies one supported built-in Glamour style preset.
Supported built-ins are dark, light, pink, dracula, tokyo-night, ascii, and notty.
const ( // GlamourStyleDark renders Markdown with Glamour's dark preset. GlamourStyleDark GlamourStyle = "dark" // GlamourStyleLight renders Markdown with Glamour's light preset. GlamourStyleLight GlamourStyle = "light" // GlamourStylePink renders Markdown with Glamour's pink preset. GlamourStylePink GlamourStyle = "pink" // GlamourStyleDracula renders Markdown with Glamour's Dracula preset. GlamourStyleDracula GlamourStyle = "dracula" // GlamourStyleTokyoNight renders Markdown with Glamour's Tokyo Night preset. GlamourStyleTokyoNight GlamourStyle = "tokyo-night" // GlamourStyleASCII renders Markdown with Glamour's ASCII preset. GlamourStyleASCII GlamourStyle = "ascii" // GlamourStyleNoTTY renders Markdown with Glamour's no-TTY preset. GlamourStyleNoTTY GlamourStyle = "notty" )
func DefaultGlamourStyle ¶
func DefaultGlamourStyle() GlamourStyle
DefaultGlamourStyle returns the default built-in Glamour style used by laslig, which is dracula.
func (GlamourStyle) Valid ¶
func (s GlamourStyle) Valid() bool
Valid reports whether the style matches one of laslig's supported built-in Glamour presets.
type KV ¶
type KV struct {
Title string `json:"title,omitempty"`
Pairs []Field `json:"pairs,omitempty"`
Empty string `json:"empty,omitempty"`
}
KV describes one aligned key-value block.
type Layout ¶
type Layout struct {
// contains filtered or unexported fields
}
Layout describes the high-level document rhythm used by one printer.
Use DefaultLayout as a base, then override individual values with the builder-style helpers when a command wants a different shape.
func DefaultLayout ¶
func DefaultLayout() Layout
DefaultLayout returns the opinionated default document layout used by laslig.
func (Layout) WithBlockGap ¶
WithBlockGap returns one layout with an updated ordinary block gap.
func (Layout) WithLeadingGap ¶
WithLeadingGap returns one layout with an updated leading gap.
func (Layout) WithListMarker ¶
func (l Layout) WithListMarker(marker ListMarker) Layout
WithListMarker returns one layout with an updated list marker style.
func (Layout) WithSectionGap ¶
WithSectionGap returns one layout with an updated section gap.
func (Layout) WithSectionIndent ¶
WithSectionIndent returns one layout with an updated section-body indent.
type List ¶
type List struct {
Title string `json:"title"`
Items []ListItem `json:"items,omitempty"`
Empty string `json:"empty,omitempty"`
}
List describes one titled list block.
type ListItem ¶
type ListItem struct {
Title string `json:"title"`
Badge string `json:"badge,omitempty"`
Fields []Field `json:"fields,omitempty"`
}
ListItem describes one item in a rendered list.
type ListMarker ¶
type ListMarker string
ListMarker identifies the marker shape used for unordered and ordered list output.
const ( // ListMarkerDash renders list items with a dash marker. ListMarkerDash ListMarker = "dash" // ListMarkerBullet renders list items with a bullet marker. ListMarkerBullet ListMarker = "bullet" // ListMarkerNumber renders list items with an ordinal marker. ListMarkerNumber ListMarker = "number" )
type LogBlock ¶
type LogBlock struct {
Title string `json:"title,omitempty"`
Body string `json:"body"`
// MaxWidth caps the total frame width (content + frame) in styled human
// mode. When omitted, the block shrinks toward content width, stays within
// the available terminal width, and uses Läslig's readable default cap.
MaxWidth int `json:"maxWidth,omitempty"`
// WrapMode controls how long block text is compacted when constrained.
WrapMode TableWrapMode `json:"wrapMode,omitempty"`
}
LogBlock describes one titled boxed transcript or log excerpt.
type Mode ¶
Mode describes the resolved output behavior for one writer, including the detected terminal width when available.
type Notice ¶
type Notice struct {
Level NoticeLevel `json:"level"`
Title string `json:"title,omitempty"`
Body string `json:"body,omitempty"`
Detail []string `json:"detail,omitempty"`
}
Notice describes one user-facing diagnostic block.
type NoticeLevel ¶
type NoticeLevel string
NoticeLevel identifies one user-facing diagnostic level.
const ( // NoticeInfoLevel identifies informational notices. NoticeInfoLevel NoticeLevel = "info" // NoticeSuccessLevel identifies success notices. NoticeSuccessLevel NoticeLevel = "success" // NoticeWarningLevel identifies warning notices. NoticeWarningLevel NoticeLevel = "warning" // NoticeErrorLevel identifies error notices. NoticeErrorLevel NoticeLevel = "error" )
type Panel ¶
type Panel struct {
Title string `json:"title,omitempty"`
Body string `json:"body"`
// MaxWidth caps the total panel width (content + border/padding) in human
// mode. When omitted, the panel shrinks toward content width, stays within
// the available terminal width, and uses Läslig's readable default cap.
MaxWidth int `json:"maxWidth,omitempty"`
// WrapMode controls how long panel body/footer lines are compacted.
WrapMode TableWrapMode `json:"wrapMode,omitempty"`
}
Panel describes one titled boxed block.
type Policy ¶
type Policy struct {
// Format selects the overall render format.
Format Format
// Style controls ANSI styling for human output.
Style StylePolicy
// Layout overrides the default document spacing and indentation rules.
Layout *Layout
// Theme overrides the printer-wide lipgloss style roles.
Theme *Theme
// SpinnerStyle selects the built-in transient spinner frame set used by
// Printer.NewSpinner. Supported values are braille, dot, line, pulse, and
// meter. The default is braille.
SpinnerStyle SpinnerStyle
// GlamourStyle selects the built-in Glamour preset used for Markdown and
// code-block rendering. Supported values are dark, light, pink, dracula,
// tokyo-night, ascii, and notty. The default is dracula.
GlamourStyle GlamourStyle
}
Policy describes the requested output behavior before writer capabilities are resolved.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer renders structured output to one writer.
func NewWithMode ¶
NewWithMode constructs one printer using an already-resolved output mode.
NewWithMode is a convenience for callers that already resolved the output mode and are happy with the default Layout and Theme for that mode.
func (*Printer) CodeBlock ¶
CodeBlock writes one titled code-style block.
Example ¶
ExamplePrinter_CodeBlock shows one plain code block without ANSI styling.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
_ = printer.CodeBlock(laslig.CodeBlock{
Title: "Snippet",
Language: "go",
Body: "fmt.Println(\"hello from laslig\")",
Footer: "Use CodeBlock for commands or code samples.",
})
}
Output: Snippet fmt.Println("hello from laslig") Use CodeBlock for commands or code samples.
func (*Printer) KV ¶
KV writes one aligned key-value block.
Example ¶
ExamplePrinter_KV shows aligned key-value rendering.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
_ = printer.KV(laslig.KV{
Title: "Config",
Pairs: []laslig.Field{
{Label: "module", Value: "github.com/evanmschultz/laslig", Identifier: true},
{Label: "style", Value: "auto", Badge: true},
{Label: "runner", Value: "mage", Muted: true},
},
})
}
Output: Config module github.com/evanmschultz/laslig style [AUTO] runner mage
func (*Printer) List ¶
List writes one titled list block.
Example ¶
ExamplePrinter_List shows grouped list items with badges and detail fields.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
_ = printer.List(laslig.List{
Title: "Targets",
Items: []laslig.ListItem{
{
Title: "check",
Badge: "ready",
Fields: []laslig.Field{
{Label: "when", Value: "Run verification before handoff."},
},
},
{
Title: "demo",
Badge: "live",
Fields: []laslig.Field{
{Label: "what", Value: "Show the all-in-one walkthrough."},
},
},
},
})
}
Output: Targets - check [READY] when: Run verification before handoff. - demo [LIVE] what: Show the all-in-one walkthrough.
func (*Printer) LogBlock ¶
LogBlock writes one titled boxed transcript or log excerpt.
Example ¶
ExamplePrinter_LogBlock shows one plain boxed-log surface without owning logging.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
_ = printer.LogBlock(laslig.LogBlock{
Title: "stderr excerpt",
Body: "INFO boot complete\nWARN retry scheduled",
})
}
Output: stderr excerpt INFO boot complete WARN retry scheduled
func (*Printer) Markdown ¶
Markdown writes one Markdown block.
Example ¶
ExamplePrinter_Markdown shows one Markdown block rendered as source in plain mode.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
_ = printer.Markdown(laslig.Markdown{
Body: "# Notes\n\n- first\n- second",
})
}
Output: # Notes - first - second
func (*Printer) NewSpinner ¶ added in v0.2.0
NewSpinner constructs one opt-in transient progress helper bound to the printer's resolved mode, layout, theme, and default spinner style.
Styled human terminals animate one transient line in place. Plain output, human output with StyleNever, and JSON output degrade to stable start/finish status records without transient frames.
Example ¶
ExamplePrinter_NewSpinner shows one spinner falling back to stable status rows in plain output.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
spin := printer.NewSpinner()
_ = spin.Start("Waiting for rollout")
_ = spin.Stop("Rollout ready", laslig.NoticeSuccessLevel)
}
Output: [RUNNING] Waiting for rollout [SUCCESS] Rollout ready
func (*Printer) NewSpinnerWithStyle ¶ added in v0.2.1
func (p *Printer) NewSpinnerWithStyle(style SpinnerStyle) *Spinner
NewSpinnerWithStyle constructs one opt-in transient progress helper bound to the printer, using one specific built-in spinner frame set.
Supported styles are braille, dot, line, pulse, and meter. Invalid values fall back to the default braille style.
Example ¶
ExamplePrinter_NewSpinnerWithStyle shows one spinner using an explicit built-in frame set.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
spin := printer.NewSpinnerWithStyle(laslig.SpinnerStyleLine)
_ = spin.Start("Waiting for rollout")
_ = spin.Stop("Rollout ready", laslig.NoticeSuccessLevel)
}
Output: [RUNNING] Waiting for rollout [SUCCESS] Rollout ready
func (*Printer) Notice ¶
Notice writes one user-facing notice block.
Example ¶
ExamplePrinter_Notice shows one warning notice rendered without ANSI styling.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
_ = printer.Notice(laslig.Notice{
Level: laslig.NoticeWarningLevel,
Title: "Coverage dropped",
Body: "Package coverage fell below the configured threshold.",
Detail: []string{
"Previous: 84.2%",
"Current: 79.8%",
},
})
}
Output: [WARNING] Coverage dropped Package coverage fell below the configured threshold. Previous: 84.2% Current: 79.8%
func (*Printer) Panel ¶
Panel writes one titled panel block.
Example ¶
ExamplePrinter_Panel shows one stronger callout block in plain mode.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
_ = printer.Panel(laslig.Panel{
Title: "Next step",
Body: "Run mage check before pushing.",
Footer: "Use Panel when the note should stand apart from the surrounding document.",
})
}
Output: Next step Run mage check before pushing. Use Panel when the note should stand apart from the surrounding document.
func (*Printer) Paragraph ¶
Paragraph writes one wrapped long-form text block.
Example ¶
ExamplePrinter_Paragraph shows one wrapped long-form text block in plain mode.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
_ = printer.Paragraph(laslig.Paragraph{
Title: "Why",
Body: "Laslig keeps ordinary command output readable without forcing a framework.",
Footer: "Writers in, errors out.",
})
}
Output: Why Laslig keeps ordinary command output readable without forcing a framework. Writers in, errors out.
func (*Printer) Record ¶
Record writes one titled record block.
Example ¶
ExamplePrinter_Record shows one simple record render with plain output.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
_ = printer.Record(laslig.Record{
Title: "Build",
Fields: []laslig.Field{
{Label: "status", Value: "pass", Badge: true},
{Label: "runner", Value: "mage", Muted: true},
},
})
}
Output: Build status: [PASS] runner: mage
func (*Printer) Section ¶
Section writes one section heading and opens section-owned indentation for following content blocks until the next section heading.
Example ¶
ExamplePrinter_Section shows one section heading owning the indentation of the blocks that follow it.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
_ = printer.Section("Overview")
_ = printer.Record(laslig.Record{
Title: "Record",
Fields: []laslig.Field{
{Label: "what", Value: "Use Section when later blocks should clearly read as one document group."},
},
})
}
Output: Overview Record what: Use Section when later blocks should clearly read as one document group.
func (*Printer) StatusLine ¶
func (p *Printer) StatusLine(line StatusLine) error
StatusLine writes one compact semantic single-line status row.
Example ¶
ExamplePrinter_StatusLine shows one compact status row in plain mode.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
_ = printer.StatusLine(laslig.StatusLine{
Level: laslig.NoticeSuccessLevel,
Text: "Build ready",
Detail: "mage check",
})
}
Output: [SUCCESS] Build ready (mage check)
func (*Printer) Table ¶
Table writes one titled table block.
Example ¶
ExamplePrinter_Table shows one plain table render for stable text output.
package main
import (
"os"
"github.com/evanmschultz/laslig"
)
// newExamplePrinter constructs one plain printer without the default leading gap
// so package examples stay compact in rendered Go docs.
func newExamplePrinter() *laslig.Printer {
layout := laslig.DefaultLayout().WithLeadingGap(0)
return laslig.New(os.Stdout, laslig.Policy{
Format: laslig.FormatPlain,
Style: laslig.StyleNever,
Layout: &layout,
})
}
func main() {
printer := newExamplePrinter()
_ = printer.Table(laslig.Table{
Title: "Targets",
Header: []string{"name", "status"},
Rows: [][]string{
{"check", "ready"},
{"demo", "ready"},
},
Caption: "One policy, three surfaces.",
})
}
Output: Targets name | status ------+------- check | ready demo | ready One policy, three surfaces.
type Spinner ¶ added in v0.2.0
type Spinner struct {
// contains filtered or unexported fields
}
Spinner renders one opt-in transient progress line for long-running work.
Use Spinner when a CLI might otherwise be silent for several seconds and a caller wants a lightweight "still running" signal. Prefer StatusLine or Notice when work starts and finishes quickly enough that durable structured output is enough.
Spinner does not own process lifecycle, cancellation, or retries. Callers should stop a spinner before writing other laslig blocks to the same writer.
func (*Spinner) Start ¶ added in v0.2.0
Start begins rendering one transient progress line or one stable fallback start record when animation is not appropriate for the resolved output mode.
Styled human output animates one in-place line. Plain output, unstyled human output, and JSON output emit one durable start record instead.
func (*Spinner) Stop ¶ added in v0.2.0
func (s *Spinner) Stop(message string, level NoticeLevel) error
Stop finalizes one running spinner with one durable status line or JSON status record.
When message is empty, Stop reuses the most recent spinner text. If level is empty, Stop defaults to NoticeSuccessLevel. Stop is safe to call even when a delayed-start caller never started the spinner.
func (*Spinner) Update ¶ added in v0.2.0
Update replaces the current spinner text while work is still running.
Updates redraw the transient line on styled human terminals. In plain, unstyled human, and JSON modes, Update records the latest text but does not emit additional output. Call Start before Update.
type SpinnerStyle ¶ added in v0.2.1
type SpinnerStyle string
SpinnerStyle identifies one supported built-in spinner frame set.
Supported built-ins are braille, dot, line, pulse, and meter.
const ( // SpinnerStyleBraille renders the default braille-dot spinner. SpinnerStyleBraille SpinnerStyle = "braille" // SpinnerStyleDot renders a larger dot spinner. SpinnerStyleDot SpinnerStyle = "dot" // SpinnerStyleLine renders a compact ASCII-friendly line spinner. SpinnerStyleLine SpinnerStyle = "line" // SpinnerStylePulse renders a pulsing dot spinner. SpinnerStylePulse SpinnerStyle = "pulse" // SpinnerStyleMeter renders a meter-like spinner. SpinnerStyleMeter SpinnerStyle = "meter" )
func DefaultSpinnerStyle ¶ added in v0.2.1
func DefaultSpinnerStyle() SpinnerStyle
DefaultSpinnerStyle returns the default built-in spinner style used by laslig, which is braille.
func (SpinnerStyle) Valid ¶ added in v0.2.1
func (s SpinnerStyle) Valid() bool
Valid reports whether the style matches one of laslig's supported built-in spinner styles.
type StatusLine ¶
type StatusLine struct {
Level NoticeLevel `json:"level,omitempty"`
Label string `json:"label,omitempty"`
Text string `json:"text"`
Detail string `json:"detail,omitempty"`
}
StatusLine describes one compact semantic status row.
type StylePolicy ¶
type StylePolicy string
StylePolicy controls whether ANSI styling is enabled for human output.
const ( // StyleAuto enables styling only when output is attached to a terminal. StyleAuto StylePolicy = "auto" // StyleAlways forces styling for human output. StyleAlways StylePolicy = "always" // StyleNever disables styling. StyleNever StylePolicy = "never" )
type Table ¶
type Table struct {
Title string `json:"title"`
Header []string `json:"header,omitempty"`
Rows [][]string `json:"rows,omitempty"`
Caption string `json:"caption,omitempty"`
Empty string `json:"empty,omitempty"`
// MaxWidth clamps styled table width (content + frame) when rendering in
// human mode. When omitted, the table shrinks toward content width, stays
// within the available terminal width, and uses Läslig's readable default
// cap.
MaxWidth int `json:"maxWidth,omitempty"`
// WrapMode controls how long table content is compacted in constrained
// widths.
WrapMode TableWrapMode `json:"wrapMode,omitempty"`
}
Table describes one titled table block.
type TableWrapMode ¶ added in v0.2.4
type TableWrapMode string
TableWrapMode controls how long framed structured text is compacted in constrained widths.
const ( // TableWrapAuto wraps where possible and rebalances structured content to // fit the available width. TableWrapAuto TableWrapMode = "auto" // TableWrapNever keeps each logical line unwrapped and truncates if needed. // Today this matches TableWrapTruncate intentionally; the separate name keeps // the API semantics explicit for callers that want to state "do not wrap". TableWrapNever TableWrapMode = "never" // TableWrapTruncate truncates long values without wrapping. Today this // behaves the same as TableWrapNever and differs mainly in caller intent. TableWrapTruncate TableWrapMode = "truncate" )
type Theme ¶
type Theme struct {
Section lipgloss.Style
Label lipgloss.Style
Value lipgloss.Style
Identifier lipgloss.Style
Muted lipgloss.Style
Badge lipgloss.Style
Panel lipgloss.Style
TableHeader lipgloss.Style
TableRule lipgloss.Style
NoticeInfo lipgloss.Style
NoticeSuccess lipgloss.Style
NoticeWarning lipgloss.Style
NoticeError lipgloss.Style
}
Theme contains the styles used by one printer.
func DefaultTheme ¶
DefaultTheme returns the default theme for one resolved output mode.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
all
command
|
|
|
codeblock
command
|
|
|
gotestout
command
|
|
|
kv
command
|
|
|
list
command
|
|
|
logblock
command
|
|
|
magecheck
command
|
|
|
markdown
command
|
|
|
notice
command
|
|
|
panel
command
|
|
|
paragraph
command
|
|
|
record
command
|
|
|
section
command
|
|
|
spinner
command
|
|
|
statusline
command
|
|
|
table
command
|
|
|
Package gotestout renders go test -json streams using laslig output primitives and the library's normal terminal styling behavior.
|
Package gotestout renders go test -json streams using laslig output primitives and the library's normal terminal styling behavior. |
|
internal
|
|















