output

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bold

func Bold(s string) string

Bold returns a bold-styled string.

func ColorEnabled

func ColorEnabled() bool

ColorEnabled returns true if colors should be used.

func Dim

func Dim(s string) string

Dim returns a dimmed (gray) styled string.

func Error

func Error(s string) string

Error returns a red-styled string.

func Highlight

func Highlight(s string) string

Highlight returns a cyan-styled string.

func Info

func Info(s string) string

Info returns a blue-styled string.

func PrecipColor

func PrecipColor(chance int) string

PrecipColor returns a color based on precipitation chance. Gradient: green (0%) -> yellow (25%) -> orange (50%) -> red (75%+).

func Profile

func Profile() termenv.Profile

Profile returns the current terminal color profile.

func Success

func Success(s string) string

Success returns a green-styled string.

func TempColor

func TempColor(tempC float64) string

TempColor returns a color-styled temperature string (blue for cold, red for hot). Gradient: blue (0°C) -> green (15°C) -> yellow (25°C) -> red (35°C+).

func Warning

func Warning(s string) string

Warning returns a yellow-styled string.

func WindColor

func WindColor(speedKmh float64) string

WindColor returns a color based on wind speed. Gradient: green (0 km/h) -> yellow (20 km/h) -> orange (40 km/h) -> red (60 km/h+).

Types

type Mode

type Mode int

Mode represents the output format mode.

const (
	ModeTable Mode = iota
	ModeJSON
	ModePlain
)

type Writer

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

Writer handles output formatting in different modes.

func New

func New(w io.Writer, mode Mode, noColor bool) *Writer

New creates a new Writer with the given mode and color settings.

func (*Writer) JSON

func (o *Writer) JSON(v any) error

JSON outputs data as JSON to the writer.

func (*Writer) Print

func (o *Writer) Print(format string, args ...any)

Print outputs a formatted string without newline.

func (*Writer) PrintLn

func (o *Writer) PrintLn(format string, args ...any)

PrintLn outputs a formatted string with newline.

func (*Writer) TSV

func (o *Writer) TSV(header []string, rows [][]string) error

TSV outputs rows as tab-separated values. If header is provided, it's written as the first line.

func (*Writer) Table

func (o *Writer) Table(header []string, rows [][]string) error

Table outputs a formatted table with proper column alignment. Applies colors if enabled (unless noColor is set).

Jump to

Keyboard shortcuts

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