print

package
v0.2.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DebugLevel   Level = "debug"
	InfoLevel    Level = "info"
	WarningLevel Level = "warning"
	ErrorLevel   Level = "error"

	JSONOutputFormat   = "json"
	PrettyOutputFormat = "pretty"
	NoneOutputFormat   = "none"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level string

type Printer

type Printer struct {
	Cmd       *cobra.Command
	Verbosity Level
}

func NewPrinter

func NewPrinter() *Printer

Creates a new printer, including setting up the default logger.

func (*Printer) Debug

func (p *Printer) Debug(level Level, msg string, args ...any)

Print a Debug level log through the "slog" package. If the verbosity level is not Debug, it does nothing

func (*Printer) Error

func (p *Printer) Error(msg string, args ...any)

Print an Error level output to the defined Err output (falling back to Stderr if not set).

func (*Printer) Info

func (p *Printer) Info(msg string, args ...any)

Print an Info level output to the defined Err output (falling back to Stderr if not set). If the verbosity level is not Debug or Info, it does nothing.

func (*Printer) Outputf

func (p *Printer) Outputf(msg string, args ...any)

Print an output using Printf to the defined output (falling back to Stderr if not set). If output format is set to none, it does nothing

func (*Printer) Outputln

func (p *Printer) Outputln(msg string)

Print an output using Println to the defined output (falling back to Stderr if not set). If output format is set to none, it does nothing

func (*Printer) PagerDisplay added in v0.2.3

func (p *Printer) PagerDisplay(content string) error

Shows the content in the command's stdout using the "less" command If output format is set to none, it does nothing

func (*Printer) PromptForConfirmation

func (p *Printer) PromptForConfirmation(prompt string) error

Prompts the user for confirmation.

Returns nil only if the user (explicitly) answers positive. Returns ErrAborted if the user answers negative.

func (*Printer) Warn

func (p *Printer) Warn(msg string, args ...any)

Print a Warn level output to the defined Err output (falling back to Stderr if not set). If the verbosity level is not Debug, Info, or Warn, it does nothing.

Jump to

Keyboard shortcuts

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