message

package
v0.33.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 18 Imported by: 16

Documentation

Overview

Package message provides a rich set of functions for displaying messages to the user.

Package message provides a rich set of functions for displaying messages to the user.

Package message provides a rich set of functions for displaying messages to the user.

Package message provides a rich set of functions for displaying messages to the user.

Package message provides a rich set of functions for displaying messages to the user.

Package message provides a rich set of functions for displaying messages to the user.

Package message provides a rich set of functions for displaying messages to the user.

Package message provides a rich set of functions for displaying messages to the user.

Index

Constants

View Source
const (
	RegistryKey     = "registry"
	RegistryReadKey = "registry-readonly"
	GitKey          = "git"
	GitReadKey      = "git-readonly"
	ArtifactKey     = "artifact"
	LoggingKey      = "logging"
	AgentKey        = "agent"
)

Common constants for printing credentials

Variables

View Source
var NoProgress bool

NoProgress tracks whether spinner/progress bars show updates.

View Source
var RuleLine = strings.Repeat("━", TermWidth)

RuleLine creates a line of ━ as wide as the terminal

Functions

func ColorWrap added in v0.32.0

func ColorWrap(str string, attr color.Attribute) string

ColorWrap changes a string to an ansi color code and appends the default color to the end preventing future characters from taking on the given color returns string as normal if color is disabled

func Command added in v0.28.0

func Command(format string, a ...any)

Command prints a zarf terminal command.

func Debug

func Debug(payload ...any)

Debug prints a debug message.

func Debugf

func Debugf(format string, a ...any)

Debugf prints a debug message with a given format.

func DisableColor added in v0.29.0

func DisableColor()

DisableColor disables color in output

func ErrorWebf

func ErrorWebf(err any, w http.ResponseWriter, format string, a ...any)

ErrorWebf prints an error message and returns a web response.

func Fatal

func Fatal(err any, message string)

Fatal prints a fatal error message and exits with a 1.

func Fatalf

func Fatalf(err any, format string, a ...any)

Fatalf prints a fatal error message and exits with a 1 with a given format.

func GetLogo() string

GetLogo returns the awesome menu ascii logo.

func HeaderInfof

func HeaderInfof(format string, a ...any)

HeaderInfof prints a large header with a formatted message.

func HorizontalRule added in v0.26.0

func HorizontalRule()

HorizontalRule prints a white horizontal rule to separate the terminal

func Info

func Info(message string)

Info prints an info message.

func Infof

func Infof(format string, a ...any)

Infof prints an info message with a given format.

func JSONValue

func JSONValue(value any) string

JSONValue prints any value as JSON.

func LogFileLocation added in v0.32.6

func LogFileLocation() string

LogFileLocation returns the location of the log file.

func Note

func Note(text string)

Note prints a note message.

func Notef

func Notef(format string, a ...any)

Notef prints a note message with a given format.

func Paragraph added in v0.26.0

func Paragraph(format string, a ...any) string

Paragraph formats text into a paragraph matching the TermWidth

func Paragraphn added in v0.26.0

func Paragraphn(n int, format string, a ...any) string

Paragraphn formats text into an n column paragraph

func PrintComponentCredential added in v0.29.0

func PrintComponentCredential(state *types.ZarfState, componentName string)

PrintComponentCredential displays credentials for a single component

func PrintConnectStringTable

func PrintConnectStringTable(connectStrings types.ConnectStrings)

PrintConnectStringTable prints a table of connect strings.

func PrintCredentialTable added in v0.29.0

func PrintCredentialTable(state *types.ZarfState, componentsToDeploy []types.DeployedComponent)

PrintCredentialTable displays credentials in a table

func PrintCredentialUpdates added in v0.29.0

func PrintCredentialUpdates(oldState *types.ZarfState, newState *types.ZarfState, services []string)

PrintCredentialUpdates displays credentials that will be updated

func PrintDiff added in v0.26.1

func PrintDiff(textA, textB string)

PrintDiff prints the differences between a and b with a as original and b as new

func Question

func Question(text string)

Question prints a user prompt description message.

func Questionf added in v0.26.0

func Questionf(format string, a ...any)

Questionf prints a user prompt description message with a given format.

func SetLogLevel

func SetLogLevel(lvl LogLevel)

SetLogLevel sets the log level.

func Success added in v0.28.0

func Success(message string)

Success prints a success message.

func Successf added in v0.25.0

func Successf(format string, a ...any)

Successf prints a success message with a given format.

func Table added in v0.31.3

func Table(header []string, data [][]string)

Table prints a padded table containing the specified header and data

func Title added in v0.27.1

func Title(title string, help string)

Title prints a title and an optional help description for that section

func UseLogFile

func UseLogFile(dir string) (io.Writer, error)

UseLogFile writes output to stderr and a logFile.

func Warn

func Warn(message string)

Warn prints a warning message.

func WarnErr added in v0.27.1

func WarnErr(err any, message string)

WarnErr prints an error message as a warning.

func WarnErrf added in v0.30.0

