o

package
v0.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package o defines functions for human-readable log messages. The package matches Homebrew's messaging functions.

Index

Constants

View Source
const (
	Arrow   = "==>" // arrow used to prefix log message headers
	Check   = "✔"   // Check mark used to indicate success
	Warning = "⚠"   // Exclamation sign used to indicate warning
	X       = "✘"   // "X" mark used to indicate failure
)

Variables

View Source
var (
	StyleSuccess = StyleGreen  // semantic name for the green style
	StyleWarning = StyleYellow // semantic name for the yellow style
	StyleError   = StyleRed    // semantic name for the red style
)

Semantic aliases for defined styles.

View Source
var (
	ErrKey  = hlog.ErrKey
	ErrAttr = hlog.ErrAttr
)

aliases for internal log utility (avoid import cycles).

View Source
var (
	// Returns width of terminal clamped between 80 and 120.
	// With of 80 is used for non-TTY terminals.
	Width = min(utils.TerminalWidth(80), 120)
)

Defined styles.

Functions

func Color

func Color() bool

Color reports the color setting.

func Debug

func Debug(msg string)

Debug prints a debug message, prefixed with a magenta arrow.

It is an implementation of Homebrew's Formula.odebug function.

func Die

func Die(msg string)

Die prints an error, prefixed with "Error:".

stderr

It is an implementation of Homebrew's Formula.odie function, but does not exit like Formulae.odie.

func EmojiPrefixed

func EmojiPrefixed(msg string) string

EmojiPrefixed returns msg prefixed with the install badge Obeys the NoEmoji and InstallBadge settings.

func H1

func H1(msg string)

H1 prints a message, prefixed with a green arrow.

It is an implementation of Homebrew's Formula.oh1 function.

func Hai

func Hai(msg string)

Hai prints a message, prefixed with a blue arrow.

It is an implementation of Homebrew's Formula.ohai function.

func InstallBadge

func InstallBadge() string

InstallBadge returns the install badge.

func LogStyles

func LogStyles() *log.Styles

Returns log styles for charmbracelet/log.

func NoEmoji

func NoEmoji() bool

NoEmoji reports the NoEmoji setting.

func Noe

func Noe(msg string)

Noe prints an error, prefixed with "Error:".

stderr

It is an implementation of Homebrew's Formula.onoe function.

func Noop

func Noop(_ string)

Noop is a noop log function.

func Poo

func Poo(msg string)

Poo prints a warning, prefixed with "Warning:".

stderr

It is an implementation of Homebrew's Formula.opoo function.

func PrettyInstalled

func PrettyInstalled(formula string) string

PrettyInstalled formats an installed formula's name.

func PrettyOutdated

func PrettyOutdated(formula string) string

PrettyOutdated formats an outdated formula's name.

func PrettyUninstalled

func PrettyUninstalled(formula string) string

PrettyUninstalled formats an uninstalled formula's name.

func SetInstallBadge

func SetInstallBadge(value string)

SetInstallBadge sets the install badge setting.

func SetNoEmoji

func SetNoEmoji(value bool)

SetNoEmoji sets the NoEmoji setting.

func StyleBlue

func StyleBlue(s string) string

Styles string blue.

func StyleBold

func StyleBold(s string) string

Styles string bold.

func StyleEach

func StyleEach(style termenv.Style, s []string) []string

Styles each string.

func StyleFaint

func StyleFaint(s string) string

Styles string faded.

func StyleGreen

func StyleGreen(s string) string

Styles string green.

func StyleRed

func StyleRed(s string) string

Styles string red.

func StyleUnderline

func StyleUnderline(s string) string

Styles string underlined.

func StyleYellow

func StyleYellow(s string) string

Styles string yellow.

Types

This section is empty.

Jump to

Keyboard shortcuts

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