pretty

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Info returns a PrefixPrinter, which can be used to print text with an "info" Prefix.
	Info = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.InfoMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.InfoMessageStyle,
			Text:  "ℹ️",
		},
	}

	// Warning returns a PrefixPrinter, which can be used to print text with a "warning" Prefix.
	Warning = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.WarningMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.WarningMessageStyle,
			Text:  "❗",
		},
	}

	// Success returns a PrefixPrinter, which can be used to print text with a "success" Prefix.
	Success = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.SuccessMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.SuccessMessageStyle,
			Text:  "✅",
		},
	}

	// Error returns a PrefixPrinter, which can be used to print text with an "error" Prefix.
	Error = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.ErrorMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.ErrorMessageStyle,
			Text:  "❌",
		},
	}

	// Fatal returns a PrefixPrinter, which can be used to print text with an "fatal" Prefix.
	// NOTICE: Fatal terminates the application immediately!
	Fatal = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.FatalMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.FatalMessageStyle,
			Text:  "💣",
		},
		Fatal: true,
	}

	// FatalN returns a PrefixPrinter, which can be used to print text with an "fatal" Prefix.
	FatalN = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.FatalMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.FatalMessageStyle,
			Text:  "💣",
		},
	}

	// Debug Prints debug messages. By default, it will only print if PrintDebugMessages is true.
	// You can change PrintDebugMessages with EnableDebugMessages and DisableDebugMessages, or by setting the variable itself.
	Debug = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.DebugMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.DebugMessageStyle,
			Text:  "⭕",
		},
		Debugger: true,
	}

	// Check returns a PrefixPrinter, which can be used to print text with a "mark check" Prefix.
	Check = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.SuccessMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.SuccessMessageStyle,
			Text:  "✅",
		},
	}
)

Pretty prefix printer style.

Usage:

pretty.Info.Println("Hello")
pretty.Warning.Println("Hello")
View Source
var (
	// DebugT Prints debug messages. By default it will only print if PrintDebugMessages is true.
	// You can change PrintDebugMessages with EnableDebugMessages and DisableDebugMessages, or by setting the variable itself.
	DebugT = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.DebugMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.DebugMessageStyle,
			Text:  "#",
		},
		Debugger: true,
	}

	// InfoT returns a PrefixPrinter, which can be used to print text with an "info" Prefix.
	InfoT = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.SuccessMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.SuccessMessageStyle,
			Text:  "»",
		},
	}

	// WarningT returns a PrefixPrinter, which can be used to print text with a "warning" Prefix.
	WarningT = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.WarningMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.WarningMessageStyle,
			Text:  "!",
		},
	}

	// ErrorT returns a PrefixPrinter, which can be used to print text with an "error" Prefix.
	ErrorT = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.ErrorMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.ErrorMessageStyle,
			Text:  "✘",
		},
	}

	// FatalT returns a PrefixPrinter, which can be used to print text with an "fatal" Prefix.
	// NOTICE: Fatal terminates the application immediately!
	FatalT = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.FatalMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.FatalMessageStyle,
			Text:  "☒",
		},
		Fatal: true,
	}

	// FatalN returns a PrefixPrinter, which can be used to print text with an "fatal" Prefix.
	FatalNT = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.FatalMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.FatalMessageStyle,
			Text:  "☒",
		},
	}

	// SuccessT returns a PrefixPrinter, which can be used to print text with a "success" Prefix.
	SuccessT = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.SuccessMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.SuccessMessageStyle,
			Text:  "✔︎",
		},
	}

	// CheckT returns a PrefixPrinter, which can be used to print text with a "mark check" Prefix.
	CheckT = pterm.PrefixPrinter{
		MessageStyle: &pterm.ThemeDefault.SuccessMessageStyle,
		Prefix: pterm.Prefix{
			Style: &pterm.ThemeDefault.SuccessMessageStyle,
			Text:  "☑",
		},
	}
)

Pretty prefix text printer style.

Usage:

