terminal

package
v12.130.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2024 License: Apache-2.0 Imports: 5 Imported by: 14

Documentation

Overview

Package terminal provides methods for printing messages to terminal

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// ErrorColorTag is fmtc color tag used for error messages
	ErrorColorTag = "{r}"

	// WarnColorTag is fmtc color tag used for warning messages
	WarnColorTag = "{y}"

	// InfoColorTag is fmtc color tag used for info messages
	InfoColorTag = "{c-}"
)
View Source
var (
	// ErrorPrefix is prefix for error messages
	ErrorPrefix = ""

	// WarnPrefix is prefix for warning messages
	WarnPrefix = ""

	// InfoPrefix is prefix for info messages
	InfoPrefix = ""
)

Functions

func Error added in v12.70.0

func Error(message any, args ...any)

Error prints error message

Example
// Add custom error message prefix
ErrorPrefix = "▲ "

// Print red text to stderr
Error("Error while sending data to %s", "https://example.com")

// Print message from error struct
err := errors.New("My error")
Error(err)
Output:

func Info added in v12.70.0

func Info(message any, args ...any)

Info prints info message

Example
// Add custom info message prefix
InfoPrefix = "❕ "

// Print cyan text to stdout
Warn("User %q will be created automatically", "bob")
Output:

func PrintActionMessage

func PrintActionMessage(message string)

PrintActionMessage prints message about action currently in progress

Example
statusOk := true

PrintActionMessage("Starting service my-service")

switch statusOk {
case true:
	PrintActionStatus(0) // Print OK
case false:
	PrintActionStatus(1) // Print ERROR
}
Output:

func PrintActionStatus

func PrintActionStatus(status int)

PrintActionStatus prints message with action execution status

Example
statusOk := true

PrintActionMessage("Starting service my-service")

switch statusOk {
case true:
	PrintActionStatus(0) // Print OK
case false:
	PrintActionStatus(1) // Print ERROR
}
Output:

func Warn added in v12.70.0

func Warn(message any, args ...any)

Warn prints warning message

Example
// Add custom warning message prefix
WarnPrefix = "△ "

// Print yellow text to stderr
Warn("Warning file %s is not found", "/home/john/test.txt")

// Print message from error struct
err := errors.New("My warning")
Warn(err)
Output:

Types

This section is empty.

Directories

Path Synopsis
Package input provides methods for reading user input
Package input provides methods for reading user input
Package tty provides methods for working with TTY
Package tty provides methods for working with TTY

Jump to

Keyboard shortcuts

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