labcli

package
v0.1.48 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapStatusError

func WrapStatusError(err error) error

Types

type CLI

type CLI interface {
	Streams

	SetQuiet(bool)

	// Regular print to stdout.
	PrintOut(string, ...any)

	// Regular print to stderr.
	PrintErr(string, ...any)

	// Print to stderr unless quiet else - discard.
	PrintAux(string, ...any)

	SetConfig(*config.Config)

	Config() *config.Config

	SetClient(*api.Client)

	Client() *api.Client

	Confirm(title, affirmative, negative string) bool

	Input(title, prompt string, value *string, validate func(string) error) error

	Version() string
}

func NewCLI

func NewCLI(cin io.ReadCloser, cout io.Writer, cerr io.Writer, version string) CLI

type ExitError added in v0.1.41

type ExitError interface {
	ExitStatus() int
}

type Printer added in v0.1.47

type Printer[T any, U []T | map[string]T] interface {
	Print(U) error
	Flush()
}

Printer prints a list of values.

func NewJSONPrinter added in v0.1.47

func NewJSONPrinter[T any, U []T | map[string]T](w io.Writer) Printer[T, U]

NewJSONPrinter outputs values as JSON.

func NewMapKeyPrinter added in v0.1.47

func NewMapKeyPrinter[T any, U map[string]T](w io.Writer) Printer[T, U]

NewMapKeyPrinter outputs the keys of a map.

func NewMapTablePrinter added in v0.1.47

func NewMapTablePrinter[T any, U map[string]T](w io.Writer, header []string, rowFunc func(T) []string, printKey bool) Printer[T, U]

NewMapTablePrinter creates a new table printer.

func NewSliceTablePrinter added in v0.1.47

func NewSliceTablePrinter[T any, U []T](w io.Writer, header []string, rowFunc func(T) []string) Printer[T, U]

NewSliceTablePrinter creates a new table printer.

type StatusError

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

func NewStatusError

func NewStatusError(code int, format string, a ...any) StatusError

func (StatusError) Code

func (e StatusError) Code() int

func (StatusError) Error

func (e StatusError) Error() string

type Streams

type Streams interface {
	InputStream() *streams.In
	OutputStream() *streams.Out
	AuxStream() *streams.Out // ErrorStream unless quiet else io.Discard
	ErrorStream() io.Writer
}

Jump to

Keyboard shortcuts

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