output

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset  = "\033[0m"
	Red    = "\033[31m"
	Green  = "\033[32m"
	Yellow = "\033[33m"
	Blue   = "\033[34m"

	Gray = "\033[90m"
)

ANSI color codes

View Source
const (
	QuietLevel = iota
	NormalLevel
	VerboseLevel
)

Verbosity levels

Variables

This section is empty.

Functions

func Banner(info VersionInfo) string

Banner renders a branded ASCII art banner with version information. It uses Lipgloss for styling and respects the existing NO_COLOR / TTY detection handled by the output package.

func Color

func Color(text, colorCode string) string

Color wraps text with color codes if colors are enabled.

func Cyan

func Cyan(text string) string

Cyan returns cyan-colored text.

func Dim

func Dim(text string) string

Dim returns gray-colored text.

func Enabled

func Enabled() bool

Enabled returns whether colors are currently enabled.

func Error

func Error(text string) string

Error returns red-colored text.

func ErrorPrint

func ErrorPrint(format string, args ...interface{})

ErrorPrint always prints (errors should always be shown).

func ErrorPrintf

func ErrorPrintf(format string, args ...interface{})

ErrorPrintf always prints formatted text (errors should always be shown).

func Errorf

func Errorf(format string, args ...interface{}) string

Errorf formats and colors text as error.

func FormatError

func FormatError(err error) string

FormatError formats an error with context and suggestions.

func FormatErrorWithContext

func FormatErrorWithContext(ctx ErrorContext) string

FormatErrorWithContext formats an error with explicit context.

func Info

func Info(text string) string

Info returns blue-colored text.

func InfoPrint

func InfoPrint(format string, args ...interface{})

InfoPrint prints info message if verbosity allows.

func Infof

func Infof(format string, args ...interface{}) string

Infof formats and colors text as info.

func Init

func Init(noColor bool)

Init initializes color output based on environment and flags. Call this early in the application lifecycle.

func Print

func Print(format string, args ...interface{})

Print prints text if verbosity allows.

func PrintJSON

func PrintJSON(data interface{}) error

PrintJSON prints data as JSON to stdout.

func PrintJSONError added in v0.3.5

func PrintJSONError(err error) error

PrintJSONError prints an error using a stable machine-readable shape.

func PrintJSONResult

func PrintJSONResult(result JSONResult) error

PrintJSONResult prints a JSONResult as JSON.

func Printf

func Printf(format string, args ...interface{})

Printf prints formatted text if verbosity allows.

func Println

func Println(args ...interface{})

Println prints a line if verbosity allows.

func QuietPrint

func QuietPrint(format string, args ...interface{})

QuietPrint prints text only in quiet mode (errors).

func SetVerbosity

func SetVerbosity(level int)

SetVerbosity sets the verbosity level.

func SetWriters

func SetWriters(out, err io.Writer)

SetWriters sets the output and error writers (useful for testing).

func Success

func Success(text string) string

Success returns green-colored text.

func SuccessPrint

func SuccessPrint(format string, args ...interface{})

SuccessPrint prints success message if verbosity allows.

func SuccessPrintln

func SuccessPrintln(text string)

SuccessPrintln prints success message with newline if verbosity allows.

func Successf

func Successf(format string, args ...interface{}) string

Successf formats and colors text as success.

func VerbosePrint

func VerbosePrint(format string, args ...interface{})

VerbosePrint prints text only in verbose mode.

func VerbosePrintf

func VerbosePrintf(format string, args ...interface{})

VerbosePrintf prints formatted text only in verbose mode.

func Warning

func Warning(text string) string

Warning returns yellow-colored text.

func WarningPrint

func WarningPrint(format string, args ...interface{})

WarningPrint prints warning message if verbosity allows.

func WarningPrintf

func WarningPrintf(format string, args ...interface{})

WarningPrintf prints formatted warning message if verbosity allows.

func WarningPrintln

func WarningPrintln(text string)

WarningPrintln prints warning message with newline if verbosity allows.

func Warningf

func Warningf(format string, args ...interface{}) string

Warningf formats and colors text as warning.

func WrapError

func WrapError(err error, suggestion string) error

WrapError wraps an error with context.

func WrapErrorWithCode

func WrapErrorWithCode(err error, suggestion string, code string) error

WrapErrorWithCode wraps an error with context and error code.

func WriteJSON

func WriteJSON(data *export.Data, outputPath string) error

WriteJSON writes data to a JSON file.

func WriteTar

func WriteTar(data *export.Data, outputPath string) error

WriteTar writes data to a tar.gz file.

Types

type ErrorContext

type ErrorContext struct {
	Error      error
	Suggestion string
	HelpURL    string
	ErrorCode  string
}

ErrorContext provides additional context for errors.

type ErrorOutput added in v0.3.5

type ErrorOutput struct {
	Success    bool   `json:"success"`
	Error      string `json:"error"`
	Suggestion string `json:"suggestion,omitempty"`
	ErrorCode  string `json:"error_code,omitempty"`
}

ErrorOutput is the structured JSON representation of a command error.

type JSONResult

type JSONResult struct {
	Success bool                   `json:"success"`
	Message string                 `json:"message,omitempty"`
	Data    map[string]interface{} `json:"data,omitempty"`
	Error   string                 `json:"error,omitempty"`
}

JSONResult represents a structured result for JSON output.

type VersionInfo added in v0.2.0

type VersionInfo struct {
	Version   string
	BuildDate string
	Commit    string
	GoVersion string
	Platform  string
}

VersionInfo holds the fields displayed below the banner.

Jump to

Keyboard shortcuts

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