tui

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package tui holds the look that every command shares: the styles, the help page, and the error block. A form, a spinner, or a progress bar joins it with the first command that needs one.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Help

func Help(p HelpPage) string

Help renders a help page, which ends with its examples. Columns take the width of the translated text.

func Output

func Output(w io.Writer, noColor bool) io.Writer

Output wraps a stream so that styles become plain text when color is off. noColor turns color off even with CLICOLOR_FORCE. Otherwise a stream that is not a terminal gets plain text unless CLICOLOR_FORCE asks for color. The decision reads only the environment and the stream, and never queries the terminal.

func Problems

func Problems(errs, warnings []contract.Problem, label func(code contract.Code, warning bool) string, hint string) string

Problems renders errors, then warnings. Each one leads with a label that carries its code, such as error[USAGE_INVALID]:, then shows its hint after the hint label. label returns the translated label of a code.

Types

type Entry

type Entry struct {
	Name    string
	Summary string
}

Entry is one line of a list: a command or a flag, then its summary.

type HelpPage

type HelpPage struct {
	Summary       string
	UsageTitle    string
	Usage         string
	Sections      []Section
	ExamplesTitle string
	Examples      []string
}

HelpPage is a help page, already in the active language.

type Section

type Section struct {
	Title   string
	Entries []Entry
	// Colon follows each name with a colon, as for commands.
	Colon bool
}

Section is a titled list of entries.

Jump to

Keyboard shortcuts

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