Documentation
¶
Index ¶
- Constants
- func AddFlag(cmd *cobra.Command)
- func HasFlag() bool
- func IsStructuredOutput() bool
- func NewStructuredReporter(r reporter.Logger) reporter.Logger
- func Output() string
- func Print(resource interface{}) error
- func PrintBool(b bool) string
- func PrintError(err error) bool
- func PrintStringSlice(in []string) string
- func PrintWarn(err error) bool
- func SetOutput(output string)
- type StructuredReporter
- func (r *StructuredReporter) Debugf(format string, args ...interface{})
- func (r *StructuredReporter) Errorf(format string, args ...interface{}) error
- func (r *StructuredReporter) Infof(format string, args ...interface{})
- func (r *StructuredReporter) IsTerminal() bool
- func (r *StructuredReporter) Warnf(format string, args ...interface{})
Constants ¶
const ( JSON = "json" YAML = "yaml" FLAG_NAME = "output" FLAG_SHORTHAND = "o" )
const ( Yes = "Yes" No = "No" EmptySlice = "" )
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 PrintBool ¶ added in v1.2.38
PrintBool returns a prettified version of a boolean. "Yes" for true, or "No" for false
func PrintError ¶
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
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{})