output

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetailMessage

func DetailMessage(err error, fallback string, sentinels ...error) string

func FormatConsoleError

func FormatConsoleError(console Console, record Error) string

func FormatConsoleWarning

func FormatConsoleWarning(console Console, record Warning) string

func FormatError

func FormatError(record Error) string

func FormatWarning

func FormatWarning(record Warning) string

func WriteEnvelope

func WriteEnvelope(out io.Writer, command Command, context string, kind Kind, data any, exitCode ExitCode) error

Types

type Command

type Command string

type Console

type Console struct {
	Invocation Invocation
	Color      bool
}

func NewConsole

func NewConsole(inv Invocation, color bool) Console

func (Console) Style

func (c Console) Style(style Style, s string) string

type ConsoleStringFunc

type ConsoleStringFunc func(Console, any) (string, error)

type Error

type Error struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Hint    string `json:"hint"`
}

type ErrorData

type ErrorData struct {
	Error Error `json:"error"`
}

type ExitCode

type ExitCode int
const (
	ExitOK   ExitCode = 0
	ExitFail ExitCode = 1
)

type Format

type Format uint8
const (
	Human Format = iota
	JSON
)

type Invocation

type Invocation struct {
	Command Command
	Context string
}

type Kind

type Kind string
const KindError Kind = "error"

type Options

type Options struct {
	Format   Format
	Color    bool
	ErrColor bool
	Out      io.Writer
	Err      io.Writer
}

type Outcome

type Outcome struct {
	Result Result
}

func OK

func OK(result Result) Outcome

func WithWarnings

func WithWarnings(outcome Outcome, warnings []Warning) Outcome

type Renderer

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

func NewRenderer

func NewRenderer(options Options) Renderer

func (Renderer) Render

func (r Renderer) Render(inv Invocation, outcome Outcome) (ExitCode, error)

type Result

type Result struct {
	Kind          Kind
	Data          any
	ExitCode      ExitCode
	Warnings      []Warning
	ConsoleString ConsoleStringFunc
}

func ErrorResult

func ErrorResult(code, message, hint string) Result

func IOError

func IOError(message string) Result

func InvalidArgs

func InvalidArgs(message string, hint string) Result

func RuntimeError

func RuntimeError(message string) Result

type Style

type Style string
const (
	StyleAccent  Style = "accent"
	StyleMuted   Style = "muted"
	StyleSuccess Style = "success"
	StyleWarning Style = "warning"
	StyleDanger  Style = "danger"
	StylePath    Style = "path"
	StylePackage Style = "package"
)

type Warning

type Warning struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Hint    string `json:"hint"`
}

Jump to

Keyboard shortcuts

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