pretty.InfoT.Println("Hello")
pretty.WarningT.Println("Hello")
View Source
var (
	// Preset Color
	// Red is an alias for FgRed.Sprintf.
	Red = pterm.FgRed.Sprintf
	// Cyan is an alias for FgCyan.Sprintf.
	Cyan = pterm.FgCyan.Sprintf
	// Gray is an alias for FgGray.Sprintf.
	Gray = pterm.FgGray.Sprintf
	// Blue is an alias for FgBlue.Sprintf.
	Blue = pterm.FgBlue.Sprintf
	// Black is an alias for FgBlack.Sprintf.
	Black = pterm.FgBlack.Sprintf
	// Green is an alias for FgGreen.Sprintf.
	Green = pterm.FgGreen.Sprintf
	// White is an alias for FgWhite.Sprintf.
	White = pterm.FgWhite.Sprintf
	// Yellow is an alias for FgYellow.Sprintf.
	Yellow = pterm.FgYellow.Sprintf
	// Magenta is an alias for FgMagenta.Sprintf.
	Magenta = pterm.FgMagenta.Sprintf

	// Normal is an alias for FgDefault.Sprintf.
	Normal = pterm.FgDefault.Sprintf

	// LightRed is a shortcut for FgLightRed.Sprintf.
	LightRed = pterm.FgLightRed.Sprintf
	// LightCyan is a shortcut for FgLightCyan.Sprintf.
	LightCyan = pterm.FgLightCyan.Sprintf
	// LightBlue is a shortcut for FgLightBlue.Sprintf.
	LightBlue = pterm.FgLightBlue.Sprintf
	// LightGreen is a shortcut for FgLightGreen.Sprintf.
	LightGreen = pterm.FgLightGreen.Sprintf
	// LightWhite is a shortcut for FgLightWhite.Sprintf.
	LightWhite = pterm.FgLightWhite.Sprintf
	// LightYellow is a shortcut for FgLightYellow.Sprintf.
	LightYellow = pterm.FgLightYellow.Sprintf
	// LightMagenta is a shortcut for FgLightMagenta.Sprintf.
	LightMagenta = pterm.FgLightMagenta.Sprintf

	// Preset Style for Color and Bold
	// RedBold is an shortcut for Sprintf of Style with Red and Bold.
	RedBold = pterm.NewStyle(pterm.FgRed, pterm.Bold).Sprintf
	// CyanBold is an shortcut for Sprintf of Style with FgCyan and Bold.
	CyanBold = pterm.NewStyle(pterm.FgCyan, pterm.Bold).Sprintf
	// GrayBold is an shortcut for Sprintf of Style with FgGray and Bold.
	GrayBold = pterm.NewStyle(pterm.FgGray, pterm.Bold).Sprintf
	// BlueBold is an shortcut for Sprintf of Style with FgBlue and Bold.
	BlueBold = pterm.NewStyle(pterm.FgBlue, pterm.Bold).Sprintf
	// BlackBold is an shortcut for Sprintf of Style with FgBlack and Bold.
	BlackBold = pterm.NewStyle(pterm.FgBlack, pterm.Bold).Sprintf
	// GreenBold is an shortcut for Sprintf of Style with FgGreen and Bold.
	GreenBold = pterm.NewStyle(pterm.FgGreen, pterm.Bold).Sprintf
	// WhiteBold is an shortcut for Sprintf of Style with FgWhite and Bold.
	WhiteBold = pterm.NewStyle(pterm.FgWhite, pterm.Bold).Sprintf
	// YellowBold is an shortcut for Sprintf of Style with FgYellow and Bold.
	YellowBold = pterm.NewStyle(pterm.FgYellow, pterm.Bold).Sprintf
	// MagentaBold is an shortcut for Sprintf of Style with FgMagenta and Bold.
	MagentaBold = pterm.NewStyle(pterm.FgMagenta, pterm.Bold).Sprintf

	// NormalBold is an shortcut for Sprintf of Style with FgDefault and Bold.
	NormalBold = pterm.NewStyle(pterm.FgDefault, pterm.Bold).Sprintf

	// LightRedBold is an shortcut for Sprintf of Style with FgLightRed and Bold.
	LightRedBold = pterm.NewStyle(pterm.FgLightRed, pterm.Bold).Sprintf
	// LightCyanBold is an shortcut for Sprintf of Style with FgLightCyan and Bold.
	LightCyanBold = pterm.NewStyle(pterm.FgLightCyan, pterm.Bold).Sprintf
	// LightBlueBold is an shortcut for Sprintf of Style with FgLightBlue and Bold.
	LightBlueBold = pterm.NewStyle(pterm.FgLightBlue, pterm.Bold).Sprintf
	// LightGreenBold is an shortcut for Sprintf of Style with FgLightGreen and Bold.
	LightGreenBold = pterm.NewStyle(pterm.FgLightGreen, pterm.Bold).Sprintf
	// LightWhiteBold is an shortcut for Sprintf of Style with FgLightWhite and Bold.
	LightWhiteBold = pterm.NewStyle(pterm.FgLightWhite, pterm.Bold).Sprintf
	// LightYellowBold is an shortcut for Sprintf of Style with FgLightYellow and Bold.
	LightYellowBold = pterm.NewStyle(pterm.FgLightYellow, pterm.Bold).Sprintf
	// LightMagentaBold is an shortcut for Sprintf of Style with FgLightMagenta and Bold.
	LightMagentaBold = pterm.NewStyle(pterm.FgLightMagenta, pterm.Bold).Sprintf
)

Pretty style, contains the color and the style.

Usage:

var s1 string = pretty.GreenBold("Hello")
var s2 string = pretty.NormalBold("Hello %s", "World")
fmt.Println(s1, s2)
View Source
var Spinner = pterm.SpinnerPrinter{
	Sequence:            []string{" ⣾ ", " ⣽ ", " ⣻ ", " ⢿ ", " ⡿ ", " ⣟ ", " ⣯ ", " ⣷ "},
	Style:               &pterm.ThemeDefault.SpinnerStyle,
	Delay:               time.Millisecond * 100,
	ShowTimer:           true,
	TimerRoundingFactor: time.Second,
	TimerStyle:          &pterm.ThemeDefault.TimerStyle,
	MessageStyle:        &pterm.ThemeDefault.InfoMessageStyle,
	SuccessPrinter:      &Success,
	FailPrinter:         &Error,
	WarningPrinter:      &Warning,
}

Spinner style.

Usage:

sp, _ := pretty.Spinner.Start("Starting ...")
time.Sleep(time.Second * 3)
sp.Success("Done")
View Source
var SpinnerT = pterm.SpinnerPrinter{
	Sequence:            []string{" ⣾ ", " ⣽ ", " ⣻ ", " ⢿ ", " ⡿ ", " ⣟ ", " ⣯ ", " ⣷ "},
	Style:               &pterm.ThemeDefault.SpinnerStyle,
	Delay:               time.Millisecond * 100,
	ShowTimer:           true,
	TimerRoundingFactor: time.Second,
	TimerStyle:          &pterm.ThemeDefault.TimerStyle,
	MessageStyle:        &pterm.ThemeDefault.InfoMessageStyle,
	SuccessPrinter:      &SuccessT,
	FailPrinter:         &ErrorT,
	WarningPrinter:      &WarningT,
}

SpinnerT text style.

Usage:

sp, _ := pretty.SpinnerT.Start("Starting ...")
time.Sleep(time.Second * 3)
sp.Success("Done")

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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