cmdout

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandName

func CommandName(cmd *cobra.Command) string

func EncodeDocument

func EncodeDocument(format Format, value any) ([]byte, error)

func EncodeRecord

func EncodeRecord(format Format, value any) ([]byte, error)

func Fail

func Fail(code Code, message string, cause error) error

func FailWithDiagnostics

func FailWithDiagnostics(
	code Code,
	message string,
	cause error,
	diagnostics []diagnostic.Diagnostic,
) error

func FormatHelp

func FormatHelp() string

func IsReported

func IsReported(err error) bool

func PrintUnreportedError

func PrintUnreportedError(cmd *cobra.Command, err error)

func Reported

func Reported(err error) error

func ToolOutput added in v0.12.0

func ToolOutput(cmd *cobra.Command, format Format) io.Writer

func WithFiles

func WithFiles(err error, files []filechange.Change) error

func WriteCommandError

func WriteCommandError(
	cmd *cobra.Command,
	format Format,
	collected []diagnostic.Diagnostic,
	failure error,
) error

func WriteDocument

func WriteDocument(out io.Writer, format Format, value any) error

func WriteOperationError added in v0.12.0

func WriteOperationError(cmd *cobra.Command, format Format, files []filechange.Change,
	err error,
) error

func WriteRecord

func WriteRecord(out io.Writer, format Format, value any) error

Types

type Code

type Code string
const (
	CodeInvalidArgs    Code = "unobin.command.invalid-args"
	CodeIO             Code = "unobin.command.io"
	CodeFailed         Code = "unobin.command.failed"
	CodeStdoutConflict Code = "unobin.command.stdout-conflict"
)

type CommandError

type CommandError struct {
	Kind          string                  `json:"kind"           ub:"kind"`
	FormatVersion int                     `json:"format-version" ub:"format-version"`
	Command       string                  `json:"command"        ub:"command"`
	Code          Code                    `json:"code"           ub:"code"`
	Message       string                  `json:"message"        ub:"message"`
	Diagnostics   []diagnostic.Diagnostic `json:"diagnostics"    ub:"diagnostics"`
	Files         []filechange.Change     `json:"files"          ub:"files"`
}

type Failure

type Failure struct {
	Code        Code
	Message     string
	Cause       error
	Diagnostics []diagnostic.Diagnostic
	Files       []filechange.Change
}

func AsFailure

func AsFailure(err error) (*Failure, bool)

func (*Failure) Error

func (e *Failure) Error() string

func (*Failure) Unwrap

func (e *Failure) Unwrap() error

type Format

type Format string
const (
	FormatText   Format = "text"
	FormatJSON   Format = "json"
	FormatUnobin Format = "unobin"
)

func CommandFormat added in v0.12.0

func CommandFormat(cmd *cobra.Command) (Format, error)

func ParseFormat

func ParseFormat(value string) (Format, error)

func (Format) Machine

func (f Format) Machine() bool

type ReportedError

type ReportedError struct {
	Err error
}

func (*ReportedError) Error

func (e *ReportedError) Error() string

func (*ReportedError) Unwrap

func (e *ReportedError) Unwrap() error

Jump to

Keyboard shortcuts

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