func WarnErrf(err any, format string, a ...any)

WarnErrf prints an error message as a warning with a given format.

func Warnf

func Warnf(format string, a ...any)

Warnf prints a warning message with a given format.

func ZarfCommand added in v0.28.0

func ZarfCommand(format string, a ...any)

ZarfCommand prints a zarf terminal command.

Types

type DebugWriter added in v0.26.0

type DebugWriter struct{}

DebugWriter represents a writer interface that writes to message.Debug

func (*DebugWriter) Write added in v0.26.0

func (d *DebugWriter) Write(raw []byte) (int, error)

type LogLevel

type LogLevel int

LogLevel is the level of logging to display.

const (
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel LogLevel = iota
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel
	// TraceLevel level. Designates finer-grained informational events than the Debug.
	TraceLevel

	// TermWidth sets the width of full width elements like progressbars and headers
	TermWidth = 100
)

func GetLogLevel

func GetLogLevel() LogLevel

GetLogLevel returns the current log level.

type ProgressBar

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

ProgressBar is a struct used to drive a pterm ProgressbarPrinter.

func NewProgressBar

func NewProgressBar(total int64, text string) *ProgressBar

NewProgressBar creates a new ProgressBar instance from a total value and a format.

func (*ProgressBar) Add added in v0.25.0

func (p *ProgressBar) Add(n int)

Add updates the ProgressBar with completed progress.

func (*ProgressBar) Errorf added in v0.26.2

func (p *ProgressBar) Errorf(err error, format string, a ...any)

Errorf marks the ProgressBar as failed in the CLI.

func (*ProgressBar) GetCurrent added in v0.32.3

func (p *ProgressBar) GetCurrent() int

GetCurrent returns the current total

func (*ProgressBar) Stop

func (p *ProgressBar) Stop()

Stop stops the ProgressBar from continuing.

func (*ProgressBar) Successf added in v0.24.3

func (p *ProgressBar) Successf(format string, a ...any)

Successf marks the ProgressBar as successful in the CLI.

func (*ProgressBar) Update

func (p *ProgressBar) Update(complete int64, text string)

Update updates the ProgressBar with completed progress and new text.

func (*ProgressBar) UpdateTitle added in v0.26.0

func (p *ProgressBar) UpdateTitle(text string)

UpdateTitle updates the ProgressBar with new text.

func (*ProgressBar) Write

func (p *ProgressBar) Write(data []byte) (int, error)

Write updates the ProgressBar with the number of bytes in a buffer as the completed progress.

type Spinner

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

Spinner is a wrapper around pterm.SpinnerPrinter.

func NewProgressSpinner

func NewProgressSpinner(format string, a ...any) *Spinner

NewProgressSpinner creates a new progress spinner.

func (*Spinner) DisablePreserveWrites added in v0.24.0

func (p *Spinner) DisablePreserveWrites()

DisablePreserveWrites disables preserving writes to the terminal.

func (*Spinner) EnablePreserveWrites added in v0.24.0

func (p *Spinner) EnablePreserveWrites()

EnablePreserveWrites enables preserving writes to the terminal.

func (*Spinner) Errorf

func (p *Spinner) Errorf(err error, format string, a ...any)

Errorf prints an error message with the spinner.

func (*Spinner) Fatal

func (p *Spinner) Fatal(err error)

Fatal calls message.Fatalf with the given error.

func (*Spinner) Fatalf

func (p *Spinner) Fatalf(err error, format string, a ...any)

Fatalf calls message.Fatalf with the given error and format.

func (*Spinner) Stop

func (p *Spinner) Stop()

Stop the spinner.

func (*Spinner) Success

func (p *Spinner) Success()

Success prints a success message and stops the spinner.

func (*Spinner) Successf

func (p *Spinner) Successf(format string, a ...any)

Successf prints a success message with the spinner and stops it.

func (*Spinner) Updatef

func (p *Spinner) Updatef(format string, a ...any)

Updatef updates the spinner text.

func (*Spinner) Write

func (p *Spinner) Write(raw []byte) (int, error)

Write the given text to the spinner.

type ZarfHandler added in v0.32.5

type ZarfHandler struct{}

ZarfHandler is a simple handler that implements the slog.Handler interface

func (ZarfHandler) Enabled added in v0.32.5

func (z ZarfHandler) Enabled(_ context.Context, _ slog.Level) bool

Enabled is always set to true as zarf logging functions are already aware of if they are allowed to be called

func (ZarfHandler) Handle added in v0.32.5

func (z ZarfHandler) Handle(_ context.Context, record slog.Record) error

Handle prints the respective logging function in zarf This function ignores any key pairs passed through the record

func (ZarfHandler) WithAttrs added in v0.32.5

func (z ZarfHandler) WithAttrs(_ []slog.Attr) slog.Handler

WithAttrs is not suppported

func (ZarfHandler) WithGroup added in v0.32.5

func (z ZarfHandler) WithGroup(_ string) slog.Handler

WithGroup is not supported

Jump to

Keyboard shortcuts

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