output

package
v1.2.62-rc2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JSON           = "json"
	YAML           = "yaml"
	FLAG_NAME      = "output"
	FLAG_SHORTHAND = "o"
)
View Source
const (
	Yes        = "Yes"
	No         = "No"
	EmptySlice = ""
)

Variables

This section is empty.

Functions

func AddFlag

func AddFlag(cmd *cobra.Command)

AddFlag adds the interactive flag to the given set of command line flags.

func HasFlag

func HasFlag() bool

func IsStructuredOutput

func IsStructuredOutput() bool

IsStructuredOutput returns true only when the --output flag is set to a known structured format (json or yaml), preventing unsupported values from being treated as structured output.

func NewStructuredReporter

func NewStructuredReporter(r reporter.Logger) reporter.Logger

NewStructuredReporter returns a reporter.Logger that formats errors and warnings as JSON when the --output flag is active, and otherwise delegates to the provided reporter unchanged.

func Output

func Output() string

Enabled retursn a boolean flag that indicates if the interactive mode is enabled.

func Print

func Print(resource interface{}) error

func PrintBool added in v1.2.38

func PrintBool(b bool) string

PrintBool returns a prettified version of a boolean. "Yes" for true, or "No" for false

func PrintError

func PrintError(err error) bool

PrintError outputs an error as JSON to stderr when a structured output format is requested. Returns true if the error was printed in structured format, false otherwise.

func PrintStringSlice added in v1.2.38

func PrintStringSlice(in []string) string

func PrintWarn

func PrintWarn(err error) bool

PrintWarn outputs a warning as JSON to stderr when a structured output format is requested. Returns true if the warning was printed in structured format, false otherwise.

func SetOutput added in v1.2.38

func SetOutput(output string)

Types

type StructuredReporter

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

StructuredReporter wraps a reporter.Logger so that Errorf and Warnf emit JSON to stderr when a structured output flag (--output json/yaml) is set, suppressing the plain-text prefix in that case.

func (*StructuredReporter) Debugf

func (r *StructuredReporter) Debugf(format string, args ...interface{})

func (*StructuredReporter) Errorf

func (r *StructuredReporter) Errorf(format string, args ...interface{}) error

func (*StructuredReporter) Infof

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

func (*StructuredReporter) IsTerminal

func (r *StructuredReporter) IsTerminal() bool

func (*StructuredReporter) Warnf

func (r *StructuredReporter) Warnf(format string, args ...interface{})

Jump to

Keyboard shortcuts

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