Documentation
¶
Overview ¶
Package ui is the presentation layer of the fxvcs CLI: headers, footers, aligned tables, item rows with a state word (and an optional symbol on a terminal), hints, byte formatting, and plural helpers. It holds no business logic and knows nothing about repositories; commands hand it already computed facts.
Index ¶
- func Bytes(n int64) string
- func Count(n int, noun string) string
- func Detect(mode string, w io.Writer, isTerminal func(io.Writer) bool) bool
- func IsTerminal(w io.Writer) bool
- func Plural(n int, one, many string) string
- func ShortID(digest string) string
- func SignedBytes(n int64) string
- func Size(w io.Writer) (width, height int, ok bool)
- type Item
- type Options
- type Printer
- func (p *Printer) Blank()
- func (p *Printer) Color() bool
- func (p *Printer) Footer(text string)
- func (p *Printer) Header(command, summary string)
- func (p *Printer) Hint(command string)
- func (p *Printer) Items(items []Item)
- func (p *Printer) Line(format string, args ...any)
- func (p *Printer) List(entries []string)
- func (p *Printer) Quiet() bool
- func (p *Printer) Table(rows [][]string)
- func (p *Printer) Verbose() bool
- func (p *Printer) Verbosef(format string, args ...any)
- func (p *Printer) Writer() io.Writer
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Detect ¶
Detect decides whether decoration is on: mode is "always", "never", or "auto" (the default: on when w is a terminal and NO_COLOR is unset).
func IsTerminal ¶
IsTerminal reports whether w is a character device (an interactive terminal) without any platform-specific system call.
func SignedBytes ¶
SignedBytes formats a size difference with its direction: "+2.4 MiB", "-1.1 MiB", or "same size" for a change that kept the byte count. It is what a managed asset has instead of a line count, because a diff of two placeholders says one line changed however many megabytes moved.
Types ¶
type Item ¶
Item is one row of a command body: a state, its label word, the repository-relative path, an already formatted size (or ""), and a note.
type Options ¶
type Options struct {
// Color enables ANSI colours and the state symbols. Callers decide from
// the terminal, NO_COLOR, and --color; see Detect.
Color bool
// Quiet suppresses everything except errors; renderers check Quiet
// before printing.
Quiet bool
// Verbose lets renderers add digests, codes, and internal paths.
Verbose bool
}
Options controls decoration and verbosity.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer writes formatted output to one writer.
func (*Printer) Header ¶
Header prints the first line of a command's output: "fxvcs <command> — <summary>".
func (*Printer) Items ¶
Items prints item rows as an aligned, two-space indented table: [symbol] label path size note.
func (*Printer) Table ¶
Table prints rows as aligned columns, two-space indented; the first row may be a header (callers pass it like any other row).