color

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package color provides terminal color output support for JVS. It respects the NO_COLOR environment variable (https://no-color.org/).

Index

Constants

View Source
const (
	Reset     = "\033[0m"
	Bold      = "\033[1m"
	DimCode   = "\033[2m"
	Underline = "\033[4m"

	// Foreground colors
	Red     = "\033[31m"
	Green   = "\033[32m"
	Yellow  = "\033[33m"
	Blue    = "\033[34m"
	Magenta = "\033[35m"
	Cyan    = "\033[36m"
	White   = "\033[37m"
	Gray    = "\033[90m"

	// Background colors
	BgRed     = "\033[41m"
	BgGreen   = "\033[42m"
	BgYellow  = "\033[43m"
	BgBlue    = "\033[44m"
	BgMagenta = "\033[45m"
	BgCyan    = "\033[46m"
)

ANSI color codes

Variables

View Source
var (
	Redf     = makeColorFunc(Red)
	Greenf   = makeColorFunc(Green)
	Yellowf  = makeColorFunc(Yellow)
	Bluef    = makeColorFunc(Blue)
	Magentaf = makeColorFunc(Magenta)
	Cyanf    = makeColorFunc(Cyan)
	Whitef   = makeColorFunc(White)
	Grayf    = makeColorFunc(Gray)
	Boldf    = makeColorFunc(Bold)
	Dimf     = makeColorFunc(DimCode)
)

Pre-defined color functions

Functions

func Code

func Code(s string) string

Code formats code/command strings in a distinct style (bold + dim).

func CodeFor

func CodeFor(file *os.File, s string) string

CodeFor formats code/command strings for file.

func Dim

func Dim(s string) string

Dim formats dimmed text (for secondary information).

func DimFor

func DimFor(file *os.File, s string) string

DimFor formats dimmed text for file.

func Disable

func Disable()

Disable turns off color output.

func Enable

func Enable()

Enable turns on color output.

func Enabled

func Enabled() bool

Enabled returns true if color output is enabled.

func EnabledFor

func EnabledFor(file *os.File) bool

EnabledFor returns true if color output is enabled for file.

func Error

func Error(s string) string

Error formats an error message in red.

func ErrorFor

func ErrorFor(file *os.File, s string) string

ErrorFor formats an error message in red for file.

func Errorf

func Errorf(format string, args ...any) string

Errorf formats an error message with printf-style arguments.

func Header(s string) string

Header formats a header in bold.

func Highlight

func Highlight(s string) string

Highlight highlights important text in yellow.

func Info

func Info(s string) string

Info formats an informational message in cyan.

func Infof

func Infof(format string, args ...any) string

Infof formats an informational message with printf-style arguments.

func Init

func Init(noColorFlag bool)

Init initializes the color system based on environment and flags. It respects the NO_COLOR environment variable (https://no-color.org/) and can be disabled programmatically. Color is enabled only for interactive terminal output; CI and redirected output stay plain for deterministic logs. Init does not override explicit Enable()/Disable() calls.

func SnapshotID

func SnapshotID(s string) string

SnapshotID formats a snapshot ID in cyan (for visibility).

func Success

func Success(s string) string

Success formats a success message in green.

func Successf

func Successf(format string, args ...any) string

Successf formats a success message with printf-style arguments.

func Tag

func Tag(s string) string

Tag formats a tag name in blue.

func Warning

func Warning(s string) string

Warning formats a warning message in yellow.

func Warningf

func Warningf(format string, args ...any) string

Warningf formats a warning message with printf-style arguments.

Types

This section is empty.

Jump to

Keyboard shortcuts

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