Documentation
¶
Index ¶
- func Bold(s string) string
- func Dim(s string) string
- func EscapePlainField(value string) string
- func Green(s string) string
- func ImageEnabled() bool
- func IsBrokenPipeError(err error) bool
- func IsTTY() bool
- func PrintJSON(w io.Writer, data json.RawMessage, jqExpr string) error
- func PrintJSONStream(w io.Writer, key string, writeItems func(func(any) error) error) error
- func PrintJSONStreamWithJQ(w io.Writer, key, jqExpr string, writeItems func(func(any) error) error) error
- func PrintPlain(w io.Writer, rows [][]string) error
- func Red(s string) string
- func RenderImage(w io.Writer, imageURL string, maxWidth int)
- func RenderImageWithContext(ctx context.Context, w io.Writer, imageURL string, maxWidth int)
- func ResetColorEnabledForTesting()
- func ResetStdoutIsTerminalForTesting()
- func SetColorEnabledForTesting(enabled bool)
- func SetStdoutIsTerminalForTesting(enabled bool)
- func StreamJSONArrayEnvelope(w io.Writer, key string, writeItems func(func(any) error) error) error
- func TerminalWidth(defaultWidth int) int
- func TerminalWidthFor(w io.Writer, defaultWidth int) int
- func WithPager(stdout, stderr io.Writer, fn func(io.Writer) error) error
- func WriteJSONStreamTo(w io.Writer, key string, writeItems func(func(any) error) error) error
- func Writef(w io.Writer, format string, args ...any) error
- func Writeln(w io.Writer, args ...any) error
- func Yellow(s string) string
- type Pager
- type Spinner
- type Styler
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapePlainField ¶ added in v0.3.0
EscapePlainField escapes control characters in value so it can be rendered safely on a single line. Used by both --plain output and the styled --dry-run preview so an embedded newline does not break the layout.
func ImageEnabled ¶
func ImageEnabled() bool
ImageEnabled returns whether image rendering is enabled (follows color gate).
func IsBrokenPipeError ¶
IsBrokenPipeError reports whether err represents a closed downstream pipe.
func PrintJSONStream ¶
PrintJSONStream keeps the same atomic-output contract as PrintJSONStreamWithJQ for user-visible `--all --json` flows.
func PrintJSONStreamWithJQ ¶
func PrintJSONStreamWithJQ(w io.Writer, key, jqExpr string, writeItems func(func(any) error) error) error
PrintJSONStreamWithJQ stages user-visible output before copying it to the final writer. This is intentional: `gumroad ... --all --jq ...` must fail atomically so late pagination/jq errors never leave partial machine-readable output on stdout. Do not switch this back to direct stdout streaming unless the CLI contract changes.
func RenderImage ¶
RenderImage downloads an image from imageURL and writes ANSI half-block pixel art to w, fitting within maxWidth terminal columns. Silent no-op on any failure — this is purely decorative.
func RenderImageWithContext ¶
RenderImageWithContext downloads an image from imageURL and writes ANSI half-block pixel art to w, fitting within maxWidth terminal columns. Silent no-op on any failure — this is purely decorative.
func ResetColorEnabledForTesting ¶
func ResetColorEnabledForTesting()
ResetColorEnabledForTesting clears the test-only color override.
func ResetStdoutIsTerminalForTesting ¶
func ResetStdoutIsTerminalForTesting()
ResetStdoutIsTerminalForTesting restores default stdout TTY detection.
func SetColorEnabledForTesting ¶
func SetColorEnabledForTesting(enabled bool)
SetColorEnabledForTesting forces color on or off regardless of runtime writer and terminal detection. This is a testing seam.
func SetStdoutIsTerminalForTesting ¶
func SetStdoutIsTerminalForTesting(enabled bool)
SetStdoutIsTerminalForTesting overrides stdout TTY detection for tests.
func StreamJSONArrayEnvelope ¶
func TerminalWidth ¶
TerminalWidth returns the terminal width or defaultWidth if detection fails.
func TerminalWidthFor ¶
TerminalWidthFor returns the terminal width for the supplied writer when backed by a TTY file descriptor, or defaultWidth if detection fails.
func WriteJSONStreamTo ¶
WriteJSONStreamTo writes a JSON envelope directly to w without staging. Prefer PrintJSONStream for user-facing command output; this helper stays raw for internal composition and focused unit tests.
Types ¶
type Pager ¶
type Pager struct {
// contains filtered or unexported fields
}
Pager wraps output through a system pager (e.g. less) when stdout is an interactive terminal. Falls back to direct stdout otherwise. Callers must Close the pager to wait for the process to finish.
func NewPager ¶
func NewPager() *Pager
NewPager starts a pager process if stdout is an interactive TTY with a capable terminal. Returns a passthrough to os.Stdout otherwise.
func NewPagerTo ¶
NewPagerTo writes to the supplied stdout writer and only spawns a system pager when that writer is a terminal-backed file.
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
func NewSpinner ¶
func (*Spinner) SetMessage ¶ added in v0.2.0
SetMessage replaces the spinner label. It is safe to call from any goroutine and takes effect on the next animation tick. Calls before Start or after Stop are accepted but nothing is rendered.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func NewStyledTable ¶
NewStyledTable binds a command-scoped styler up front. Command handlers should prefer this constructor so explicit flags like --no-color propagate consistently instead of falling back to writer auto-detection.