format

package
v1.12.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	LoginCommand  = "login"
	LogoutCommand = "logout"
)
View Source
const (
	SuccessChar = "✓"
	FailureChar = "✗"

	OutputFormatTypeYAML OutputFormatType = 0
	OutputFormatTypeJSON OutputFormatType = 1
)

Variables

This section is empty.

Functions

func Command added in v1.1.1

func Command() command

Command can be used to print how certain nctl commands can be executed

func Confirm added in v1.8.3

func Confirm(message string) (bool, error)

Confirm prints a confirm dialog using the supplied message and then waits until prompt is confirmed or denied. Only y and yes are accepted for confirmation.

func Confirmf

func Confirmf(format string, a ...any) (bool, error)

Confirmf prints a confirm dialog using format and then waits until prompt is confirmed or denied. Only y and yes are accepted for confirmation.

func ExitIfErrorf added in v1.2.0

func ExitIfErrorf(err error, args ...any) error

ExitIfErrorf prints Usage + friendly message on error (and exits).

func FailureMessagef

func FailureMessagef(icon, format string, a ...any) string

FailureMessagef is a formatted message for indicating a failed step.

func InterpolateFlagPlaceholders added in v1.2.0

func InterpolateFlagPlaceholders(vars kong.Vars) func(*kong.Kong) error

InterpolateFlagPlaceholders will return a function which walks the whole kong model and interpolates variables in placeholders in flags.

func IsInteractiveEnvironment added in v1.8.2

func IsInteractiveEnvironment(out io.Writer) bool

func MissingChildren added in v1.2.0

func MissingChildren(node *kong.Node) bool

MissingChildren detects missing commands/args. Logic taken from github.com/alecthomas/kong/context.go

func NewSpinner

func NewSpinner(message, stopMessage string) (*yacspin.Spinner, error)

NewSpinner returns a new spinner with the default config

func PrettyPrintObject added in v1.2.2

func PrettyPrintObject(obj any, opts PrintOpts) error

PrettyPrintObject prints the supplied object in "pretty" colored yaml with some metadata, status and other default fields stripped out.

func PrettyPrintObjects

func PrettyPrintObjects[T any](objs []T, opts PrintOpts) error

PrettyPrintObjects prints the supplied objects in "pretty" colored yaml with some metadata, status and other default fields stripped out. If multiple objects are supplied, they will be divided with a yaml divider.

func PrintFailuref

func PrintFailuref(icon, format string, a ...any)

PrintFailuref prints a failure message.

func PrintSuccess added in v1.8.3

func PrintSuccess(icon, message string)

PrintSuccess prints a success message.

func PrintSuccessf

func PrintSuccessf(icon, format string, a ...any)

PrintSuccessf prints a success message.

func PrintWarningf added in v1.7.0

func PrintWarningf(msg string, a ...any)

func ProgressMessage added in v1.8.3

func ProgressMessage(icon, message string) string

ProgressMessage is a formatted message for use with a spinner.Suffix. An icon can be added which is displayed at the end of the message.

func ProgressMessagef

func ProgressMessagef(icon, format string, a ...any) string

ProgressMessagef is a formatted message for use with a spinner.Suffix. An icon can be added which is displayed at the end of the message.

func SuccessMessage added in v1.8.3

func SuccessMessage(icon, message string) string

SuccessMessage returns a message for indicating a successful step.

func SuccessMessagef

func SuccessMessagef(icon, format string, a ...any) string

SuccessMessagef is a formatted message for indicating a successful step.

Types

type JSONOutputOptions added in v1.9.0

type JSONOutputOptions struct {
	// PrintSingleItem will print a single item of an array as is
	// (without the array notation)
	PrintSingleItem bool
}

type OutputFormatType added in v1.9.0

type OutputFormatType int

type PrintOpts

type PrintOpts struct {
	// Out will be used to print to if set instead of stdout.
	Out io.Writer
	// ExcludeAdditional allows to exclude more fields of the object
	ExcludeAdditional [][]string
	// format type of the output, e.g. yaml or json
	Format OutputFormatType
	// JSONOpts defines special options for JSON output
	JSONOpts JSONOutputOptions
	// AllFields prints all fields of the object.
	AllFields bool
}

PrintOpts customizes the printing.

Jump to

Keyboard shortcuts

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