print

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level string
const (
	DebugLevel   Level = "debug"
	InfoLevel    Level = "info"
	WarningLevel Level = "warning"
	ErrorLevel   Level = "error"
)

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).

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).

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