Documentation ¶
Overview ¶
Package pterm is a modern go module to beautify console output. It can be used without configuration, but if desired, everything can be customized down to the smallest detail.
Official docs are available at: https://docs.pterm.sh
View the animated examples here: https://github.com/pterm/pterm#-examples
Index ¶
- Variables
- func DisableColor()
- func DisableDebugMessages()
- func DisableOutput()
- func DisableStyling()
- func EnableColor()
- func EnableDebugMessages()
- func EnableOutput()
- func EnableStyling()
- func Fprint(writer io.Writer, a ...interface{})
- func Fprintln(writer io.Writer, a ...interface{})
- func Fprinto(w io.Writer, a ...interface{})
- func GetTerminalHeight() int
- func GetTerminalSize() (width, height int, err error)
- func GetTerminalWidth() int
- func Print(a ...interface{})
- func PrintOnError(a ...interface{})
- func PrintOnErrorf(format string, a ...interface{})
- func Printf(format string, a ...interface{})
- func Printfln(format string, a ...interface{})
- func Println(a ...interface{})
- func Printo(a ...interface{})
- func RecalculateTerminalSize()
- func RemoveColorFromString(a ...interface{}) string
- func SetDefaultOutput(w io.Writer)
- func SetForcedTerminalSize(width int, height int)
- func Sprint(a ...interface{}) string
- func Sprintf(format string, a ...interface{}) string
- func Sprintfln(format string, a ...interface{}) string
- func Sprintln(a ...interface{}) string
- func Sprinto(a ...interface{}) string
- type AreaPrinter
- func (p *AreaPrinter) Clear()
- func (p *AreaPrinter) GenericStart() (*LivePrinter, error)
- func (p *AreaPrinter) GenericStop() (*LivePrinter, error)
- func (p *AreaPrinter) GetContent() string
- func (p *AreaPrinter) SetWriter(writer io.Writer)
- func (p *AreaPrinter) Start(text ...interface{}) (*AreaPrinter, error)
- func (p *AreaPrinter) Stop() error
- func (p *AreaPrinter) Update(text ...interface{})
- func (p AreaPrinter) WithCenter(b ...bool) *AreaPrinter
- func (p AreaPrinter) WithFullscreen(b ...bool) *AreaPrinter
- func (p AreaPrinter) WithRemoveWhenDone(b ...bool) *AreaPrinter
- type Bar
- type BarChartPrinter
- func (p BarChartPrinter) Render() error
- func (p BarChartPrinter) Srender() (string, error)
- func (p BarChartPrinter) WithBars(bars Bars) *BarChartPrinter
- func (p BarChartPrinter) WithHeight(value int) *BarChartPrinter
- func (p BarChartPrinter) WithHorizontal(b ...bool) *BarChartPrinter
- func (p BarChartPrinter) WithHorizontalBarCharacter(char string) *BarChartPrinter
- func (p BarChartPrinter) WithShowValue(b ...bool) *BarChartPrinter
- func (p BarChartPrinter) WithVerticalBarCharacter(char string) *BarChartPrinter
- func (p BarChartPrinter) WithWidth(value int) *BarChartPrinter
- func (p BarChartPrinter) WithWriter(writer io.Writer) *BarChartPrinter
- type Bars
- type BasicTextPrinter
- func (p *BasicTextPrinter) Print(a ...interface{}) *TextPrinter
- func (p *BasicTextPrinter) PrintOnError(a ...interface{}) *TextPrinter
- func (p *BasicTextPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
- func (p *BasicTextPrinter) Printf(format string, a ...interface{}) *TextPrinter
- func (p *BasicTextPrinter) Printfln(format string, a ...interface{}) *TextPrinter
- func (p *BasicTextPrinter) Println(a ...interface{}) *TextPrinter
- func (p BasicTextPrinter) Sprint(a ...interface{}) string
- func (p BasicTextPrinter) Sprintf(format string, a ...interface{}) string
- func (p BasicTextPrinter) Sprintfln(format string, a ...interface{}) string
- func (p BasicTextPrinter) Sprintln(a ...interface{}) string
- func (p BasicTextPrinter) WithStyle(style *Style) *BasicTextPrinter
- func (p BasicTextPrinter) WithWriter(writer io.Writer) *BasicTextPrinter
- type BigTextPrinter
- func (p BigTextPrinter) Render() error
- func (p BigTextPrinter) Srender() (string, error)
- func (p BigTextPrinter) WithBigCharacters(chars map[string]string) *BigTextPrinter
- func (p BigTextPrinter) WithLetters(letters ...Letters) *BigTextPrinter
- func (p BigTextPrinter) WithWriter(writer io.Writer) *BigTextPrinter
- type BoxPrinter
- func (p BoxPrinter) Print(a ...interface{}) *TextPrinter
- func (p BoxPrinter) PrintOnError(a ...interface{}) *TextPrinter
- func (p BoxPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
- func (p BoxPrinter) Printf(format string, a ...interface{}) *TextPrinter
- func (p BoxPrinter) Printfln(format string, a ...interface{}) *TextPrinter
- func (p BoxPrinter) Println(a ...interface{}) *TextPrinter
- func (p BoxPrinter) Sprint(a ...interface{}) string
- func (p BoxPrinter) Sprintf(format string, a ...interface{}) string
- func (p BoxPrinter) Sprintfln(format string, a ...interface{}) string
- func (p BoxPrinter) Sprintln(a ...interface{}) string
- func (p BoxPrinter) WithBottomLeftCornerString(str string) *BoxPrinter
- func (p BoxPrinter) WithBottomPadding(padding int) *BoxPrinter
- func (p BoxPrinter) WithBottomRightCornerString(str string) *BoxPrinter
- func (p BoxPrinter) WithBoxStyle(style *Style) *BoxPrinter
- func (p BoxPrinter) WithHorizontalString(str string) *BoxPrinter
- func (p BoxPrinter) WithLeftPadding(padding int) *BoxPrinter
- func (p BoxPrinter) WithRightPadding(padding int) *BoxPrinter
- func (p BoxPrinter) WithTextStyle(style *Style) *BoxPrinter
- func (p BoxPrinter) WithTitle(str string) *BoxPrinter
- func (p BoxPrinter) WithTitleBottomCenter(b ...bool) *BoxPrinter
- func (p BoxPrinter) WithTitleBottomLeft(b ...bool) *BoxPrinter
- func (p BoxPrinter) WithTitleBottomRight(b ...bool) *BoxPrinter
- func (p BoxPrinter) WithTitleTopCenter(b ...bool) *BoxPrinter
- func (p BoxPrinter) WithTitleTopLeft(b ...bool) *BoxPrinter
- func (p BoxPrinter) WithTitleTopRight(b ...bool) *BoxPrinter
- func (p BoxPrinter) WithTopLeftCornerString(str string) *BoxPrinter
- func (p BoxPrinter) WithTopPadding(padding int) *BoxPrinter
- func (p BoxPrinter) WithTopRightCornerString(str string) *BoxPrinter
- func (p BoxPrinter) WithVerticalString(str string) *BoxPrinter
- func (p BoxPrinter) WithWriter(writer io.Writer) *BoxPrinter
- type BulletListItem
- func (p BulletListItem) WithBullet(bullet string) *BulletListItem
- func (p BulletListItem) WithBulletStyle(style *Style) *BulletListItem
- func (p BulletListItem) WithLevel(level int) *BulletListItem
- func (p BulletListItem) WithText(text string) *BulletListItem
- func (p BulletListItem) WithTextStyle(style *Style) *BulletListItem
- type BulletListPrinter
- func (l BulletListPrinter) Render() error
- func (l BulletListPrinter) Srender() (string, error)
- func (l BulletListPrinter) WithBullet(bullet string) *BulletListPrinter
- func (l BulletListPrinter) WithBulletStyle(style *Style) *BulletListPrinter
- func (l BulletListPrinter) WithItems(items []BulletListItem) *BulletListPrinter
- func (l BulletListPrinter) WithTextStyle(style *Style) *BulletListPrinter
- func (l BulletListPrinter) WithWriter(writer io.Writer) *BulletListPrinter
- type CenterPrinter
- func (p CenterPrinter) Print(a ...interface{}) *TextPrinter
- func (p CenterPrinter) PrintOnError(a ...interface{}) *TextPrinter
- func (p CenterPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
- func (p CenterPrinter) Printf(format string, a ...interface{}) *TextPrinter
- func (p CenterPrinter) Printfln(format string, a ...interface{}) *TextPrinter
- func (p CenterPrinter) Println(a ...interface{}) *TextPrinter
- func (p CenterPrinter) Sprint(a ...interface{}) string
- func (p CenterPrinter) Sprintf(format string, a ...interface{}) string
- func (p CenterPrinter) Sprintfln(format string, a ...interface{}) string
- func (p CenterPrinter) Sprintln(a ...interface{}) string
- func (p CenterPrinter) WithCenterEachLineSeparately(b ...bool) *CenterPrinter
- func (p CenterPrinter) WithWriter(writer io.Writer) *CenterPrinter
- type Checkmark
- type Color
- func (c Color) Print(a ...interface{}) *TextPrinter
- func (c Color) PrintOnError(a ...interface{}) *TextPrinter
- func (c Color) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
- func (c Color) Printf(format string, a ...interface{}) *TextPrinter
- func (c Color) Printfln(format string, a ...interface{}) *TextPrinter
- func (c Color) Println(a ...interface{}) *TextPrinter
- func (c Color) Sprint(a ...interface{}) string
- func (c Color) Sprintf(format string, a ...interface{}) string
- func (c Color) Sprintfln(format string, a ...interface{}) string
- func (c Color) Sprintln(a ...interface{}) string
- func (c Color) String() string
- func (c Color) ToStyle() *Style
- type HeaderPrinter
- func (p *HeaderPrinter) Print(a ...interface{}) *TextPrinter
- func (p *HeaderPrinter) PrintOnError(a ...interface{}) *TextPrinter
- func (p *HeaderPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
- func (p *HeaderPrinter) Printf(format string, a ...interface{}) *TextPrinter
- func (p *HeaderPrinter) Printfln(format string, a ...interface{}) *TextPrinter
- func (p *HeaderPrinter) Println(a ...interface{}) *TextPrinter
- func (p HeaderPrinter) Sprint(a ...interface{}) string
- func (p HeaderPrinter) Sprintf(format string, a ...interface{}) string
- func (p HeaderPrinter) Sprintfln(format string, a ...interface{}) string
- func (p HeaderPrinter) Sprintln(a ...interface{}) string
- func (p HeaderPrinter) WithBackgroundStyle(style *Style) *HeaderPrinter
- func (p HeaderPrinter) WithFullWidth(b ...bool) *HeaderPrinter
- func (p HeaderPrinter) WithMargin(margin int) *HeaderPrinter
- func (p HeaderPrinter) WithTextStyle(style *Style) *HeaderPrinter
- func (p HeaderPrinter) WithWriter(writer io.Writer) *HeaderPrinter
- type HeatmapAxis
- type HeatmapData
- type HeatmapPrinter
- func (p HeatmapPrinter) Render() error
- func (p HeatmapPrinter) Srender() (string, error)
- func (p HeatmapPrinter) WithAxisData(hd HeatmapAxis) *HeatmapPrinter
- func (p HeatmapPrinter) WithAxisStyle(style *Style) *HeatmapPrinter
- func (p HeatmapPrinter) WithBoxed(b ...bool) *HeatmapPrinter
- func (p HeatmapPrinter) WithCellSize(i int) *HeatmapPrinter
- func (p HeatmapPrinter) WithColors(colors ...Color) *HeatmapPrinter
- func (p HeatmapPrinter) WithData(data [][]float32) *HeatmapPrinter
- func (p HeatmapPrinter) WithEnableComplementaryColor(b ...bool) *HeatmapPrinter
- func (p HeatmapPrinter) WithEnableRGB(b ...bool) *HeatmapPrinter
- func (p HeatmapPrinter) WithGrid(b ...bool) *HeatmapPrinter
- func (p HeatmapPrinter) WithLegend(b ...bool) *HeatmapPrinter
- func (p HeatmapPrinter) WithLegendLabel(s string) *HeatmapPrinter
- func (p HeatmapPrinter) WithLegendOnlyColoredCells(b ...bool) *HeatmapPrinter
- func (p HeatmapPrinter) WithOnlyColoredCells(b ...bool) *HeatmapPrinter
- func (p HeatmapPrinter) WithRGBRange(rgb ...RGB) *HeatmapPrinter
- func (p HeatmapPrinter) WithSeparatorStyle(style *Style) *HeatmapPrinter
- func (p HeatmapPrinter) WithTextColor(color Color) *HeatmapPrinter
- func (p HeatmapPrinter) WithTextRGB(rgb RGB) *HeatmapPrinter
- func (p HeatmapPrinter) WithWriter(writer io.Writer) *HeatmapPrinter
- type InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) Show(text ...string) (bool, error)
- func (p InteractiveConfirmPrinter) WithConfirmStyle(style *Style) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithConfirmText(text string) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithDefaultText(text string) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithDefaultValue(value bool) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithDelimiter(delimiter string) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithRejectStyle(style *Style) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithRejectText(text string) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithSuffixStyle(style *Style) *InteractiveConfirmPrinter
- func (p InteractiveConfirmPrinter) WithTextStyle(style *Style) *InteractiveConfirmPrinter
- type InteractiveContinuePrinter
- func (p InteractiveContinuePrinter) Show(text ...string) (string, error)
- func (p InteractiveContinuePrinter) WithDefaultText(text string) *InteractiveContinuePrinter
- func (p InteractiveContinuePrinter) WithDefaultValue(value string) *InteractiveContinuePrinter
- func (p InteractiveContinuePrinter) WithDefaultValueIndex(value int) *InteractiveContinuePrinter
- func (p InteractiveContinuePrinter) WithDelimiter(delimiter string) *InteractiveContinuePrinter
- func (p InteractiveContinuePrinter) WithHandles(handles []string) *InteractiveContinuePrinter
- func (p InteractiveContinuePrinter) WithOptions(options []string) *InteractiveContinuePrinter
- func (p InteractiveContinuePrinter) WithOptionsStyle(style *Style) *InteractiveContinuePrinter
- func (p InteractiveContinuePrinter) WithShowShortHandles(b ...bool) *InteractiveContinuePrinter
- func (p InteractiveContinuePrinter) WithSuffixStyle(style *Style) *InteractiveContinuePrinter
- func (p InteractiveContinuePrinter) WithTextStyle(style *Style) *InteractiveContinuePrinter
- type InteractiveMultiselectPrinter
- func (p *InteractiveMultiselectPrinter) Show(text ...string) ([]string, error)
- func (p InteractiveMultiselectPrinter) WithCheckmark(checkmark *Checkmark) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithDefaultOptions(options []string) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithDefaultText(text string) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithFilter(b ...bool) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithKeyConfirm(keyConfirm keys.KeyCode) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithKeySelect(keySelect keys.KeyCode) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithMaxHeight(maxHeight int) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveMultiselectPrinter
- func (p InteractiveMultiselectPrinter) WithOptions(options []string) *InteractiveMultiselectPrinter
- type InteractiveSelectPrinter
- func (p *InteractiveSelectPrinter) Show(text ...string) (string, error)
- func (p InteractiveSelectPrinter) WithDefaultOption(option string) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithDefaultText(text string) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithFilter(b ...bool) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithMaxHeight(maxHeight int) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveSelectPrinter
- func (p InteractiveSelectPrinter) WithOptions(options []string) *InteractiveSelectPrinter
- type InteractiveTextInputPrinter
- func (p InteractiveTextInputPrinter) Show(text ...string) (string, error)
- func (p InteractiveTextInputPrinter) WithDefaultText(text string) *InteractiveTextInputPrinter
- func (p InteractiveTextInputPrinter) WithDefaultValue(value string) *InteractiveTextInputPrinter
- func (p InteractiveTextInputPrinter) WithDelimiter(delimiter string) *InteractiveTextInputPrinter
- func (p InteractiveTextInputPrinter) WithMask(mask string) *InteractiveTextInputPrinter
- func (p InteractiveTextInputPrinter) WithMultiLine(multiLine ...bool) *InteractiveTextInputPrinter
- func (p InteractiveTextInputPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveTextInputPrinter
- func (p InteractiveTextInputPrinter) WithTextStyle(style *Style) *InteractiveTextInputPrinter
- type Letter
- type Letters
- type LeveledList
- type LeveledListItem
- type LivePrinter
- type LogFormatter
- type LogLevel
- type Logger
- func (l Logger) AppendKeyStyle(key string, style Style) *Logger
- func (l Logger) AppendKeyStyles(styles map[string]Style) *Logger
- func (l Logger) Args(args ...any) []LoggerArgument
- func (l Logger) ArgsFromMap(m map[string]any) []LoggerArgument
- func (l Logger) CanPrint(level LogLevel) bool
- func (l Logger) Debug(msg string, args ...[]LoggerArgument)
- func (l Logger) Error(msg string, args ...[]LoggerArgument)
- func (l Logger) Fatal(msg string, args ...[]LoggerArgument)
- func (l Logger) Info(msg string, args ...[]LoggerArgument)
- func (l Logger) Print(msg string, args ...[]LoggerArgument)
- func (l Logger) Trace(msg string, args ...[]LoggerArgument)
- func (l Logger) Warn(msg string, args ...[]LoggerArgument)
- func (l Logger) WithCaller(b ...bool) *Logger
- func (l Logger) WithCallerOffset(offset int) *Logger
- func (l Logger) WithFormatter(formatter LogFormatter) *Logger
- func (l Logger) WithKeyStyles(styles map[string]Style) *Logger
- func (l Logger) WithLevel(level LogLevel) *Logger
- func (l Logger) WithMaxWidth(width int) *Logger
- func (l Logger) WithTime(b ...bool) *Logger
- func (l Logger) WithTimeFormat(format string) *Logger
- func (l Logger) WithWriter(writer io.Writer) *Logger
- type LoggerArgument
- type MultiPrinter
- func (p MultiPrinter) GenericStart() (*LivePrinter, error)
- func (p MultiPrinter) GenericStop() (*LivePrinter, error)
- func (p *MultiPrinter) NewWriter() io.Writer
- func (p *MultiPrinter) SetWriter(writer io.Writer)
- func (p *MultiPrinter) Start() (*MultiPrinter, error)
- func (p *MultiPrinter) Stop() (*MultiPrinter, error)
- func (p MultiPrinter) WithUpdateDelay(delay time.Duration) *MultiPrinter
- func (p MultiPrinter) WithWriter(writer io.Writer) *MultiPrinter
- type Panel
- type PanelPrinter
- func (p PanelPrinter) Render() error
- func (p PanelPrinter) Srender() (string, error)
- func (p PanelPrinter) WithBottomPadding(bottomPadding int) *PanelPrinter
- func (p PanelPrinter) WithBoxPrinter(boxPrinter BoxPrinter) *PanelPrinter
- func (p PanelPrinter) WithPadding(padding int) *PanelPrinter
- func (p PanelPrinter) WithPanels(panels Panels) *PanelPrinter
- func (p PanelPrinter) WithSameColumnWidth(b ...bool) *PanelPrinter
- func (p PanelPrinter) WithWriter(writer io.Writer) *PanelPrinter
- type Panels
- type ParagraphPrinter
- func (p *ParagraphPrinter) Print(a ...interface{}) *TextPrinter
- func (p *ParagraphPrinter) PrintOnError(a ...interface{}) *TextPrinter
- func (p *ParagraphPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
- func (p *ParagraphPrinter) Printf(format string, a ...interface{}) *TextPrinter
- func (p *ParagraphPrinter) Printfln(format string, a ...interface{}) *TextPrinter
- func (p *ParagraphPrinter) Println(a ...interface{}) *TextPrinter
- func (p ParagraphPrinter) Sprint(a ...interface{}) string
- func (p ParagraphPrinter) Sprintf(format string, a ...interface{}) string
- func (p ParagraphPrinter) Sprintfln(format string, a ...interface{}) string
- func (p ParagraphPrinter) Sprintln(a ...interface{}) string
- func (p ParagraphPrinter) WithMaxWidth(width int) *ParagraphPrinter
- func (p ParagraphPrinter) WithWriter(writer io.Writer) *ParagraphPrinter
- type Prefix
- type PrefixPrinter
- func (p PrefixPrinter) GetFormattedPrefix() string
- func (p *PrefixPrinter) Print(a ...interface{}) *TextPrinter
- func (p *PrefixPrinter) PrintOnError(a ...interface{}) *TextPrinter
- func (p *PrefixPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
- func (p *PrefixPrinter) Printf(format string, a ...interface{}) *TextPrinter
- func (p *PrefixPrinter) Printfln(format string, a ...interface{}) *TextPrinter
- func (p *PrefixPrinter) Println(a ...interface{}) *TextPrinter
- func (p *PrefixPrinter) Sprint(a ...interface{}) string
- func (p PrefixPrinter) Sprintf(format string, a ...interface{}) string
- func (p PrefixPrinter) Sprintfln(format string, a ...interface{}) string
- func (p PrefixPrinter) Sprintln(a ...interface{}) string
- func (p PrefixPrinter) WithDebugger(b ...bool) *PrefixPrinter
- func (p PrefixPrinter) WithFatal(b ...bool) *PrefixPrinter
- func (p PrefixPrinter) WithLineNumberOffset(offset int) *PrefixPrinter
- func (p PrefixPrinter) WithMessageStyle(style *Style) *PrefixPrinter
- func (p PrefixPrinter) WithPrefix(prefix Prefix) *PrefixPrinter
- func (p PrefixPrinter) WithScope(scope Scope) *PrefixPrinter
- func (p PrefixPrinter) WithShowLineNumber(b ...bool) *PrefixPrinter
- func (p PrefixPrinter) WithWriter(writer io.Writer) *PrefixPrinter
- type ProgressbarPrinter
- func (p *ProgressbarPrinter) Add(count int) *ProgressbarPrinter
- func (p *ProgressbarPrinter) GenericStart() (*LivePrinter, error)
- func (p *ProgressbarPrinter) GenericStop() (*LivePrinter, error)
- func (p *ProgressbarPrinter) GetElapsedTime() time.Duration
- func (p *ProgressbarPrinter) Increment() *ProgressbarPrinter
- func (p *ProgressbarPrinter) SetWriter(writer io.Writer)
- func (p ProgressbarPrinter) Start(title ...interface{}) (*ProgressbarPrinter, error)
- func (p *ProgressbarPrinter) Stop() (*ProgressbarPrinter, error)
- func (p *ProgressbarPrinter) UpdateTitle(title string) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithBarCharacter(char string) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithBarFiller(char string) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithBarStyle(style *Style) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithCurrent(current int) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithElapsedTimeRoundingFactor(duration time.Duration) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithLastCharacter(char string) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithMaxWidth(maxWidth int) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithRemoveWhenDone(b ...bool) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithShowCount(b ...bool) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithShowElapsedTime(b ...bool) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithShowPercentage(b ...bool) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithShowTitle(b ...bool) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithTitle(name string) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithTitleStyle(style *Style) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithTotal(total int) *ProgressbarPrinter
- func (p ProgressbarPrinter) WithWriter(writer io.Writer) *ProgressbarPrinter
- type RGB
- func (p RGB) Fade(min, max, current float32, end ...RGB) RGB
- func (p RGB) GetValues() (r, g, b uint8)
- func (p RGB) Print(a ...interface{}) *TextPrinter
- func (p RGB) PrintOnError(a ...interface{}) *TextPrinter
- func (p RGB) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
- func (p RGB) Printf(format string, a ...interface{}) *TextPrinter
- func (p RGB) Printfln(format string, a ...interface{}) *TextPrinter
- func (p RGB) Println(a ...interface{}) *TextPrinter
- func (p RGB) Sprint(a ...interface{}) string
- func (p RGB) Sprintf(format string, a ...interface{}) string
- func (p RGB) Sprintfln(format string, a ...interface{}) string
- func (p RGB) Sprintln(a ...interface{}) string
- func (p RGB) ToRGBStyle() RGBStyle
- type RGBStyle
- func (p RGBStyle) AddOptions(opts ...Color) RGBStyle
- func (p RGBStyle) Print(a ...interface{}) *TextPrinter
- func (p RGBStyle) PrintOnError(a ...interface{}) *TextPrinter
- func (p RGBStyle) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
- func (p RGBStyle) Printf(format string, a ...interface{}) *TextPrinter
- func (p RGBStyle) Printfln(format string, a ...interface{}) *TextPrinter
- func (p RGBStyle) Println(a ...interface{}) *TextPrinter
- func (p RGBStyle) Sprint(a ...interface{}) string
- func (p RGBStyle) Sprintf(format string, a ...interface{}) string
- func (p RGBStyle) Sprintfln(format string, a ...interface{}) string
- func (p RGBStyle) Sprintln(a ...interface{}) string
- type RenderPrinter
- type Scope
- type SectionPrinter
- func (p *SectionPrinter) Print(a ...interface{}) *TextPrinter
- func (p *SectionPrinter) PrintOnError(a ...interface{}) *TextPrinter
- func (p *SectionPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
- func (p *SectionPrinter) Printf(format string, a ...interface{}) *TextPrinter
- func (p *SectionPrinter) Printfln(format string, a ...interface{}) *TextPrinter
- func (p *SectionPrinter) Println(a ...interface{}) *TextPrinter
- func (p SectionPrinter) Sprint(a ...interface{}) string
- func (p SectionPrinter) Sprintf(format string, a ...interface{}) string
- func (p SectionPrinter) Sprintfln(format string, a ...interface{}) string
- func (p SectionPrinter) Sprintln(a ...interface{}) string
- func (p SectionPrinter) WithBottomPadding(padding int) *SectionPrinter
- func (p SectionPrinter) WithIndentCharacter(char string) *SectionPrinter
- func (p SectionPrinter) WithLevel(level int) *SectionPrinter
- func (p SectionPrinter) WithStyle(style *Style) *SectionPrinter
- func (p SectionPrinter) WithTopPadding(padding int) *SectionPrinter
- func (p SectionPrinter) WithWriter(writer io.Writer) *SectionPrinter
- type SlogHandler
- type SpinnerPrinter
- func (s *SpinnerPrinter) Fail(message ...interface{})
- func (s *SpinnerPrinter) GenericStart() (*LivePrinter, error)
- func (s *SpinnerPrinter) GenericStop() (*LivePrinter, error)
- func (s *SpinnerPrinter) Info(message ...interface{})
- func (p *SpinnerPrinter) SetWriter(writer io.Writer)
- func (s SpinnerPrinter) Start(text ...interface{}) (*SpinnerPrinter, error)
- func (s *SpinnerPrinter) Stop() error
- func (s *SpinnerPrinter) Success(message ...interface{})
- func (s *SpinnerPrinter) UpdateText(text string)
- func (s *SpinnerPrinter) Warning(message ...interface{})
- func (s SpinnerPrinter) WithDelay(delay time.Duration) *SpinnerPrinter
- func (s SpinnerPrinter) WithMessageStyle(style *Style) *SpinnerPrinter
- func (s SpinnerPrinter) WithRemoveWhenDone(b ...bool) *SpinnerPrinter
- func (s SpinnerPrinter) WithSequence(sequence ...string) *SpinnerPrinter
- func (s SpinnerPrinter) WithShowTimer(b ...bool) *SpinnerPrinter
- func (s SpinnerPrinter) WithStyle(style *Style) *SpinnerPrinter
- func (s SpinnerPrinter) WithText(text string) *SpinnerPrinter
- func (s SpinnerPrinter) WithTimerRoundingFactor(factor time.Duration) *SpinnerPrinter
- func (s SpinnerPrinter) WithTimerStyle(style *Style) *SpinnerPrinter
- func (p SpinnerPrinter) WithWriter(writer io.Writer) *SpinnerPrinter
- type Style
- func (s Style) Add(styles ...Style) Style
- func (s Style) Code() string
- func (s Style) Print(a ...interface{})
- func (s Style) Printf(format string, a ...interface{})
- func (s Style) Printfln(format string, a ...interface{})
- func (s Style) Println(a ...interface{})
- func (s Style) RemoveColor(colors ...Color) Style
- func (s Style) Sprint(a ...interface{}) string
- func (s Style) Sprintf(format string, a ...interface{}) string
- func (s Style) Sprintfln(format string, a ...interface{}) string
- func (s Style) Sprintln(a ...interface{}) string
- func (s Style) String() string
- type TableData
- type TablePrinter
- func (p TablePrinter) Render() error
- func (p TablePrinter) Srender() (string, error)
- func (p TablePrinter) WithBoxed(b ...bool) *TablePrinter
- func (p TablePrinter) WithCSVReader(reader *csv.Reader) *TablePrinter
- func (p TablePrinter) WithData(data [][]string) *TablePrinter
- func (p TablePrinter) WithHasHeader(b ...bool) *TablePrinter
- func (p TablePrinter) WithHeaderRowSeparator(separator string) *TablePrinter
- func (p TablePrinter) WithHeaderRowSeparatorStyle(style *Style) *TablePrinter
- func (p TablePrinter) WithHeaderStyle(style *Style) *TablePrinter
- func (p TablePrinter) WithLeftAlignment(b ...bool) *TablePrinter
- func (p TablePrinter) WithRightAlignment(b ...bool) *TablePrinter
- func (p TablePrinter) WithRowSeparator(separator string) *TablePrinter
- func (p TablePrinter) WithRowSeparatorStyle(style *Style) *TablePrinter
- func (p TablePrinter) WithSeparator(separator string) *TablePrinter
- func (p TablePrinter) WithSeparatorStyle(style *Style) *TablePrinter
- func (p TablePrinter) WithStyle(style *Style) *TablePrinter
- func (p TablePrinter) WithWriter(writer io.Writer) *TablePrinter
- type TextPrinter
- type Theme
- func (t Theme) WithBarLabelStyle(style Style) Theme
- func (t Theme) WithBarStyle(style Style) Theme
- func (t Theme) WithBoxStyle(style Style) Theme
- func (t Theme) WithBoxTextStyle(style Style) Theme
- func (t Theme) WithBulletListBulletStyle(style Style) Theme
- func (t Theme) WithBulletListTextStyle(style Style) Theme
- func (t Theme) WithDebugMessageStyle(style Style) Theme
- func (t Theme) WithDebugPrefixStyle(style Style) Theme
- func (t Theme) WithDescriptionMessageStyle(style Style) Theme
- func (t Theme) WithDescriptionPrefixStyle(style Style) Theme
- func (t Theme) WithErrorMessageStyle(style Style) Theme
- func (t Theme) WithErrorPrefixStyle(style Style) Theme
- func (t Theme) WithFatalMessageStyle(style Style) Theme
- func (t Theme) WithFatalPrefixStyle(style Style) Theme
- func (t Theme) WithHighlightStyle(style Style) Theme
- func (t Theme) WithInfoMessageStyle(style Style) Theme
- func (t Theme) WithInfoPrefixStyle(style Style) Theme
- func (t Theme) WithLetterStyle(style Style) Theme
- func (t Theme) WithPrimaryStyle(style Style) Theme
- func (t Theme) WithSecondaryStyle(style Style) Theme
- func (t Theme) WithSuccessMessageStyle(style Style) Theme
- func (t Theme) WithSuccessPrefixStyle(style Style) Theme
- func (t Theme) WithTreeStyle(style Style) Theme
- func (t Theme) WithTreeTextStyle(style Style) Theme
- func (t Theme) WithWarningMessageStyle(style Style) Theme
- func (t Theme) WithWarningPrefixStyle(style Style) Theme
- type TreeNode
- type TreePrinter
- func (p TreePrinter) Render() error
- func (p TreePrinter) Srender() (string, error)
- func (p TreePrinter) WithHorizontalString(s string) *TreePrinter
- func (p TreePrinter) WithIndent(indent int) *TreePrinter
- func (p TreePrinter) WithRoot(root TreeNode) *TreePrinter
- func (p TreePrinter) WithTextStyle(style *Style) *TreePrinter
- func (p TreePrinter) WithTopRightCornerString(s string) *TreePrinter
- func (p TreePrinter) WithTopRightDownStringOngoing(s string) *TreePrinter
- func (p TreePrinter) WithTreeStyle(style *Style) *TreePrinter
- func (p TreePrinter) WithVerticalString(s string) *TreePrinter
- func (p TreePrinter) WithWriter(writer io.Writer) *TreePrinter
Constants ¶
This section is empty.
Variables ¶
var ( // Red is an alias for FgRed.Sprint. Red = FgRed.Sprint // Cyan is an alias for FgCyan.Sprint. Cyan = FgCyan.Sprint // Gray is an alias for FgGray.Sprint. Gray = FgGray.Sprint // Blue is an alias for FgBlue.Sprint. Blue = FgBlue.Sprint // Black is an alias for FgBlack.Sprint. Black = FgBlack.Sprint // Green is an alias for FgGreen.Sprint. Green = FgGreen.Sprint // White is an alias for FgWhite.Sprint. White = FgWhite.Sprint // Yellow is an alias for FgYellow.Sprint. Yellow = FgYellow.Sprint // Magenta is an alias for FgMagenta.Sprint. Magenta = FgMagenta.Sprint // Normal is an alias for FgDefault.Sprint. Normal = FgDefault.Sprint // LightRed is a shortcut for FgLightRed.Sprint. LightRed = FgLightRed.Sprint // LightCyan is a shortcut for FgLightCyan.Sprint. LightCyan = FgLightCyan.Sprint // LightBlue is a shortcut for FgLightBlue.Sprint. LightBlue = FgLightBlue.Sprint // LightGreen is a shortcut for FgLightGreen.Sprint. LightGreen = FgLightGreen.Sprint // LightWhite is a shortcut for FgLightWhite.Sprint. LightWhite = FgLightWhite.Sprint // LightYellow is a shortcut for FgLightYellow.Sprint. LightYellow = FgLightYellow.Sprint // LightMagenta is a shortcut for FgLightMagenta.Sprint. LightMagenta = FgLightMagenta.Sprint )
var ( // ErrTerminalSizeNotDetectable - the terminal size can not be detected and the fallback values are used. ErrTerminalSizeNotDetectable = errors.New("terminal size could not be detected - using fallback value") // ErrHexCodeIsInvalid - the given HEX code is invalid. ErrHexCodeIsInvalid = errors.New("hex code is not valid") // ErrKeyWithoutValue - an odd number of arguments was passed to a pterm Logger's Args method. ErrKeyWithoutValue = "ERROR: key_without_value" )
var ( // Info returns a PrefixPrinter, which can be used to print text with an "info" Prefix. Info = PrefixPrinter{ MessageStyle: &ThemeDefault.InfoMessageStyle, Prefix: Prefix{ Style: &ThemeDefault.InfoPrefixStyle, Text: "INFO", }, } // Warning returns a PrefixPrinter, which can be used to print text with a "warning" Prefix. Warning = PrefixPrinter{ MessageStyle: &ThemeDefault.WarningMessageStyle, Prefix: Prefix{ Style: &ThemeDefault.WarningPrefixStyle, Text: "WARNING", }, } // Success returns a PrefixPrinter, which can be used to print text with a "success" Prefix. Success = PrefixPrinter{ MessageStyle: &ThemeDefault.SuccessMessageStyle, Prefix: Prefix{ Style: &ThemeDefault.SuccessPrefixStyle, Text: "SUCCESS", }, } // Error returns a PrefixPrinter, which can be used to print text with an "error" Prefix. Error = PrefixPrinter{ MessageStyle: &ThemeDefault.ErrorMessageStyle, Prefix: Prefix{ Style: &ThemeDefault.ErrorPrefixStyle, Text: " ERROR ", }, } // Fatal returns a PrefixPrinter, which can be used to print text with an "fatal" Prefix. // NOTICE: Fatal terminates the application immediately! Fatal = PrefixPrinter{ MessageStyle: &ThemeDefault.FatalMessageStyle, Prefix: Prefix{ Style: &ThemeDefault.FatalPrefixStyle, Text: " FATAL ", }, Fatal: true, } // 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 = PrefixPrinter{ MessageStyle: &ThemeDefault.DebugMessageStyle, Prefix: Prefix{ Text: " DEBUG ", Style: &ThemeDefault.DebugPrefixStyle, }, Debugger: true, } // Description returns a PrefixPrinter, which can be used to print text with a "description" Prefix. Description = PrefixPrinter{ MessageStyle: &ThemeDefault.DescriptionMessageStyle, Prefix: Prefix{ Style: &ThemeDefault.DescriptionPrefixStyle, Text: "Description", }, } )
var ( // Output completely disables output from pterm if set to false. Can be used in CLI application quiet mode. Output = true // PrintDebugMessages sets if messages printed by the DebugPrinter should be printed. PrintDebugMessages = false // RawOutput is set to true if pterm.DisableStyling() was called. // The variable indicates that PTerm will not add additional styling to text. // Use pterm.DisableStyling() or pterm.EnableStyling() to change this variable. // Changing this variable directly, will disable or enable the output of colored text. RawOutput = false )
var ActiveProgressBarPrinters []*ProgressbarPrinter
ActiveProgressBarPrinters contains all running ProgressbarPrinters. Generally, there should only be one active ProgressbarPrinter at a time.
var DefaultArea = AreaPrinter{}
DefaultArea is the default area printer.
var ( // DefaultBarChart is the default BarChartPrinter. DefaultBarChart = BarChartPrinter{ Horizontal: false, VerticalBarCharacter: "██", HorizontalBarCharacter: "█", Height: GetTerminalHeight() * 2 / 3, Width: GetTerminalWidth() * 2 / 3, } )
var ( // DefaultBasicText returns a default BasicTextPrinter, which can be used to print text as is. // No default style is present for BasicTextPrinter. DefaultBasicText = BasicTextPrinter{} )
var DefaultBigText = BigTextPrinter{ BigCharacters: map[string]string{ "a": ` █████ ██ ██ ███████ ██ ██ ██ ██ `, "A": ` █████ ██ ██ ███████ ██ ██ ██ ██ `, "b": `██████ ██ ██ ██████ ██ ██ ██████`, "B": `██████ ██ ██ ██████ ██ ██ ██████`, "c": ` ██████ ██ ██ ██ ██████`, "C": ` ██████ ██ ██ ██ ██████`, "d": `██████ ██ ██ ██ ██ ██ ██ ██████ `, "D": `██████ ██ ██ ██ ██ ██ ██ ██████ `, "e": `███████ ██ █████ ██ ███████`, "E": `███████ ██ █████ ██ ███████`, "f": `███████ ██ █████ ██ ██ `, "F": `███████ ██ █████ ██ ██ `, "g": ` ██████ ██ ██ ███ ██ ██ ██████ `, "G": ` ██████ ██ ██ ███ ██ ██ ██████ `, "h": `██ ██ ██ ██ ███████ ██ ██ ██ ██ `, "H": `██ ██ ██ ██ ███████ ██ ██ ██ ██ `, "i": `██ ██ ██ ██ ██`, "I": `██ ██ ██ ██ ██`, "j": ` ██ ██ ██ ██ ██ █████ `, "J": ` ██ ██ ██ ██ ██ █████ `, "k": `██ ██ ██ ██ █████ ██ ██ ██ ██`, "K": `██ ██ ██ ██ █████ ██ ██ ██ ██`, "l": `██ ██ ██ ██ ███████ `, "L": `██ ██ ██ ██ ███████ `, "m": `███ ███ ████ ████ ██ ████ ██ ██ ██ ██ ██ ██`, "M": `███ ███ ████ ████ ██ ████ ██ ██ ██ ██ ██ ██`, "n": `███ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ████`, "N": `███ ██ ████ ██ ██ ██ ██ ██ ██ ██ ██ ████`, "o": ` ██████ ██ ██ ██ ██ ██ ██ ██████ `, "O": ` ██████ ██ ██ ██ ██ ██ ██ ██████ `, "p": `██████ ██ ██ ██████ ██ ██ `, "P": `██████ ██ ██ ██████ ██ ██ `, "q": ` ██████ ██ ██ ██ ██ ██ ▄▄ ██ ██████ ▀▀ `, "Q": ` ██████ ██ ██ ██ ██ ██ ▄▄ ██ ██████ ▀▀ `, "r": `██████ ██ ██ ██████ ██ ██ ██ ██`, "R": `██████ ██ ██ ██████ ██ ██ ██ ██`, "s": `███████ ██ ███████ ██ ███████`, "S": `███████ ██ ███████ ██ ███████`, "t": `████████ ██ ██ ██ ██ `, "T": `████████ ██ ██ ██ ██ `, "u": `██ ██ ██ ██ ██ ██ ██ ██ ██████ `, "U": `██ ██ ██ ██ ██ ██ ██ ██ ██████ `, "v": `██ ██ ██ ██ ██ ██ ██ ██ ████ `, "V": `██ ██ ██ ██ ██ ██ ██ ██ ████ `, "w": `██ ██ ██ ██ ██ █ ██ ██ ███ ██ ███ ███ `, "W": `██ ██ ██ ██ ██ █ ██ ██ ███ ██ ███ ███ `, "x": `██ ██ ██ ██ ███ ██ ██ ██ ██ `, "X": `██ ██ ██ ██ ███ ██ ██ ██ ██ `, "y": `██ ██ ██ ██ ████ ██ ██ `, "Y": `██ ██ ██ ██ ████ ██ ██ `, "z": `███████ ███ ███ ███ ███████`, "Z": `███████ ███ ███ ███ ███████`, "0": ` ██████ ██ ████ ██ ██ ██ ████ ██ ██████ `, "1": ` ██ ███ ██ ██ ██ `, "2": `██████ ██ █████ ██ ███████ `, "3": `██████ ██ █████ ██ ██████ `, "4": `██ ██ ██ ██ ███████ ██ ██ `, "5": `███████ ██ ███████ ██ ███████`, "6": ` ██████ ██ ███████ ██ ██ ██████ `, "7": `███████ ██ ██ ██ ██`, "8": ` █████ ██ ██ █████ ██ ██ █████ `, "9": ` █████ ██ ██ ██████ ██ █████ `, " ": " ", "!": `██ ██ ██ ██ `, "$": `▄▄███▄▄· ██ ███████ ██ ███████ ▀▀▀ `, "%": `██ ██ ██ ██ ██ ██ ██`, "/": ` ██ ██ ██ ██ ██ `, "(": ` ██ ██ ██ ██ ██ `, ")": `██ ██ ██ ██ ██ `, "?": `██████ ██ ▄███ ▀▀ ██ `, "[": `███ ██ ██ ██ ███`, "]": `███ ██ ██ ██ ███ `, ".": ` ██`, ",": ` ▄█`, "-": ` █████ `, "<": ` ██ ██ ██ ██ ██ `, ">": `██ ██ ██ ██ ██ `, "*": ` ▄ ██ ▄ ████ ▀ ██ ▀ `, "#": ` ██ ██ ████████ ██ ██ ████████ ██ ██ `, "_": ` ███████ `, ":": ` ██ ██ `, "°": ` ████ ██ ██ ████ `, }, }
DefaultBigText contains default values for BigTextPrinter.
var DefaultBox = BoxPrinter{ VerticalString: "|", TopRightCornerString: "└", TopLeftCornerString: "┘", BottomLeftCornerString: "┐", BottomRightCornerString: "┌", HorizontalString: "─", BoxStyle: &ThemeDefault.BoxStyle, TextStyle: &ThemeDefault.BoxTextStyle, RightPadding: 1, LeftPadding: 1, TopPadding: 0, BottomPadding: 0, TitleTopLeft: true, }
DefaultBox is the default BoxPrinter.
var DefaultBulletList = BulletListPrinter{ Bullet: "•", TextStyle: &ThemeDefault.BulletListTextStyle, BulletStyle: &ThemeDefault.BulletListBulletStyle, }
DefaultBulletList contains standards, which can be used to print a BulletListPrinter.
var DefaultCenter = CenterPrinter{ CenterEachLineSeparately: false, }
DefaultCenter is the default CenterPrinter.
var ( // DefaultHeader returns the printer for a default header text. // Defaults to LightWhite, Bold Text and a Gray DefaultHeader background. DefaultHeader = HeaderPrinter{ TextStyle: &ThemeDefault.HeaderTextStyle, BackgroundStyle: &ThemeDefault.HeaderBackgroundStyle, Margin: 5, } )
var DefaultHeatmap = HeatmapPrinter{ AxisStyle: &ThemeDefault.HeatmapHeaderStyle, SeparatorStyle: &ThemeDefault.HeatmapSeparatorStyle, VerticalSeparator: "│", TopRightCornerSeparator: "└", TopLeftCornerSeparator: "┘", BottomLeftCornerSeparator: "┐", BottomRightCornerSeparator: "┌", HorizontalSeparator: "─", TSeparator: "┬", TReverseSeparator: "┴", LSeparator: "├", LReverseSeparator: "┤", TCrossSeparator: "┼", LegendLabel: "Legend", Boxed: true, Grid: true, Legend: true, TextRGB: RGB{0, 0, 0, false}, RGBRange: []RGB{{R: 255, G: 0, B: 0, Background: true}, {R: 255, G: 165, B: 0, Background: true}, {R: 0, G: 255, B: 0, Background: true}}, TextColor: FgBlack, Colors: []Color{BgRed, BgLightRed, BgYellow, BgLightYellow, BgLightGreen, BgGreen}, EnableRGB: false, }
DefaultHeatmap contains standards, which can be used to print a HeatmapPrinter.
var DefaultInteractiveConfirm = InteractiveConfirmPrinter{ DefaultValue: false, DefaultText: "Please confirm", TextStyle: &ThemeDefault.PrimaryStyle, ConfirmText: "Yes", ConfirmStyle: &ThemeDefault.SuccessMessageStyle, RejectText: "No", RejectStyle: &ThemeDefault.ErrorMessageStyle, SuffixStyle: &ThemeDefault.SecondaryStyle, Delimiter: ": ", }
DefaultInteractiveConfirm is the default InteractiveConfirm printer. Pressing "y" will return true, "n" will return false. Pressing enter without typing "y" or "n" will return the configured default value (by default set to "no").
var DefaultInteractiveContinue = InteractiveContinuePrinter{ DefaultValueIndex: 0, DefaultText: "Do you want to continue", TextStyle: &ThemeDefault.PrimaryStyle, Options: []string{"yes", "no", "all", "cancel"}, OptionsStyle: &ThemeDefault.SuccessMessageStyle, SuffixStyle: &ThemeDefault.SecondaryStyle, Delimiter: ": ", }
DefaultInteractiveContinue is the default InteractiveContinue printer. Pressing "y" will return yes, "n" will return no, "a" returns all and "s" returns stop. Pressing enter without typing any letter will return the configured default value (by default set to "yes", the fisrt option).
var ( // DefaultInteractiveMultiselect is the default InteractiveMultiselect printer. DefaultInteractiveMultiselect = InteractiveMultiselectPrinter{ TextStyle: &ThemeDefault.PrimaryStyle, DefaultText: "Please select your options", Options: []string{}, OptionStyle: &ThemeDefault.DefaultText, DefaultOptions: []string{}, MaxHeight: 5, Selector: ">", SelectorStyle: &ThemeDefault.SecondaryStyle, Filter: true, KeySelect: keys.Enter, KeyConfirm: keys.Tab, Checkmark: &ThemeDefault.Checkmark, } )
var ( // DefaultInteractiveSelect is the default InteractiveSelect printer. DefaultInteractiveSelect = InteractiveSelectPrinter{ TextStyle: &ThemeDefault.PrimaryStyle, DefaultText: "Please select an option", Options: []string{}, OptionStyle: &ThemeDefault.DefaultText, DefaultOption: "", MaxHeight: 5, Selector: ">", SelectorStyle: &ThemeDefault.SecondaryStyle, Filter: true, } )
var DefaultInteractiveTextInput = InteractiveTextInputPrinter{ DefaultText: "Input text", Delimiter: ": ", TextStyle: &ThemeDefault.PrimaryStyle, Mask: "", }
DefaultInteractiveTextInput is the default InteractiveTextInput printer.
var DefaultLogger = Logger{ Formatter: LogFormatterColorful, Writer: os.Stdout, Level: LogLevelInfo, ShowTime: true, TimeFormat: "2006-01-02 15:04:05", MaxWidth: 80, KeyStyles: map[string]Style{ "error": *NewStyle(FgRed, Bold), "err": *NewStyle(FgRed, Bold), "caller": *NewStyle(FgGray, Bold), }, }
DefaultLogger is the default logger.
var DefaultMultiPrinter = MultiPrinter{ Writer: os.Stdout, UpdateDelay: time.Millisecond * 200, // contains filtered or unexported fields }
var DefaultPanel = PanelPrinter{
Padding: 1,
}
DefaultPanel is the default PanelPrinter.
var DefaultParagraph = ParagraphPrinter{ MaxWidth: GetTerminalWidth(), }
DefaultParagraph contains the default values for a ParagraphPrinter.
var DefaultProgressbar = ProgressbarPrinter{ Total: 100, BarCharacter: "█", LastCharacter: "█", ElapsedTimeRoundingFactor: time.Second, BarStyle: &ThemeDefault.ProgressbarBarStyle, TitleStyle: &ThemeDefault.ProgressbarTitleStyle, ShowTitle: true, ShowCount: true, ShowPercentage: true, ShowElapsedTime: true, BarFiller: Gray("█"), MaxWidth: 80, Writer: os.Stdout, }
DefaultProgressbar is the default ProgressbarPrinter.
var DefaultSection = SectionPrinter{ Style: &ThemeDefault.SectionStyle, Level: 1, TopPadding: 1, BottomPadding: 1, IndentCharacter: "#", }
DefaultSection is the default section printer.
var DefaultSpinner = SpinnerPrinter{ Sequence: []string{"▀ ", " ▀", " ▄", "▄ "}, Style: &ThemeDefault.SpinnerStyle, Delay: time.Millisecond * 200, ShowTimer: true, TimerRoundingFactor: time.Second, TimerStyle: &ThemeDefault.TimerStyle, MessageStyle: &ThemeDefault.SpinnerTextStyle, InfoPrinter: &Info, SuccessPrinter: &Success, FailPrinter: &Error, WarningPrinter: &Warning, }
DefaultSpinner is the default SpinnerPrinter.
var DefaultTable = TablePrinter{ Style: &ThemeDefault.TableStyle, HeaderStyle: &ThemeDefault.TableHeaderStyle, HeaderRowSeparator: "", HeaderRowSeparatorStyle: &ThemeDefault.TableSeparatorStyle, Separator: " | ", SeparatorStyle: &ThemeDefault.TableSeparatorStyle, RowSeparator: "", RowSeparatorStyle: &ThemeDefault.TableSeparatorStyle, LeftAlignment: true, RightAlignment: false, }
DefaultTable contains standards, which can be used to print a TablePrinter.
var DefaultTree = TreePrinter{ TreeStyle: &ThemeDefault.TreeStyle, TextStyle: &ThemeDefault.TreeTextStyle, TopRightCornerString: "└", HorizontalString: "─", TopRightDownString: "├", VerticalString: "│", RightDownLeftString: "┬", Indent: 2, }
DefaultTree contains standards, which can be used to render a TreePrinter.
var FallbackTerminalHeight = 10
FallbackTerminalHeight is the value used for GetTerminalHeight, if the actual height can not be detected You can override that value if necessary.
var FallbackTerminalWidth = 80
FallbackTerminalWidth is the value used for GetTerminalWidth, if the actual width can not be detected You can override that value if necessary.
var ( // GrayBoxStyle wraps text in a gray box. GrayBoxStyle = NewStyle(BgGray, FgLightWhite) )
var PrintColor = true
PrintColor is false if PTerm should not print colored output.
var ( // ThemeDefault is the default theme used by PTerm. // If this variable is overwritten, the new value is used as default theme. ThemeDefault = Theme{ DefaultText: Style{FgDefault, BgDefault}, PrimaryStyle: Style{FgLightCyan}, SecondaryStyle: Style{FgLightMagenta}, HighlightStyle: Style{Bold, FgYellow}, InfoMessageStyle: Style{FgLightCyan}, InfoPrefixStyle: Style{FgBlack, BgCyan}, SuccessMessageStyle: Style{FgGreen}, SuccessPrefixStyle: Style{FgBlack, BgGreen}, WarningMessageStyle: Style{FgYellow}, WarningPrefixStyle: Style{FgBlack, BgYellow}, ErrorMessageStyle: Style{FgLightRed}, ErrorPrefixStyle: Style{FgBlack, BgLightRed}, FatalMessageStyle: Style{FgLightRed}, FatalPrefixStyle: Style{FgBlack, BgLightRed}, DescriptionMessageStyle: Style{FgDefault}, DescriptionPrefixStyle: Style{FgLightWhite, BgDarkGray}, ScopeStyle: Style{FgGray}, ProgressbarBarStyle: Style{FgCyan}, ProgressbarTitleStyle: Style{FgLightCyan}, HeaderTextStyle: Style{FgLightWhite, Bold}, HeaderBackgroundStyle: Style{BgGray}, SpinnerStyle: Style{FgLightCyan}, SpinnerTextStyle: Style{FgLightWhite}, TableStyle: Style{FgDefault}, TableHeaderStyle: Style{FgLightCyan}, TableSeparatorStyle: Style{FgGray}, HeatmapStyle: Style{FgDefault}, HeatmapHeaderStyle: Style{FgLightCyan}, HeatmapSeparatorStyle: Style{FgDefault}, SectionStyle: Style{Bold, FgYellow}, BulletListTextStyle: Style{FgDefault}, BulletListBulletStyle: Style{FgGray}, TreeStyle: Style{FgGray}, TreeTextStyle: Style{FgDefault}, LetterStyle: Style{FgDefault}, DebugMessageStyle: Style{FgGray}, DebugPrefixStyle: Style{FgBlack, BgGray}, BoxStyle: Style{FgDefault}, BoxTextStyle: Style{FgDefault}, BarLabelStyle: Style{FgLightCyan}, BarStyle: Style{FgCyan}, TimerStyle: Style{FgGray}, Checkmark: Checkmark{ Checked: Green("✓"), Unchecked: Red("✗"), }, } )
Functions ¶
func DisableDebugMessages ¶ added in v0.9.0
func DisableDebugMessages()
DisableDebugMessages disables the output of debug printers.
func DisableOutput ¶ added in v0.5.1
func DisableOutput()
DisableOutput disables the output of PTerm.
func DisableStyling ¶ added in v0.12.15
func DisableStyling()
DisableStyling sets PTerm to RawOutput mode and disables all of PTerms styling. You can use this to print to text files etc. This also calls DisableColor.
func EnableDebugMessages ¶ added in v0.9.0
func EnableDebugMessages()
EnableDebugMessages enables the output of debug printers.
func EnableStyling ¶ added in v0.12.15
func EnableStyling()
EnableStyling enables the default PTerm styling. This also calls EnableColor.
func Fprint ¶ added in v0.1.0
Fprint formats using the default formats for its operands and writes to w. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func Fprintln ¶ added in v0.1.0
Fprintln formats using the default formats for its operands and writes to w. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func GetTerminalHeight ¶ added in v0.1.0
func GetTerminalHeight() int
GetTerminalHeight returns the terminal height of the active terminal.
func GetTerminalSize ¶ added in v0.1.0
GetTerminalSize returns the width and the height of the active terminal.
func GetTerminalWidth ¶ added in v0.1.0
func GetTerminalWidth() int
GetTerminalWidth returns the terminal width of the active terminal.
func Print ¶
func Print(a ...interface{})
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func PrintOnError ¶ added in v0.12.19
func PrintOnError(a ...interface{})
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func PrintOnErrorf ¶ added in v0.12.33
func PrintOnErrorf(format string, a ...interface{})
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func Printf ¶
func Printf(format string, a ...interface{})
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func Printfln ¶ added in v0.12.14
func Printfln(format string, a ...interface{})
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func Println ¶
func Println(a ...interface{})
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func Printo ¶ added in v0.1.0
func Printo(a ...interface{})
Printo overrides the current line in a terminal. If the current line is empty, the text will be printed like with pterm.Print. Example:
pterm.Printo("Hello, World") time.Sleep(time.Second) pterm.Printo("Hello, Earth!")
func RecalculateTerminalSize ¶ added in v0.12.34
func RecalculateTerminalSize()
RecalculateTerminalSize updates already initialized terminal dimensions. Has to be called after a terminal resize to guarantee proper rendering. Applies only to new instances.
func RemoveColorFromString ¶ added in v0.4.0
func RemoveColorFromString(a ...interface{}) string
RemoveColorFromString removes color codes from a string.
func SetDefaultOutput ¶ added in v0.3.1
SetDefaultOutput sets the default output of pterm.
func SetForcedTerminalSize ¶ added in v0.12.34
setForcedTerminalSize turns off terminal size autodetection. Usuful for unified tests.
func Sprint ¶
func Sprint(a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func Sprintfln ¶ added in v0.12.14
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
Types ¶
type AreaPrinter ¶ added in v0.12.18
type AreaPrinter struct { RemoveWhenDone bool Fullscreen bool Center bool // contains filtered or unexported fields }
AreaPrinter prints an area which can be updated easily. use this printer for live output like charts, algorithm visualizations, simulations and even games.
func (*AreaPrinter) Clear ¶ added in v0.12.32
func (p *AreaPrinter) Clear()
Clear is a Wrapper function that clears the content of the Area moves the cursor to the bottom of the terminal, clears n lines upwards from the current position and moves the cursor again.
func (*AreaPrinter) GenericStart ¶ added in v0.12.18
func (p *AreaPrinter) GenericStart() (*LivePrinter, error)
GenericStart runs Start, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Start instead of this in your program.
func (*AreaPrinter) GenericStop ¶ added in v0.12.18
func (p *AreaPrinter) GenericStop() (*LivePrinter, error)
GenericStop runs Stop, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Stop instead of this in your program.
func (*AreaPrinter) GetContent ¶ added in v0.12.18
func (p *AreaPrinter) GetContent() string
GetContent returns the current area content.
func (*AreaPrinter) SetWriter ¶ added in v0.12.66
func (p *AreaPrinter) SetWriter(writer io.Writer)
SetWriter sets the writer for the AreaPrinter.
func (*AreaPrinter) Start ¶ added in v0.12.18
func (p *AreaPrinter) Start(text ...interface{}) (*AreaPrinter, error)
Start the AreaPrinter.
func (*AreaPrinter) Stop ¶ added in v0.12.18
func (p *AreaPrinter) Stop() error
Stop terminates the AreaPrinter immediately. The AreaPrinter will not resolve into anything.
func (*AreaPrinter) Update ¶ added in v0.12.18
func (p *AreaPrinter) Update(text ...interface{})
Update overwrites the content of the AreaPrinter. Can be used live.
func (AreaPrinter) WithCenter ¶ added in v0.12.18
func (p AreaPrinter) WithCenter(b ...bool) *AreaPrinter
WithCenter centers the AreaPrinter content to the terminal.
func (AreaPrinter) WithFullscreen ¶ added in v0.12.18
func (p AreaPrinter) WithFullscreen(b ...bool) *AreaPrinter
WithFullscreen sets the AreaPrinter height the same height as the terminal, making it fullscreen.
func (AreaPrinter) WithRemoveWhenDone ¶ added in v0.12.18
func (p AreaPrinter) WithRemoveWhenDone(b ...bool) *AreaPrinter
WithRemoveWhenDone removes the AreaPrinter content after it is stopped.
type Bar ¶ added in v0.12.7
Bar is used in bar charts.
func (Bar) WithLabelStyle ¶ added in v0.12.7
WithLabelStyle returns a new Bar with a specific option.
type BarChartPrinter ¶ added in v0.12.7
type BarChartPrinter struct { Writer io.Writer Bars Bars Horizontal bool ShowValue bool // Height sets the maximum height of a vertical bar chart. // The default is calculated to fit into the terminal. // Ignored if Horizontal is set to true. Height int // Width sets the maximum width of a horizontal bar chart. // The default is calculated to fit into the terminal. // Ignored if Horizontal is set to false. Width int VerticalBarCharacter string HorizontalBarCharacter string }
BarChartPrinter is used to print bar charts.
func (BarChartPrinter) Render ¶ added in v0.12.7
func (p BarChartPrinter) Render() error
Render prints the Template to the terminal.
func (BarChartPrinter) Srender ¶ added in v0.12.7
func (p BarChartPrinter) Srender() (string, error)
Srender renders the BarChart as a string.
func (BarChartPrinter) WithBars ¶ added in v0.12.7
func (p BarChartPrinter) WithBars(bars Bars) *BarChartPrinter
WithBars returns a new BarChartPrinter with a specific option.
func (BarChartPrinter) WithHeight ¶ added in v0.12.7
func (p BarChartPrinter) WithHeight(value int) *BarChartPrinter
WithHeight returns a new BarChartPrinter with a specific option.
func (BarChartPrinter) WithHorizontal ¶ added in v0.12.7
func (p BarChartPrinter) WithHorizontal(b ...bool) *BarChartPrinter
WithHorizontal returns a new BarChartPrinter with a specific option.
func (BarChartPrinter) WithHorizontalBarCharacter ¶ added in v0.12.7
func (p BarChartPrinter) WithHorizontalBarCharacter(char string) *BarChartPrinter
WithHorizontalBarCharacter returns a new BarChartPrinter with a specific option.
func (BarChartPrinter) WithShowValue ¶ added in v0.12.7
func (p BarChartPrinter) WithShowValue(b ...bool) *BarChartPrinter
WithShowValue returns a new BarChartPrinter with a specific option.
func (BarChartPrinter) WithVerticalBarCharacter ¶ added in v0.12.7
func (p BarChartPrinter) WithVerticalBarCharacter(char string) *BarChartPrinter
WithVerticalBarCharacter returns a new BarChartPrinter with a specific option.
func (BarChartPrinter) WithWidth ¶ added in v0.12.7
func (p BarChartPrinter) WithWidth(value int) *BarChartPrinter
WithWidth returns a new BarChartPrinter with a specific option.
func (BarChartPrinter) WithWriter ¶ added in v0.12.40
func (p BarChartPrinter) WithWriter(writer io.Writer) *BarChartPrinter
WithWriter sets the custom Writer.
type BasicTextPrinter ¶ added in v0.6.0
BasicTextPrinter is the printer used to print the input as-is or as specified by user formatting.
func (*BasicTextPrinter) Print ¶ added in v0.6.0
func (p *BasicTextPrinter) Print(a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to provided writer. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (*BasicTextPrinter) PrintOnError ¶ added in v0.12.19
func (p *BasicTextPrinter) PrintOnError(a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*BasicTextPrinter) PrintOnErrorf ¶ added in v0.12.33
func (p *BasicTextPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*BasicTextPrinter) Printf ¶ added in v0.6.0
func (p *BasicTextPrinter) Printf(format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to provided writer. It returns the number of bytes written and any write error encountered.
func (*BasicTextPrinter) Printfln ¶ added in v0.12.14
func (p *BasicTextPrinter) Printfln(format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to provided writer. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (*BasicTextPrinter) Println ¶ added in v0.6.0
func (p *BasicTextPrinter) Println(a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to provided writer. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (BasicTextPrinter) Sprint ¶ added in v0.6.0
func (p BasicTextPrinter) Sprint(a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (BasicTextPrinter) Sprintf ¶ added in v0.6.0
func (p BasicTextPrinter) Sprintf(format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (BasicTextPrinter) Sprintfln ¶ added in v0.12.14
func (p BasicTextPrinter) Sprintfln(format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (BasicTextPrinter) Sprintln ¶ added in v0.6.0
func (p BasicTextPrinter) Sprintln(a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (BasicTextPrinter) WithStyle ¶ added in v0.6.0
func (p BasicTextPrinter) WithStyle(style *Style) *BasicTextPrinter
WithStyle adds a style to the printer.
func (BasicTextPrinter) WithWriter ¶ added in v0.12.40
func (p BasicTextPrinter) WithWriter(writer io.Writer) *BasicTextPrinter
type BigTextPrinter ¶ added in v0.8.0
type BigTextPrinter struct { // BigCharacters holds the map from a normal character to it's big version. BigCharacters map[string]string Letters Letters Writer io.Writer }
BigTextPrinter renders big text. You can use this as title screen for your application.
func (BigTextPrinter) Render ¶ added in v0.8.0
func (p BigTextPrinter) Render() error
Render prints the BigText to the terminal.
func (BigTextPrinter) Srender ¶ added in v0.8.0
func (p BigTextPrinter) Srender() (string, error)
Srender renders the BigText as a string.
func (BigTextPrinter) WithBigCharacters ¶ added in v0.8.0
func (p BigTextPrinter) WithBigCharacters(chars map[string]string) *BigTextPrinter
WithBigCharacters returns a new BigTextPrinter with specific BigCharacters.
func (BigTextPrinter) WithLetters ¶ added in v0.8.0
func (p BigTextPrinter) WithLetters(letters ...Letters) *BigTextPrinter
WithLetters returns a new BigTextPrinter with specific Letters
func (BigTextPrinter) WithWriter ¶ added in v0.12.40
func (p BigTextPrinter) WithWriter(writer io.Writer) *BigTextPrinter
WithWriter sets the custom Writer.
type BoxPrinter ¶ added in v0.12.8
type BoxPrinter struct { Title string TitleTopLeft bool TitleTopRight bool TitleTopCenter bool TitleBottomLeft bool TitleBottomRight bool TitleBottomCenter bool TextStyle *Style VerticalString string BoxStyle *Style HorizontalString string TopRightCornerString string TopLeftCornerString string BottomLeftCornerString string BottomRightCornerString string TopPadding int BottomPadding int RightPadding int LeftPadding int Writer io.Writer }
BoxPrinter is able to render a box around printables.
func (BoxPrinter) Print ¶ added in v0.12.8
func (p BoxPrinter) Print(a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (BoxPrinter) PrintOnError ¶ added in v0.12.19
func (p BoxPrinter) PrintOnError(a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (BoxPrinter) PrintOnErrorf ¶ added in v0.12.33
func (p BoxPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (BoxPrinter) Printf ¶ added in v0.12.8
func (p BoxPrinter) Printf(format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (BoxPrinter) Printfln ¶ added in v0.12.14
func (p BoxPrinter) Printfln(format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (BoxPrinter) Println ¶ added in v0.12.8
func (p BoxPrinter) Println(a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (BoxPrinter) Sprint ¶ added in v0.12.8
func (p BoxPrinter) Sprint(a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (BoxPrinter) Sprintf ¶ added in v0.12.8
func (p BoxPrinter) Sprintf(format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (BoxPrinter) Sprintfln ¶ added in v0.12.14
func (p BoxPrinter) Sprintfln(format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (BoxPrinter) Sprintln ¶ added in v0.12.8
func (p BoxPrinter) Sprintln(a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (BoxPrinter) WithBottomLeftCornerString ¶ added in v0.12.8
func (p BoxPrinter) WithBottomLeftCornerString(str string) *BoxPrinter
WithBottomLeftCornerString returns a new box with a specific BottomLeftCornerString.
func (BoxPrinter) WithBottomPadding ¶ added in v0.12.8
func (p BoxPrinter) WithBottomPadding(padding int) *BoxPrinter
WithBottomPadding returns a new box with a specific BottomPadding.
func (BoxPrinter) WithBottomRightCornerString ¶ added in v0.12.8
func (p BoxPrinter) WithBottomRightCornerString(str string) *BoxPrinter
WithBottomRightCornerString returns a new box with a specific BottomRightCornerString.
func (BoxPrinter) WithBoxStyle ¶ added in v0.12.8
func (p BoxPrinter) WithBoxStyle(style *Style) *BoxPrinter
WithBoxStyle returns a new box with a specific box Style.
func (BoxPrinter) WithHorizontalString ¶ added in v0.12.8
func (p BoxPrinter) WithHorizontalString(str string) *BoxPrinter
WithHorizontalString returns a new box with a specific HorizontalString.
func (BoxPrinter) WithLeftPadding ¶ added in v0.12.8
func (p BoxPrinter) WithLeftPadding(padding int) *BoxPrinter
WithLeftPadding returns a new box with a specific LeftPadding.
func (BoxPrinter) WithRightPadding ¶ added in v0.12.8
func (p BoxPrinter) WithRightPadding(padding int) *BoxPrinter
WithRightPadding returns a new box with a specific RightPadding.
func (BoxPrinter) WithTextStyle ¶ added in v0.12.8
func (p BoxPrinter) WithTextStyle(style *Style) *BoxPrinter
WithTextStyle returns a new box with a specific text Style.
func (BoxPrinter) WithTitle ¶ added in v0.12.24
func (p BoxPrinter) WithTitle(str string) *BoxPrinter
WithTitle returns a new box with a specific Title.
func (BoxPrinter) WithTitleBottomCenter ¶ added in v0.12.24
func (p BoxPrinter) WithTitleBottomCenter(b ...bool) *BoxPrinter
WithTitleBottomCenter returns a new box with a specific Title alignment.
func (BoxPrinter) WithTitleBottomLeft ¶ added in v0.12.24
func (p BoxPrinter) WithTitleBottomLeft(b ...bool) *BoxPrinter
WithTitleBottomLeft returns a new box with a specific Title alignment.
func (BoxPrinter) WithTitleBottomRight ¶ added in v0.12.24
func (p BoxPrinter) WithTitleBottomRight(b ...bool) *BoxPrinter
WithTitleBottomRight returns a new box with a specific Title alignment.
func (BoxPrinter) WithTitleTopCenter ¶ added in v0.12.24
func (p BoxPrinter) WithTitleTopCenter(b ...bool) *BoxPrinter
WithTitleTopCenter returns a new box with a specific Title alignment.
func (BoxPrinter) WithTitleTopLeft ¶ added in v0.12.24
func (p BoxPrinter) WithTitleTopLeft(b ...bool) *BoxPrinter
WithTitleTopLeft returns a new box with a specific Title alignment.
func (BoxPrinter) WithTitleTopRight ¶ added in v0.12.24
func (p BoxPrinter) WithTitleTopRight(b ...bool) *BoxPrinter
WithTitleTopRight returns a new box with a specific Title alignment.
func (BoxPrinter) WithTopLeftCornerString ¶ added in v0.12.8
func (p BoxPrinter) WithTopLeftCornerString(str string) *BoxPrinter
WithTopLeftCornerString returns a new box with a specific TopLeftCornerString.
func (BoxPrinter) WithTopPadding ¶ added in v0.12.8
func (p BoxPrinter) WithTopPadding(padding int) *BoxPrinter
WithTopPadding returns a new box with a specific TopPadding.
func (BoxPrinter) WithTopRightCornerString ¶ added in v0.12.8
func (p BoxPrinter) WithTopRightCornerString(str string) *BoxPrinter
WithTopRightCornerString returns a new box with a specific TopRightCornerString.
func (BoxPrinter) WithVerticalString ¶ added in v0.12.8
func (p BoxPrinter) WithVerticalString(str string) *BoxPrinter
WithVerticalString returns a new box with a specific VerticalString.
func (BoxPrinter) WithWriter ¶ added in v0.12.40
func (p BoxPrinter) WithWriter(writer io.Writer) *BoxPrinter
WithWriter sets the custom Writer.
type BulletListItem ¶ added in v0.8.0
type BulletListItem struct { Level int Text string TextStyle *Style Bullet string BulletStyle *Style }
BulletListItem is able to render a ListItem.
func NewBulletListItemFromString
deprecated
added in
v0.9.0
func NewBulletListItemFromString(text string, padding string) BulletListItem
NewBulletListItemFromString returns a BulletListItem with a Text. The padding is counted in the Text to define the Level of the ListItem.
Deprecated: use putils.BulletListItemFromString instead.
func (BulletListItem) WithBullet ¶ added in v0.8.0
func (p BulletListItem) WithBullet(bullet string) *BulletListItem
WithBullet returns a new BulletListItem with a specific Prefix.
func (BulletListItem) WithBulletStyle ¶ added in v0.8.0
func (p BulletListItem) WithBulletStyle(style *Style) *BulletListItem
WithBulletStyle returns a new BulletListItem with a specific BulletStyle.
func (BulletListItem) WithLevel ¶ added in v0.8.0
func (p BulletListItem) WithLevel(level int) *BulletListItem
WithLevel returns a new BulletListItem with a specific Level.
func (BulletListItem) WithText ¶ added in v0.8.0
func (p BulletListItem) WithText(text string) *BulletListItem
WithText returns a new BulletListItem with a specific Text.
func (BulletListItem) WithTextStyle ¶ added in v0.8.0
func (p BulletListItem) WithTextStyle(style *Style) *BulletListItem
WithTextStyle returns a new BulletListItem with a specific TextStyle.
type BulletListPrinter ¶ added in v0.12.0
type BulletListPrinter struct { Items []BulletListItem TextStyle *Style Bullet string BulletStyle *Style Writer io.Writer }
BulletListPrinter is able to render a list.
func NewBulletListFromString
deprecated
added in
v0.9.0
func NewBulletListFromString(s string, padding string) BulletListPrinter
NewBulletListFromString returns a BulletListPrinter with Text using the NewTreeListItemFromString method, splitting after return (\n).
Deprecated: use putils.BulletListFromString instead.
func NewBulletListFromStrings
deprecated
added in
v0.9.0
func NewBulletListFromStrings(s []string, padding string) BulletListPrinter
NewBulletListFromStrings returns a BulletListPrinter with Text using the NewTreeListItemFromString method.
Deprecated: use putils.BulletListFromStrings instead.
func (BulletListPrinter) Render ¶ added in v0.12.0
func (l BulletListPrinter) Render() error
Render prints the list to the terminal.
func (BulletListPrinter) Srender ¶ added in v0.12.0
func (l BulletListPrinter) Srender() (string, error)
Srender renders the list as a string.
func (BulletListPrinter) WithBullet ¶ added in v0.12.0
func (l BulletListPrinter) WithBullet(bullet string) *BulletListPrinter
WithBullet returns a new list with a specific bullet.
func (BulletListPrinter) WithBulletStyle ¶ added in v0.12.0
func (l BulletListPrinter) WithBulletStyle(style *Style) *BulletListPrinter
WithBulletStyle returns a new list with a specific bullet style.
func (BulletListPrinter) WithItems ¶ added in v0.12.0
func (l BulletListPrinter) WithItems(items []BulletListItem) *BulletListPrinter
WithItems returns a new list with specific Items.
func (BulletListPrinter) WithTextStyle ¶ added in v0.12.0
func (l BulletListPrinter) WithTextStyle(style *Style) *BulletListPrinter
WithTextStyle returns a new list with a specific text style.
func (BulletListPrinter) WithWriter ¶ added in v0.12.40
func (l BulletListPrinter) WithWriter(writer io.Writer) *BulletListPrinter
WithWriter sets the custom Writer.
type CenterPrinter ¶ added in v0.10.1
CenterPrinter prints centered text.
func (CenterPrinter) Print ¶ added in v0.10.1
func (p CenterPrinter) Print(a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (CenterPrinter) PrintOnError ¶ added in v0.12.19
func (p CenterPrinter) PrintOnError(a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (CenterPrinter) PrintOnErrorf ¶ added in v0.12.33
func (p CenterPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (CenterPrinter) Printf ¶ added in v0.10.1
func (p CenterPrinter) Printf(format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (CenterPrinter) Printfln ¶ added in v0.12.14
func (p CenterPrinter) Printfln(format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (CenterPrinter) Println ¶ added in v0.10.1
func (p CenterPrinter) Println(a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (CenterPrinter) Sprint ¶ added in v0.10.1
func (p CenterPrinter) Sprint(a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (CenterPrinter) Sprintf ¶ added in v0.10.1
func (p CenterPrinter) Sprintf(format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (CenterPrinter) Sprintfln ¶ added in v0.12.14
func (p CenterPrinter) Sprintfln(format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (CenterPrinter) Sprintln ¶ added in v0.10.1
func (p CenterPrinter) Sprintln(a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (CenterPrinter) WithCenterEachLineSeparately ¶ added in v0.10.1
func (p CenterPrinter) WithCenterEachLineSeparately(b ...bool) *CenterPrinter
WithCenterEachLineSeparately centers each line separately.
func (CenterPrinter) WithWriter ¶ added in v0.12.40
func (p CenterPrinter) WithWriter(writer io.Writer) *CenterPrinter
WithWriter sets the custom Writer.
type Color ¶
type Color uint8
Color is a number which will be used to color strings in the terminal.
const ( FgBlack Color = iota + 30 FgRed FgGreen FgYellow FgBlue FgMagenta FgCyan FgWhite // FgDefault revert default FG. FgDefault Color = 39 )
Foreground colors. basic foreground colors 30 - 37.
const ( FgDarkGray Color = iota + 90 FgLightRed FgLightGreen FgLightYellow FgLightBlue FgLightMagenta FgLightCyan FgLightWhite // FgGray is an alias of FgDarkGray. FgGray Color = 90 )
Extra foreground color 90 - 97.
const ( BgBlack Color = iota + 40 BgRed BgGreen BgYellow // BgBrown like yellow BgBlue BgMagenta BgCyan BgWhite // BgDefault reverts to the default background. BgDefault Color = 49 )
Background colors. basic background colors 40 - 47.
const ( BgDarkGray Color = iota + 100 BgLightRed BgLightGreen BgLightYellow BgLightBlue BgLightMagenta BgLightCyan BgLightWhite // BgGray is an alias of BgDarkGray. BgGray Color = 100 )
Extra background color 100 - 107.
const ( Reset Color = iota Bold Fuzzy Italic Underscore Blink FastBlink Reverse Concealed Strikethrough )
Option settings.
func (Color) Print ¶
func (c Color) Print(a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Color.
func (Color) PrintOnError ¶ added in v0.12.19
func (c Color) PrintOnError(a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (Color) PrintOnErrorf ¶ added in v0.12.33
func (c Color) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (Color) Printf ¶
func (c Color) Printf(format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Color.
func (Color) Printfln ¶ added in v0.12.14
func (c Color) Printfln(format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Color.
func (Color) Println ¶
func (c Color) Println(a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Color.
func (Color) Sprint ¶
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string. Input will be colored with the parent Color.
func (Color) Sprintf ¶
Sprintf formats according to a format specifier and returns the resulting string. Input will be colored with the parent Color.
func (Color) Sprintfln ¶ added in v0.12.14
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended. Input will be colored with the parent Color.
func (Color) Sprintln ¶
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended. Input will be colored with the parent Color.
type HeaderPrinter ¶ added in v0.0.1
type HeaderPrinter struct { TextStyle *Style BackgroundStyle *Style Margin int FullWidth bool Writer io.Writer }
HeaderPrinter contains the data used to craft a header. A header is printed as a big box with text in it. Can be used as title screens or section separator.
func (*HeaderPrinter) Print ¶ added in v0.0.1
func (p *HeaderPrinter) Print(a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (*HeaderPrinter) PrintOnError ¶ added in v0.12.19
func (p *HeaderPrinter) PrintOnError(a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*HeaderPrinter) PrintOnErrorf ¶ added in v0.12.33
func (p *HeaderPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*HeaderPrinter) Printf ¶ added in v0.0.1
func (p *HeaderPrinter) Printf(format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (*HeaderPrinter) Printfln ¶ added in v0.12.14
func (p *HeaderPrinter) Printfln(format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (*HeaderPrinter) Println ¶ added in v0.0.1
func (p *HeaderPrinter) Println(a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (HeaderPrinter) Sprint ¶ added in v0.0.1
func (p HeaderPrinter) Sprint(a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (HeaderPrinter) Sprintf ¶ added in v0.0.1
func (p HeaderPrinter) Sprintf(format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (HeaderPrinter) Sprintfln ¶ added in v0.12.14
func (p HeaderPrinter) Sprintfln(format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (HeaderPrinter) Sprintln ¶ added in v0.0.1
func (p HeaderPrinter) Sprintln(a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (HeaderPrinter) WithBackgroundStyle ¶ added in v0.1.0
func (p HeaderPrinter) WithBackgroundStyle(style *Style) *HeaderPrinter
WithBackgroundStyle changes the background styling of the header.
func (HeaderPrinter) WithFullWidth ¶ added in v0.1.0
func (p HeaderPrinter) WithFullWidth(b ...bool) *HeaderPrinter
WithFullWidth enables full width on a HeaderPrinter.
func (HeaderPrinter) WithMargin ¶ added in v0.1.0
func (p HeaderPrinter) WithMargin(margin int) *HeaderPrinter
WithMargin changes the background styling of the header.
func (HeaderPrinter) WithTextStyle ¶ added in v0.1.0
func (p HeaderPrinter) WithTextStyle(style *Style) *HeaderPrinter
WithTextStyle returns a new HeaderPrinter with changed
func (HeaderPrinter) WithWriter ¶ added in v0.12.40
func (p HeaderPrinter) WithWriter(writer io.Writer) *HeaderPrinter
WithWriter sets the custom Writer.
type HeatmapAxis ¶ added in v0.12.70
type HeatmapData ¶ added in v0.12.70
type HeatmapData [][]float32
HeatmapData is the type that contains the data of a HeatmapPrinter.
type HeatmapPrinter ¶ added in v0.12.70
type HeatmapPrinter struct { HasHeader bool AxisStyle *Style VerticalSeparator string TopRightCornerSeparator string TopLeftCornerSeparator string BottomLeftCornerSeparator string BottomRightCornerSeparator string HorizontalSeparator string TSeparator string TReverseSeparator string LSeparator string LReverseSeparator string TCrossSeparator string LegendLabel string SeparatorStyle *Style Data HeatmapData Axis HeatmapAxis Boxed bool Grid bool OnlyColoredCells bool LegendOnlyColoredCells bool EnableComplementaryColor bool Legend bool CellSize int Colors []Color TextColor Color EnableRGB bool RGBRange []RGB TextRGB RGB Writer io.Writer // contains filtered or unexported fields }
HeatmapPrinter is able to render tables.
func (HeatmapPrinter) Render ¶ added in v0.12.70
func (p HeatmapPrinter) Render() error
Render prints the HeatmapPrinter to the terminal.
func (HeatmapPrinter) Srender ¶ added in v0.12.70
func (p HeatmapPrinter) Srender() (string, error)
Srender renders the HeatmapPrinter as a string.
func (HeatmapPrinter) WithAxisData ¶ added in v0.12.70
func (p HeatmapPrinter) WithAxisData(hd HeatmapAxis) *HeatmapPrinter
WithAxisData returns a new HeatmapPrinter, where the first line and row are headers.
func (HeatmapPrinter) WithAxisStyle ¶ added in v0.12.70
func (p HeatmapPrinter) WithAxisStyle(style *Style) *HeatmapPrinter
WithAxisStyle returns a new HeatmapPrinter with a specific AxisStyle.
func (HeatmapPrinter) WithBoxed ¶ added in v0.12.70
func (p HeatmapPrinter) WithBoxed(b ...bool) *HeatmapPrinter
WithBoxed returns a new HeatmapPrinter with a box around the table. If set to true, Grid will be set to true too.
func (HeatmapPrinter) WithCellSize ¶ added in v0.12.70
func (p HeatmapPrinter) WithCellSize(i int) *HeatmapPrinter
WithCellSize returns a new HeatmapPrinter with a specific cell size. This only works if there is no header and OnlyColoredCells == true!
func (HeatmapPrinter) WithColors ¶ added in v0.12.70
func (p HeatmapPrinter) WithColors(colors ...Color) *HeatmapPrinter
WithColors returns a new HeatmapPrinter with a specific Colors.
func (HeatmapPrinter) WithData ¶ added in v0.12.70
func (p HeatmapPrinter) WithData(data [][]float32) *HeatmapPrinter
WithData returns a new HeatmapPrinter with specific Data.
func (HeatmapPrinter) WithEnableComplementaryColor ¶ added in v0.12.70
func (p HeatmapPrinter) WithEnableComplementaryColor(b ...bool) *HeatmapPrinter
WithEnableComplementaryColor returns a new HeatmapPrinter with complement color.
func (HeatmapPrinter) WithEnableRGB ¶ added in v0.12.70
func (p HeatmapPrinter) WithEnableRGB(b ...bool) *HeatmapPrinter
WithEnableRGB returns a new HeatmapPrinter with RGB colors.
func (HeatmapPrinter) WithGrid ¶ added in v0.12.70
func (p HeatmapPrinter) WithGrid(b ...bool) *HeatmapPrinter
WithGrid returns a new HeatmapPrinter with a grid. If set to false, Boxed will be set to false too.
func (HeatmapPrinter) WithLegend ¶ added in v0.12.70
func (p HeatmapPrinter) WithLegend(b ...bool) *HeatmapPrinter
WithLegend returns a new HeatmapPrinter with a legend.
func (HeatmapPrinter) WithLegendLabel ¶ added in v0.12.70
func (p HeatmapPrinter) WithLegendLabel(s string) *HeatmapPrinter
WithLegendLabel returns a new HeatmapPrinter with a specific legend tag. This sets the Legend to true.
func (HeatmapPrinter) WithLegendOnlyColoredCells ¶ added in v0.12.70
func (p HeatmapPrinter) WithLegendOnlyColoredCells(b ...bool) *HeatmapPrinter
WithLegendOnlyColoredCells returns a new HeatmapPrinter with legend with only colored cells. This sets the Legend to true.
func (HeatmapPrinter) WithOnlyColoredCells ¶ added in v0.12.70
func (p HeatmapPrinter) WithOnlyColoredCells(b ...bool) *HeatmapPrinter
WithOnlyColoredCells returns a new HeatmapPrinter with only colored cells.
func (HeatmapPrinter) WithRGBRange ¶ added in v0.12.70
func (p HeatmapPrinter) WithRGBRange(rgb ...RGB) *HeatmapPrinter
WithRGBRange returns a new HeatmapPrinter with a specific RGBRange.
func (HeatmapPrinter) WithSeparatorStyle ¶ added in v0.12.70
func (p HeatmapPrinter) WithSeparatorStyle(style *Style) *HeatmapPrinter
WithSeparatorStyle returns a new HeatmapPrinter with a specific SeparatorStyle.
func (HeatmapPrinter) WithTextColor ¶ added in v0.12.70
func (p HeatmapPrinter) WithTextColor(color Color) *HeatmapPrinter
WithTextColor returns a new HeatmapPrinter with a specific TextColor. This sets EnableComplementaryColor to false.
func (HeatmapPrinter) WithTextRGB ¶ added in v0.12.70
func (p HeatmapPrinter) WithTextRGB(rgb RGB) *HeatmapPrinter
WithTextRGB returns a new HeatmapPrinter with a specific TextRGB. This sets EnableComplementaryColor to false.
func (HeatmapPrinter) WithWriter ¶ added in v0.12.70
func (p HeatmapPrinter) WithWriter(writer io.Writer) *HeatmapPrinter
WithWriter sets the Writer.
type InteractiveConfirmPrinter ¶ added in v0.12.42
type InteractiveConfirmPrinter struct { DefaultValue bool DefaultText string Delimiter string TextStyle *Style ConfirmText string ConfirmStyle *Style RejectText string RejectStyle *Style SuffixStyle *Style OnInterruptFunc func() }
InteractiveConfirmPrinter is a printer for interactive confirm prompts.
func (InteractiveConfirmPrinter) Show ¶ added in v0.12.42
func (p InteractiveConfirmPrinter) Show(text ...string) (bool, error)
Show shows the confirm prompt.
Example:
result, _ := pterm.DefaultInteractiveConfirm.Show("Are you sure?") pterm.Println(result)
func (InteractiveConfirmPrinter) WithConfirmStyle ¶ added in v0.12.42
func (p InteractiveConfirmPrinter) WithConfirmStyle(style *Style) *InteractiveConfirmPrinter
WithConfirmStyle sets the confirm style.
func (InteractiveConfirmPrinter) WithConfirmText ¶ added in v0.12.42
func (p InteractiveConfirmPrinter) WithConfirmText(text string) *InteractiveConfirmPrinter
WithConfirmText sets the confirm text.
func (InteractiveConfirmPrinter) WithDefaultText ¶ added in v0.12.42
func (p InteractiveConfirmPrinter) WithDefaultText(text string) *InteractiveConfirmPrinter
WithDefaultText sets the default text.
func (InteractiveConfirmPrinter) WithDefaultValue ¶ added in v0.12.42
func (p InteractiveConfirmPrinter) WithDefaultValue(value bool) *InteractiveConfirmPrinter
WithDefaultValue sets the default value, which will be returned when the user presses enter without typing "y" or "n".
func (InteractiveConfirmPrinter) WithDelimiter ¶ added in v0.12.64
func (p InteractiveConfirmPrinter) WithDelimiter(delimiter string) *InteractiveConfirmPrinter
WithDelimiter sets the delimiter between the message and the input.
func (InteractiveConfirmPrinter) WithOnInterruptFunc ¶ added in v0.12.63
func (p InteractiveConfirmPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveConfirmPrinter
OnInterrupt sets the function to execute on exit of the input reader
func (InteractiveConfirmPrinter) WithRejectStyle ¶ added in v0.12.42
func (p InteractiveConfirmPrinter) WithRejectStyle(style *Style) *InteractiveConfirmPrinter
WithRejectStyle sets the reject style.
func (InteractiveConfirmPrinter) WithRejectText ¶ added in v0.12.42
func (p InteractiveConfirmPrinter) WithRejectText(text string) *InteractiveConfirmPrinter
WithRejectText sets the reject text.
func (InteractiveConfirmPrinter) WithSuffixStyle ¶ added in v0.12.42
func (p InteractiveConfirmPrinter) WithSuffixStyle(style *Style) *InteractiveConfirmPrinter
WithSuffixStyle sets the suffix style.
func (InteractiveConfirmPrinter) WithTextStyle ¶ added in v0.12.42
func (p InteractiveConfirmPrinter) WithTextStyle(style *Style) *InteractiveConfirmPrinter
WithTextStyle sets the text style.
type InteractiveContinuePrinter ¶ added in v0.12.47
type InteractiveContinuePrinter struct { DefaultValueIndex int DefaultText string Delimiter string TextStyle *Style Options []string OptionsStyle *Style Handles []string ShowShortHandles bool SuffixStyle *Style }
InteractiveContinuePrinter is a printer for interactive continue prompts.
func (InteractiveContinuePrinter) Show ¶ added in v0.12.47
func (p InteractiveContinuePrinter) Show(text ...string) (string, error)
Show shows the continue prompt.
Example:
result, _ := pterm.DefaultInteractiveContinue.Show("Do you want to apply the changes?") pterm.Println(result)
func (InteractiveContinuePrinter) WithDefaultText ¶ added in v0.12.47
func (p InteractiveContinuePrinter) WithDefaultText(text string) *InteractiveContinuePrinter
WithDefaultText sets the default text.
func (InteractiveContinuePrinter) WithDefaultValue ¶ added in v0.12.47
func (p InteractiveContinuePrinter) WithDefaultValue(value string) *InteractiveContinuePrinter
WithDefaultValue sets the default value, which will be returned when the user presses enter without typing any letter.
func (InteractiveContinuePrinter) WithDefaultValueIndex ¶ added in v0.12.47
func (p InteractiveContinuePrinter) WithDefaultValueIndex(value int) *InteractiveContinuePrinter
WithDefaultValueIndex sets the default value, which will be returned when the user presses enter without typing any letter.
func (InteractiveContinuePrinter) WithDelimiter ¶ added in v0.12.64
func (p InteractiveContinuePrinter) WithDelimiter(delimiter string) *InteractiveContinuePrinter
WithDelimiter sets the delimiter between the message and the input.
func (InteractiveContinuePrinter) WithHandles ¶ added in v0.12.47
func (p InteractiveContinuePrinter) WithHandles(handles []string) *InteractiveContinuePrinter
WithHandles allows you to customize the short handles for the answers.
func (InteractiveContinuePrinter) WithOptions ¶ added in v0.12.47
func (p InteractiveContinuePrinter) WithOptions(options []string) *InteractiveContinuePrinter
WithOptions sets the options.
func (InteractiveContinuePrinter) WithOptionsStyle ¶ added in v0.12.47
func (p InteractiveContinuePrinter) WithOptionsStyle(style *Style) *InteractiveContinuePrinter
WithOptionsStyle sets the continue style.
func (InteractiveContinuePrinter) WithShowShortHandles ¶ added in v0.12.47
func (p InteractiveContinuePrinter) WithShowShortHandles(b ...bool) *InteractiveContinuePrinter
WithShowShortHandles will set ShowShortHandles to true this makes the printer display the shorthand options instead their shorthand version.
func (InteractiveContinuePrinter) WithSuffixStyle ¶ added in v0.12.47
func (p InteractiveContinuePrinter) WithSuffixStyle(style *Style) *InteractiveContinuePrinter
WithSuffixStyle sets the suffix style.
func (InteractiveContinuePrinter) WithTextStyle ¶ added in v0.12.47
func (p InteractiveContinuePrinter) WithTextStyle(style *Style) *InteractiveContinuePrinter
WithTextStyle sets the text style.
type InteractiveMultiselectPrinter ¶ added in v0.12.42
type InteractiveMultiselectPrinter struct { DefaultText string TextStyle *Style Options []string OptionStyle *Style DefaultOptions []string MaxHeight int Selector string SelectorStyle *Style Filter bool Checkmark *Checkmark OnInterruptFunc func() // KeySelect is the select key. It cannot be keys.Space when Filter is enabled. KeySelect keys.KeyCode // KeyConfirm is the confirm key. It cannot be keys.Space when Filter is enabled. KeyConfirm keys.KeyCode // contains filtered or unexported fields }
InteractiveMultiselectPrinter is a printer for interactive multiselect menus.
func (*InteractiveMultiselectPrinter) Show ¶ added in v0.12.42
func (p *InteractiveMultiselectPrinter) Show(text ...string) ([]string, error)
Show shows the interactive multiselect menu and returns the selected entry.
func (InteractiveMultiselectPrinter) WithCheckmark ¶ added in v0.12.52
func (p InteractiveMultiselectPrinter) WithCheckmark(checkmark *Checkmark) *InteractiveMultiselectPrinter
WithCheckmark sets the checkmark
func (InteractiveMultiselectPrinter) WithDefaultOptions ¶ added in v0.12.42
func (p InteractiveMultiselectPrinter) WithDefaultOptions(options []string) *InteractiveMultiselectPrinter
WithDefaultOptions sets the default options.
func (InteractiveMultiselectPrinter) WithDefaultText ¶ added in v0.12.42
func (p InteractiveMultiselectPrinter) WithDefaultText(text string) *InteractiveMultiselectPrinter
WithDefaultText sets the default text.
func (InteractiveMultiselectPrinter) WithFilter ¶ added in v0.12.48
func (p InteractiveMultiselectPrinter) WithFilter(b ...bool) *InteractiveMultiselectPrinter
WithFilter sets the Filter option
func (InteractiveMultiselectPrinter) WithKeyConfirm ¶ added in v0.12.48
func (p InteractiveMultiselectPrinter) WithKeyConfirm(keyConfirm keys.KeyCode) *InteractiveMultiselectPrinter
WithKeyConfirm sets the confirm key It cannot be keys.Space when Filter is enabled.
func (InteractiveMultiselectPrinter) WithKeySelect ¶ added in v0.12.48
func (p InteractiveMultiselectPrinter) WithKeySelect(keySelect keys.KeyCode) *InteractiveMultiselectPrinter
WithKeySelect sets the confirm key It cannot be keys.Space when Filter is enabled.
func (InteractiveMultiselectPrinter) WithMaxHeight ¶ added in v0.12.42
func (p InteractiveMultiselectPrinter) WithMaxHeight(maxHeight int) *InteractiveMultiselectPrinter
WithMaxHeight sets the maximum height of the select menu.
func (InteractiveMultiselectPrinter) WithOnInterruptFunc ¶ added in v0.12.63
func (p InteractiveMultiselectPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveMultiselectPrinter
OnInterrupt sets the function to execute on exit of the input reader
func (InteractiveMultiselectPrinter) WithOptions ¶ added in v0.12.42
func (p InteractiveMultiselectPrinter) WithOptions(options []string) *InteractiveMultiselectPrinter
WithOptions sets the options.
type InteractiveSelectPrinter ¶ added in v0.12.42
type InteractiveSelectPrinter struct { TextStyle *Style DefaultText string Options []string OptionStyle *Style DefaultOption string MaxHeight int Selector string SelectorStyle *Style OnInterruptFunc func() Filter bool // contains filtered or unexported fields }
InteractiveSelectPrinter is a printer for interactive select menus.
func (*InteractiveSelectPrinter) Show ¶ added in v0.12.42
func (p *InteractiveSelectPrinter) Show(text ...string) (string, error)
Show shows the interactive select menu and returns the selected entry.
func (InteractiveSelectPrinter) WithDefaultOption ¶ added in v0.12.42
func (p InteractiveSelectPrinter) WithDefaultOption(option string) *InteractiveSelectPrinter
WithDefaultOption sets the default options.
func (InteractiveSelectPrinter) WithDefaultText ¶ added in v0.12.42
func (p InteractiveSelectPrinter) WithDefaultText(text string) *InteractiveSelectPrinter
WithDefaultText sets the default text.
func (InteractiveSelectPrinter) WithFilter ¶ added in v0.12.63
func (p InteractiveSelectPrinter) WithFilter(b ...bool) *InteractiveSelectPrinter
WithFilter sets the Filter option
func (InteractiveSelectPrinter) WithMaxHeight ¶ added in v0.12.42
func (p InteractiveSelectPrinter) WithMaxHeight(maxHeight int) *InteractiveSelectPrinter
WithMaxHeight sets the maximum height of the select menu.
func (InteractiveSelectPrinter) WithOnInterruptFunc ¶ added in v0.12.63
func (p InteractiveSelectPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveSelectPrinter
OnInterrupt sets the function to execute on exit of the input reader
func (InteractiveSelectPrinter) WithOptions ¶ added in v0.12.42
func (p InteractiveSelectPrinter) WithOptions(options []string) *InteractiveSelectPrinter
WithOptions sets the options.
type InteractiveTextInputPrinter ¶ added in v0.12.42
type InteractiveTextInputPrinter struct { TextStyle *Style DefaultText string DefaultValue string Delimiter string MultiLine bool Mask string OnInterruptFunc func() // contains filtered or unexported fields }
InteractiveTextInputPrinter is a printer for interactive select menus.
func (InteractiveTextInputPrinter) Show ¶ added in v0.12.42
func (p InteractiveTextInputPrinter) Show(text ...string) (string, error)
Show shows the interactive select menu and returns the selected entry.
func (InteractiveTextInputPrinter) WithDefaultText ¶ added in v0.12.42
func (p InteractiveTextInputPrinter) WithDefaultText(text string) *InteractiveTextInputPrinter
WithDefaultText sets the default text.
func (InteractiveTextInputPrinter) WithDefaultValue ¶ added in v0.12.70
func (p InteractiveTextInputPrinter) WithDefaultValue(value string) *InteractiveTextInputPrinter
WithDefaultValue sets the default value.
func (InteractiveTextInputPrinter) WithDelimiter ¶ added in v0.12.64
func (p InteractiveTextInputPrinter) WithDelimiter(delimiter string) *InteractiveTextInputPrinter
WithDelimiter sets the delimiter between the message and the input.
func (InteractiveTextInputPrinter) WithMask ¶ added in v0.12.59
func (p InteractiveTextInputPrinter) WithMask(mask string) *InteractiveTextInputPrinter
WithMask sets the mask.
func (InteractiveTextInputPrinter) WithMultiLine ¶ added in v0.12.42
func (p InteractiveTextInputPrinter) WithMultiLine(multiLine ...bool) *InteractiveTextInputPrinter
WithMultiLine sets the multi line flag.
func (InteractiveTextInputPrinter) WithOnInterruptFunc ¶ added in v0.12.63
func (p InteractiveTextInputPrinter) WithOnInterruptFunc(exitFunc func()) *InteractiveTextInputPrinter
WithOnInterruptFunc sets the function to execute on exit of the input reader
func (InteractiveTextInputPrinter) WithTextStyle ¶ added in v0.12.42
func (p InteractiveTextInputPrinter) WithTextStyle(style *Style) *InteractiveTextInputPrinter
WithTextStyle sets the text style.
type Letter ¶ added in v0.8.0
Letter is an object, which holds a string and a specific Style for it.
func (Letter) WithRGB ¶ added in v0.12.38
WithRGB returns a new Letter with a specific RGB color (overwrites style).
func (Letter) WithString ¶ added in v0.8.0
WithString returns a new Letter with a specific String.
type Letters ¶ added in v0.8.0
type Letters []Letter
Letters is a slice of Letter.
func NewLettersFromString
deprecated
added in
v0.8.0
func NewLettersFromStringWithRGB
deprecated
added in
v0.12.38
func NewLettersFromStringWithStyle
deprecated
added in
v0.8.0
type LeveledList ¶ added in v0.9.3
type LeveledList []LeveledListItem
LeveledList is a list, which contains multiple LeveledListItem.
type LeveledListItem ¶ added in v0.9.3
LeveledListItem combines a text with a specific level. The level is the indent, which would normally be seen in a BulletListPrinter.
type LivePrinter ¶ added in v0.5.0
type LivePrinter interface { // GenericStart runs Start, but returns a LivePrinter. // This is used for the interface LivePrinter. // You most likely want to use Start instead of this in your program. GenericStart() (*LivePrinter, error) // GenericStop runs Stop, but returns a LivePrinter. // This is used for the interface LivePrinter. // You most likely want to use Stop instead of this in your program. GenericStop() (*LivePrinter, error) SetWriter(writer io.Writer) }
LivePrinter is a printer which can update it's output live.
type LogFormatter ¶ added in v0.12.58
type LogFormatter int
LogFormatter is the log formatter. Can be either LogFormatterColorful or LogFormatterJSON.
const ( // LogFormatterColorful is a colorful log formatter. LogFormatterColorful LogFormatter = iota // LogFormatterJSON is a JSON log formatter. LogFormatterJSON )
type LogLevel ¶ added in v0.12.58
type LogLevel int
const ( // LogLevelDisabled does never print. LogLevelDisabled LogLevel = iota // LogLevelTrace is the log level for traces. LogLevelTrace // LogLevelDebug is the log level for debug. LogLevelDebug // LogLevelInfo is the log level for info. LogLevelInfo // LogLevelWarn is the log level for warnings. LogLevelWarn // LogLevelError is the log level for errors. LogLevelError // LogLevelFatal is the log level for fatal errors. LogLevelFatal // LogLevelPrint is the log level for printing. LogLevelPrint )
type Logger ¶ added in v0.12.58
type Logger struct { // Formatter is the log formatter of the logger. Formatter LogFormatter // Writer is the writer of the logger. Writer io.Writer // Level is the log level of the logger. Level LogLevel // ShowCaller defines if the logger should print the caller. ShowCaller bool // CallerOffset defines the offset of the caller. CallerOffset int // ShowTime defines if the logger should print a timestamp. ShowTime bool // TimestampLayout defines the layout of the timestamp. TimeFormat string // KeyStyles defines the styles for specific keys. KeyStyles map[string]Style // MaxWidth defines the maximum width of the logger. // If the text (including the arguments) is longer than the max width, it will be split into multiple lines. MaxWidth int }
func (Logger) AppendKeyStyle ¶ added in v0.12.58
AppendKeyStyle appends a style for a specific key.
func (Logger) AppendKeyStyles ¶ added in v0.12.58
AppendKeyStyles appends a style for a specific key.
func (Logger) Args ¶ added in v0.12.58
func (l Logger) Args(args ...any) []LoggerArgument
Args converts any arguments to a slice of LoggerArgument.
func (Logger) ArgsFromMap ¶ added in v0.12.58
func (l Logger) ArgsFromMap(m map[string]any) []LoggerArgument
ArgsFromMap converts a map to a slice of LoggerArgument.
func (Logger) CanPrint ¶ added in v0.12.58
CanPrint checks if the logger can print a specific log level.
func (Logger) Debug ¶ added in v0.12.58
func (l Logger) Debug(msg string, args ...[]LoggerArgument)
Debug prints a debug log.
func (Logger) Error ¶ added in v0.12.58
func (l Logger) Error(msg string, args ...[]LoggerArgument)
Error prints an error log.
func (Logger) Fatal ¶ added in v0.12.58
func (l Logger) Fatal(msg string, args ...[]LoggerArgument)
Fatal prints a fatal log and exits the program.
func (Logger) Info ¶ added in v0.12.58
func (l Logger) Info(msg string, args ...[]LoggerArgument)
Info prints an info log.
func (Logger) Print ¶ added in v0.12.58
func (l Logger) Print(msg string, args ...[]LoggerArgument)
Print prints a log.
func (Logger) Trace ¶ added in v0.12.58
func (l Logger) Trace(msg string, args ...[]LoggerArgument)
Trace prints a trace log.
func (Logger) Warn ¶ added in v0.12.58
func (l Logger) Warn(msg string, args ...[]LoggerArgument)
Warn prints a warning log.
func (Logger) WithCaller ¶ added in v0.12.58
WithCaller enables or disables the caller.
func (Logger) WithCallerOffset ¶ added in v0.12.58
WithCallerOffset sets the caller offset.
func (Logger) WithFormatter ¶ added in v0.12.58
func (l Logger) WithFormatter(formatter LogFormatter) *Logger
WithFormatter sets the log formatter of the logger.
func (Logger) WithKeyStyles ¶ added in v0.12.58
WithKeyStyles sets the style for a specific key.
func (Logger) WithMaxWidth ¶ added in v0.12.58
WithMaxWidth sets the maximum width of the logger.
func (Logger) WithTimeFormat ¶ added in v0.12.58
WithTimeFormat sets the timestamp layout.
type LoggerArgument ¶ added in v0.12.58
type LoggerArgument struct { // Key is the key of the argument. Key string // Value is the value of the argument. Value any }
LoggerArgument is a key-value pair for a logger.
type MultiPrinter ¶ added in v0.12.66
type MultiPrinter struct { IsActive bool Writer io.Writer UpdateDelay time.Duration // contains filtered or unexported fields }
func (MultiPrinter) GenericStart ¶ added in v0.12.66
func (p MultiPrinter) GenericStart() (*LivePrinter, error)
GenericStart runs Start, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Start instead of this in your program.
func (MultiPrinter) GenericStop ¶ added in v0.12.66
func (p MultiPrinter) GenericStop() (*LivePrinter, error)
GenericStop runs Stop, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Stop instead of this in your program.
func (*MultiPrinter) NewWriter ¶ added in v0.12.66
func (p *MultiPrinter) NewWriter() io.Writer
func (*MultiPrinter) SetWriter ¶ added in v0.12.66
func (p *MultiPrinter) SetWriter(writer io.Writer)
SetWriter sets the writer for the AreaPrinter.
func (*MultiPrinter) Start ¶ added in v0.12.66
func (p *MultiPrinter) Start() (*MultiPrinter, error)
func (*MultiPrinter) Stop ¶ added in v0.12.66
func (p *MultiPrinter) Stop() (*MultiPrinter, error)
func (MultiPrinter) WithUpdateDelay ¶ added in v0.12.66
func (p MultiPrinter) WithUpdateDelay(delay time.Duration) *MultiPrinter
WithUpdateDelay returns a fork of the MultiPrinter with a new update delay.
func (MultiPrinter) WithWriter ¶ added in v0.12.66
func (p MultiPrinter) WithWriter(writer io.Writer) *MultiPrinter
WithWriter returns a fork of the MultiPrinter with a new writer.
type Panel ¶ added in v0.11.0
type Panel struct {
Data string
}
Panel contains the data, which should be printed inside a PanelPrinter.
type PanelPrinter ¶ added in v0.11.0
type PanelPrinter struct { Panels Panels Padding int BottomPadding int SameColumnWidth bool BoxPrinter BoxPrinter Writer io.Writer }
PanelPrinter prints content in boxes.
func (PanelPrinter) Render ¶ added in v0.11.0
func (p PanelPrinter) Render() error
Render prints the Template to the terminal.
func (PanelPrinter) Srender ¶ added in v0.11.0
func (p PanelPrinter) Srender() (string, error)
Srender renders the Template as a string.
func (PanelPrinter) WithBottomPadding ¶ added in v0.12.0
func (p PanelPrinter) WithBottomPadding(bottomPadding int) *PanelPrinter
WithBottomPadding returns a new PanelPrinter with specific options.
func (PanelPrinter) WithBoxPrinter ¶ added in v0.12.8
func (p PanelPrinter) WithBoxPrinter(boxPrinter BoxPrinter) *PanelPrinter
WithBoxPrinter returns a new PanelPrinter with specific options.
func (PanelPrinter) WithPadding ¶ added in v0.11.0
func (p PanelPrinter) WithPadding(padding int) *PanelPrinter
WithPadding returns a new PanelPrinter with specific options.
func (PanelPrinter) WithPanels ¶ added in v0.11.0
func (p PanelPrinter) WithPanels(panels Panels) *PanelPrinter
WithPanels returns a new PanelPrinter with specific options.
func (PanelPrinter) WithSameColumnWidth ¶ added in v0.12.0
func (p PanelPrinter) WithSameColumnWidth(b ...bool) *PanelPrinter
WithSameColumnWidth returns a new PanelPrinter with specific options.
func (PanelPrinter) WithWriter ¶ added in v0.12.40
func (p PanelPrinter) WithWriter(writer io.Writer) *PanelPrinter
WithWriter sets the custom Writer.
type Panels ¶ added in v0.11.0
type Panels [][]Panel
Panels is a two dimensional coordinate system for Panel.
type ParagraphPrinter ¶ added in v0.5.0
ParagraphPrinter can print paragraphs to a fixed line width. The text will split between words, so that words will stick together. It's like in a book.
func (*ParagraphPrinter) Print ¶ added in v0.5.0
func (p *ParagraphPrinter) Print(a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (*ParagraphPrinter) PrintOnError ¶ added in v0.12.19
func (p *ParagraphPrinter) PrintOnError(a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*ParagraphPrinter) PrintOnErrorf ¶ added in v0.12.33
func (p *ParagraphPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*ParagraphPrinter) Printf ¶ added in v0.5.0
func (p *ParagraphPrinter) Printf(format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (*ParagraphPrinter) Printfln ¶ added in v0.12.14
func (p *ParagraphPrinter) Printfln(format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (*ParagraphPrinter) Println ¶ added in v0.5.0
func (p *ParagraphPrinter) Println(a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (ParagraphPrinter) Sprint ¶ added in v0.5.0
func (p ParagraphPrinter) Sprint(a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (ParagraphPrinter) Sprintf ¶ added in v0.5.0
func (p ParagraphPrinter) Sprintf(format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (ParagraphPrinter) Sprintfln ¶ added in v0.12.14
func (p ParagraphPrinter) Sprintfln(format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (ParagraphPrinter) Sprintln ¶ added in v0.5.0
func (p ParagraphPrinter) Sprintln(a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (ParagraphPrinter) WithMaxWidth ¶ added in v0.5.0
func (p ParagraphPrinter) WithMaxWidth(width int) *ParagraphPrinter
WithMaxWidth returns a new ParagraphPrinter with a specific MaxWidth
func (ParagraphPrinter) WithWriter ¶ added in v0.12.40
func (p ParagraphPrinter) WithWriter(writer io.Writer) *ParagraphPrinter
WithWriter sets the custom Writer.
type PrefixPrinter ¶
type PrefixPrinter struct { Prefix Prefix Scope Scope MessageStyle *Style Fatal bool ShowLineNumber bool LineNumberOffset int Writer io.Writer // If Debugger is true, the printer will only print if PrintDebugMessages is set to true. // You can change PrintDebugMessages with EnableDebugMessages and DisableDebugMessages, or by setting the variable itself. Debugger bool }
PrefixPrinter is the printer used to print a Prefix.
func (PrefixPrinter) GetFormattedPrefix ¶
func (p PrefixPrinter) GetFormattedPrefix() string
GetFormattedPrefix returns the Prefix as a styled text string.
func (*PrefixPrinter) Print ¶
func (p *PrefixPrinter) Print(a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (*PrefixPrinter) PrintOnError ¶ added in v0.12.15
func (p *PrefixPrinter) PrintOnError(a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
Note: Use WithFatal(true) or Fatal to panic after first non nil error.
func (*PrefixPrinter) PrintOnErrorf ¶ added in v0.12.33
func (p *PrefixPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*PrefixPrinter) Printf ¶
func (p *PrefixPrinter) Printf(format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (*PrefixPrinter) Printfln ¶ added in v0.12.14
func (p *PrefixPrinter) Printfln(format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (*PrefixPrinter) Println ¶
func (p *PrefixPrinter) Println(a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (*PrefixPrinter) Sprint ¶
func (p *PrefixPrinter) Sprint(a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (PrefixPrinter) Sprintf ¶
func (p PrefixPrinter) Sprintf(format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (PrefixPrinter) Sprintfln ¶ added in v0.12.14
func (p PrefixPrinter) Sprintfln(format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (PrefixPrinter) Sprintln ¶
func (p PrefixPrinter) Sprintln(a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (PrefixPrinter) WithDebugger ¶ added in v0.9.0
func (p PrefixPrinter) WithDebugger(b ...bool) *PrefixPrinter
WithDebugger returns a new Printer with specific Debugger value. If Debugger is true, the printer will only print if PrintDebugMessages is set to true. You can change PrintDebugMessages with EnableDebugMessages and DisableDebugMessages, or by setting the variable itself.
func (PrefixPrinter) WithFatal ¶ added in v0.3.0
func (p PrefixPrinter) WithFatal(b ...bool) *PrefixPrinter
WithFatal sets if the printer should panic after printing. NOTE: The printer will only panic if either PrefixPrinter.Println, PrefixPrinter.Print or PrefixPrinter.Printf is called.
func (PrefixPrinter) WithLineNumberOffset ¶ added in v0.12.31
func (p PrefixPrinter) WithLineNumberOffset(offset int) *PrefixPrinter
WithLineNumberOffset can be used to exclude a specific amount of calls in the call stack. If you make a wrapper function for example, you can set this to one. The printed line number will then be the line number where your wrapper function is called.
func (PrefixPrinter) WithMessageStyle ¶ added in v0.1.0
func (p PrefixPrinter) WithMessageStyle(style *Style) *PrefixPrinter
WithMessageStyle adds a custom prefix to the printer.
func (PrefixPrinter) WithPrefix ¶ added in v0.1.0
func (p PrefixPrinter) WithPrefix(prefix Prefix) *PrefixPrinter
WithPrefix adds a custom prefix to the printer.
func (PrefixPrinter) WithScope ¶
func (p PrefixPrinter) WithScope(scope Scope) *PrefixPrinter
WithScope adds a scope to the Prefix.
func (PrefixPrinter) WithShowLineNumber ¶ added in v0.12.12
func (p PrefixPrinter) WithShowLineNumber(b ...bool) *PrefixPrinter
WithShowLineNumber sets if the printer should print the line number from where it's called in a go file.
func (PrefixPrinter) WithWriter ¶ added in v0.12.40
func (p PrefixPrinter) WithWriter(writer io.Writer) *PrefixPrinter
WithWriter sets the custom Writer.
type ProgressbarPrinter ¶ added in v0.12.0
type ProgressbarPrinter struct { Title string Total int Current int BarCharacter string LastCharacter string ElapsedTimeRoundingFactor time.Duration BarFiller string MaxWidth int ShowElapsedTime bool ShowCount bool ShowTitle bool ShowPercentage bool RemoveWhenDone bool TitleStyle *Style BarStyle *Style IsActive bool Writer io.Writer // contains filtered or unexported fields }
ProgressbarPrinter shows a progress animation in the terminal.
func (*ProgressbarPrinter) Add ¶ added in v0.12.0
func (p *ProgressbarPrinter) Add(count int) *ProgressbarPrinter
Add to current value.
func (*ProgressbarPrinter) GenericStart ¶ added in v0.12.0
func (p *ProgressbarPrinter) GenericStart() (*LivePrinter, error)
GenericStart runs Start, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Start instead of this in your program.
func (*ProgressbarPrinter) GenericStop ¶ added in v0.12.0
func (p *ProgressbarPrinter) GenericStop() (*LivePrinter, error)
GenericStop runs Stop, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Stop instead of this in your program.
func (*ProgressbarPrinter) GetElapsedTime ¶ added in v0.12.0
func (p *ProgressbarPrinter) GetElapsedTime() time.Duration
GetElapsedTime returns the elapsed time, since the ProgressbarPrinter was started.
func (*ProgressbarPrinter) Increment ¶ added in v0.12.0
func (p *ProgressbarPrinter) Increment() *ProgressbarPrinter
Increment current value by one.
func (*ProgressbarPrinter) SetWriter ¶ added in v0.12.66
func (p *ProgressbarPrinter) SetWriter(writer io.Writer)
SetWriter sets the custom Writer.
func (ProgressbarPrinter) Start ¶ added in v0.12.0
func (p ProgressbarPrinter) Start(title ...interface{}) (*ProgressbarPrinter, error)
Start the ProgressbarPrinter.
func (*ProgressbarPrinter) Stop ¶ added in v0.12.0
func (p *ProgressbarPrinter) Stop() (*ProgressbarPrinter, error)
Stop the ProgressbarPrinter.
func (*ProgressbarPrinter) UpdateTitle ¶ added in v0.12.33
func (p *ProgressbarPrinter) UpdateTitle(title string) *ProgressbarPrinter
UpdateTitle updates the title and re-renders the progressbar
func (ProgressbarPrinter) WithBarCharacter ¶ added in v0.12.0
func (p ProgressbarPrinter) WithBarCharacter(char string) *ProgressbarPrinter
WithBarCharacter sets the bar character of the ProgressbarPrinter.
func (ProgressbarPrinter) WithBarFiller ¶ added in v0.12.37
func (p ProgressbarPrinter) WithBarFiller(char string) *ProgressbarPrinter
WithBarFiller sets the filler character for the ProgressbarPrinter.
func (ProgressbarPrinter) WithBarStyle ¶ added in v0.12.0
func (p ProgressbarPrinter) WithBarStyle(style *Style) *ProgressbarPrinter
WithBarStyle sets the style of the bar.
func (ProgressbarPrinter) WithCurrent ¶ added in v0.12.0
func (p ProgressbarPrinter) WithCurrent(current int) *ProgressbarPrinter
WithCurrent sets the current value of the ProgressbarPrinter.
func (ProgressbarPrinter) WithElapsedTimeRoundingFactor ¶ added in v0.12.0
func (p ProgressbarPrinter) WithElapsedTimeRoundingFactor(duration time.Duration) *ProgressbarPrinter
WithElapsedTimeRoundingFactor sets the rounding factor of the elapsed time.
func (ProgressbarPrinter) WithLastCharacter ¶ added in v0.12.0
func (p ProgressbarPrinter) WithLastCharacter(char string) *ProgressbarPrinter
WithLastCharacter sets the last character of the ProgressbarPrinter.
func (ProgressbarPrinter) WithMaxWidth ¶ added in v0.12.37
func (p ProgressbarPrinter) WithMaxWidth(maxWidth int) *ProgressbarPrinter
WithMaxWidth sets the maximum width of the ProgressbarPrinter. If the terminal is smaller than the given width, the terminal width will be used instead. If the width is set to zero, or below, the terminal width will be used.
func (ProgressbarPrinter) WithRemoveWhenDone ¶ added in v0.12.0
func (p ProgressbarPrinter) WithRemoveWhenDone(b ...bool) *ProgressbarPrinter
WithRemoveWhenDone sets if the ProgressbarPrinter should be removed when it is done.
func (ProgressbarPrinter) WithShowCount ¶ added in v0.12.0
func (p ProgressbarPrinter) WithShowCount(b ...bool) *ProgressbarPrinter
WithShowCount sets if the total and current count should be displayed in the ProgressbarPrinter.
func (ProgressbarPrinter) WithShowElapsedTime ¶ added in v0.12.0
func (p ProgressbarPrinter) WithShowElapsedTime(b ...bool) *ProgressbarPrinter
WithShowElapsedTime sets if the elapsed time should be displayed in the ProgressbarPrinter.
func (ProgressbarPrinter) WithShowPercentage ¶ added in v0.12.0
func (p ProgressbarPrinter) WithShowPercentage(b ...bool) *ProgressbarPrinter
WithShowPercentage sets if the completed percentage should be displayed in the ProgressbarPrinter.
func (ProgressbarPrinter) WithShowTitle ¶ added in v0.12.0
func (p ProgressbarPrinter) WithShowTitle(b ...bool) *ProgressbarPrinter
WithShowTitle sets if the title should be displayed in the ProgressbarPrinter.
func (ProgressbarPrinter) WithTitle ¶ added in v0.12.0
func (p ProgressbarPrinter) WithTitle(name string) *ProgressbarPrinter
WithTitle sets the name of the ProgressbarPrinter.
func (ProgressbarPrinter) WithTitleStyle ¶ added in v0.12.0
func (p ProgressbarPrinter) WithTitleStyle(style *Style) *ProgressbarPrinter
WithTitleStyle sets the style of the title.
func (ProgressbarPrinter) WithTotal ¶ added in v0.12.0
func (p ProgressbarPrinter) WithTotal(total int) *ProgressbarPrinter
WithTotal sets the total value of the ProgressbarPrinter.
func (ProgressbarPrinter) WithWriter ¶ added in v0.12.42
func (p ProgressbarPrinter) WithWriter(writer io.Writer) *ProgressbarPrinter
WithWriter sets the custom Writer.
type RGB ¶ added in v0.5.1
RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three additive primary colors, red, green, and blue. https://en.wikipedia.org/wiki/RGB_color_model
func NewRGBFromHEX
deprecated
added in
v0.5.1
func (RGB) Fade ¶ added in v0.5.1
Fade fades one RGB value (over other RGB values) to another RGB value, by giving the function a minimum, maximum and current value.
func (RGB) Print ¶ added in v0.5.1
func (p RGB) Print(a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (RGB) PrintOnError ¶ added in v0.12.19
func (p RGB) PrintOnError(a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (RGB) PrintOnErrorf ¶ added in v0.12.33
func (p RGB) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (RGB) Printf ¶ added in v0.5.1
func (p RGB) Printf(format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (RGB) Printfln ¶ added in v0.12.14
func (p RGB) Printfln(format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (RGB) Println ¶ added in v0.5.1
func (p RGB) Println(a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (RGB) Sprint ¶ added in v0.5.1
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (RGB) Sprintf ¶ added in v0.5.1
Sprintf formats according to a format specifier and returns the resulting string.
func (RGB) Sprintfln ¶ added in v0.12.14
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (RGB) Sprintln ¶ added in v0.5.1
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (RGB) ToRGBStyle ¶ added in v0.12.60
type RGBStyle ¶ added in v0.12.60
type RGBStyle struct { Options []Color Foreground, Background RGB // contains filtered or unexported fields }
func NewRGBStyle ¶ added in v0.12.60
NewRGBStyle returns a new RGBStyle. The foreground color is required, the background color is optional. The colors will be set as is, ignoring the RGB.Background property.
func (RGBStyle) AddOptions ¶ added in v0.12.60
AddOptions adds options to the RGBStyle.
func (RGBStyle) Print ¶ added in v0.12.60
func (p RGBStyle) Print(a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (RGBStyle) PrintOnError ¶ added in v0.12.60
func (p RGBStyle) PrintOnError(a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (RGBStyle) PrintOnErrorf ¶ added in v0.12.60
func (p RGBStyle) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (RGBStyle) Printf ¶ added in v0.12.60
func (p RGBStyle) Printf(format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (RGBStyle) Printfln ¶ added in v0.12.60
func (p RGBStyle) Printfln(format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (RGBStyle) Println ¶ added in v0.12.60
func (p RGBStyle) Println(a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (RGBStyle) Sprint ¶ added in v0.12.60
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (RGBStyle) Sprintf ¶ added in v0.12.60
Sprintf formats according to a format specifier and returns the resulting string.
type RenderPrinter ¶ added in v0.5.0
type RenderPrinter interface { // Render the XXX to the terminal. Render() error // Srender returns the rendered string of XXX. Srender() (string, error) }
RenderPrinter is used to display renderable content. Example for renderable content is a Table.
type Scope ¶
Scope contains the data of the optional scope of a prefix. If it has a text, it will be printed after the Prefix in brackets.
type SectionPrinter ¶ added in v0.3.2
type SectionPrinter struct { Style *Style Level int IndentCharacter string TopPadding int BottomPadding int Writer io.Writer }
SectionPrinter prints a new section title. It can be used to structure longer text, or different chapters of your program.
func (*SectionPrinter) Print ¶ added in v0.3.2
func (p *SectionPrinter) Print(a ...interface{}) *TextPrinter
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered.
func (*SectionPrinter) PrintOnError ¶ added in v0.12.19
func (p *SectionPrinter) PrintOnError(a ...interface{}) *TextPrinter
PrintOnError prints every error which is not nil. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*SectionPrinter) PrintOnErrorf ¶ added in v0.12.33
func (p *SectionPrinter) PrintOnErrorf(format string, a ...interface{}) *TextPrinter
PrintOnErrorf wraps every error which is not nil and prints it. If every error is nil, nothing will be printed. This can be used for simple error checking.
func (*SectionPrinter) Printf ¶ added in v0.3.2
func (p *SectionPrinter) Printf(format string, a ...interface{}) *TextPrinter
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered.
func (*SectionPrinter) Printfln ¶ added in v0.12.14
func (p *SectionPrinter) Printfln(format string, a ...interface{}) *TextPrinter
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (*SectionPrinter) Println ¶ added in v0.3.2
func (p *SectionPrinter) Println(a ...interface{}) *TextPrinter
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered.
func (SectionPrinter) Sprint ¶ added in v0.3.2
func (p SectionPrinter) Sprint(a ...interface{}) string
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string.
func (SectionPrinter) Sprintf ¶ added in v0.3.2
func (p SectionPrinter) Sprintf(format string, a ...interface{}) string
Sprintf formats according to a format specifier and returns the resulting string.
func (SectionPrinter) Sprintfln ¶ added in v0.12.14
func (p SectionPrinter) Sprintfln(format string, a ...interface{}) string
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (SectionPrinter) Sprintln ¶ added in v0.3.2
func (p SectionPrinter) Sprintln(a ...interface{}) string
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
func (SectionPrinter) WithBottomPadding ¶ added in v0.5.0
func (p SectionPrinter) WithBottomPadding(padding int) *SectionPrinter
WithBottomPadding returns a new SectionPrinter with a specific top padding.
func (SectionPrinter) WithIndentCharacter ¶ added in v0.8.0
func (p SectionPrinter) WithIndentCharacter(char string) *SectionPrinter
WithIndentCharacter returns a new SectionPrinter with a specific IndentCharacter.
func (SectionPrinter) WithLevel ¶ added in v0.4.0
func (p SectionPrinter) WithLevel(level int) *SectionPrinter
WithLevel returns a new SectionPrinter with a specific level.
func (SectionPrinter) WithStyle ¶ added in v0.4.0
func (p SectionPrinter) WithStyle(style *Style) *SectionPrinter
WithStyle returns a new SectionPrinter with a specific style.
func (SectionPrinter) WithTopPadding ¶ added in v0.4.0
func (p SectionPrinter) WithTopPadding(padding int) *SectionPrinter
WithTopPadding returns a new SectionPrinter with a specific top padding.
func (SectionPrinter) WithWriter ¶ added in v0.12.40
func (p SectionPrinter) WithWriter(writer io.Writer) *SectionPrinter
WithWriter sets the custom Writer.
type SlogHandler ¶ added in v0.12.67
type SlogHandler struct {
// contains filtered or unexported fields
}
func NewSlogHandler ¶ added in v0.12.67
func NewSlogHandler(logger *Logger) *SlogHandler
NewSlogHandler returns a new logging handler that can be intrgrated with log/slog.
type SpinnerPrinter ¶ added in v0.12.0
type SpinnerPrinter struct { Text string Sequence []string Style *Style Delay time.Duration MessageStyle *Style InfoPrinter TextPrinter SuccessPrinter TextPrinter FailPrinter TextPrinter WarningPrinter TextPrinter RemoveWhenDone bool ShowTimer bool TimerRoundingFactor time.Duration TimerStyle *Style IsActive bool Writer io.Writer // contains filtered or unexported fields }
SpinnerPrinter is a loading animation, which can be used if the progress is unknown. It's an animation loop, which can have a text and supports throwing errors or warnings. A TextPrinter is used to display all outputs, after the SpinnerPrinter is done.
func (*SpinnerPrinter) Fail ¶ added in v0.12.0
func (s *SpinnerPrinter) Fail(message ...interface{})
Fail displays the fail printer. If no message is given, the text of the SpinnerPrinter will be reused as the default message.
func (*SpinnerPrinter) GenericStart ¶ added in v0.12.0
func (s *SpinnerPrinter) GenericStart() (*LivePrinter, error)
GenericStart runs Start, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Start instead of this in your program.
func (*SpinnerPrinter) GenericStop ¶ added in v0.12.0
func (s *SpinnerPrinter) GenericStop() (*LivePrinter, error)
GenericStop runs Stop, but returns a LivePrinter. This is used for the interface LivePrinter. You most likely want to use Stop instead of this in your program.
func (*SpinnerPrinter) Info ¶ added in v0.12.44
func (s *SpinnerPrinter) Info(message ...interface{})
Info displays an info message If no message is given, the text of the SpinnerPrinter will be reused as the default message.
func (*SpinnerPrinter) SetWriter ¶ added in v0.12.66
func (p *SpinnerPrinter) SetWriter(writer io.Writer)
SetWriter sets the custom Writer.
func (SpinnerPrinter) Start ¶ added in v0.12.0
func (s SpinnerPrinter) Start(text ...interface{}) (*SpinnerPrinter, error)
Start the SpinnerPrinter.
func (*SpinnerPrinter) Stop ¶ added in v0.12.0
func (s *SpinnerPrinter) Stop() error
Stop terminates the SpinnerPrinter immediately. The SpinnerPrinter will not resolve into anything.
func (*SpinnerPrinter) Success ¶ added in v0.12.0
func (s *SpinnerPrinter) Success(message ...interface{})
Success displays the success printer. If no message is given, the text of the SpinnerPrinter will be reused as the default message.
func (*SpinnerPrinter) UpdateText ¶ added in v0.12.0
func (s *SpinnerPrinter) UpdateText(text string)
UpdateText updates the message of the active SpinnerPrinter. Can be used live.
func (*SpinnerPrinter) Warning ¶ added in v0.12.0
func (s *SpinnerPrinter) Warning(message ...interface{})
Warning displays the warning printer. If no message is given, the text of the SpinnerPrinter will be reused as the default message.
func (SpinnerPrinter) WithDelay ¶ added in v0.12.0
func (s SpinnerPrinter) WithDelay(delay time.Duration) *SpinnerPrinter
WithDelay adds a delay to the SpinnerPrinter.
func (SpinnerPrinter) WithMessageStyle ¶ added in v0.12.0
func (s SpinnerPrinter) WithMessageStyle(style *Style) *SpinnerPrinter
WithMessageStyle adds a style to the SpinnerPrinter message.
func (SpinnerPrinter) WithRemoveWhenDone ¶ added in v0.12.0
func (s SpinnerPrinter) WithRemoveWhenDone(b ...bool) *SpinnerPrinter
WithRemoveWhenDone removes the SpinnerPrinter after it is done.
func (SpinnerPrinter) WithSequence ¶ added in v0.12.0
func (s SpinnerPrinter) WithSequence(sequence ...string) *SpinnerPrinter
WithSequence adds a sequence to the SpinnerPrinter.
func (SpinnerPrinter) WithShowTimer ¶ added in v0.12.28
func (s SpinnerPrinter) WithShowTimer(b ...bool) *SpinnerPrinter
WithShowTimer shows how long the spinner is running.
func (SpinnerPrinter) WithStyle ¶ added in v0.12.0
func (s SpinnerPrinter) WithStyle(style *Style) *SpinnerPrinter
WithStyle adds a style to the SpinnerPrinter.
func (SpinnerPrinter) WithText ¶ added in v0.12.0
func (s SpinnerPrinter) WithText(text string) *SpinnerPrinter
WithText adds a text to the SpinnerPrinter.
func (SpinnerPrinter) WithTimerRoundingFactor ¶ added in v0.12.28
func (s SpinnerPrinter) WithTimerRoundingFactor(factor time.Duration) *SpinnerPrinter
WithTimerRoundingFactor sets the rounding factor for the timer.
func (SpinnerPrinter) WithTimerStyle ¶ added in v0.12.28
func (s SpinnerPrinter) WithTimerStyle(style *Style) *SpinnerPrinter
WithTimerStyle adds a style to the SpinnerPrinter timer.
func (SpinnerPrinter) WithWriter ¶ added in v0.12.42
func (p SpinnerPrinter) WithWriter(writer io.Writer) *SpinnerPrinter
WithWriter sets the custom Writer.
type Style ¶
type Style []Color
Style is a collection of colors. Can include foreground, background and styling (eg. Bold, Underscore, etc.) colors.
func (Style) Print ¶
func (s Style) Print(a ...interface{})
Print formats using the default formats for its operands and writes to standard output. Spaces are added between operands when neither is a string. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Style.
func (Style) Printf ¶
Printf formats according to a format specifier and writes to standard output. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Style.
func (Style) Printfln ¶ added in v0.12.14
Printfln formats according to a format specifier and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Style.
func (Style) Println ¶
func (s Style) Println(a ...interface{})
Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered. Input will be colored with the parent Style.
func (Style) RemoveColor ¶ added in v0.12.58
RemoveColor removes the given colors from the Style.
func (Style) Sprint ¶
Sprint formats using the default formats for its operands and returns the resulting string. Spaces are added between operands when neither is a string. Input will be colored with the parent Style.
func (Style) Sprintf ¶
Sprintf formats according to a format specifier and returns the resulting string. Input will be colored with the parent Style.
func (Style) Sprintfln ¶ added in v0.12.14
Sprintfln formats according to a format specifier and returns the resulting string. Spaces are always added between operands and a newline is appended. Input will be colored with the parent Style.
type TableData ¶ added in v0.5.0
type TableData [][]string
TableData is the type that contains the data of a TablePrinter.
type TablePrinter ¶ added in v0.12.0
type TablePrinter struct { Style *Style HasHeader bool HeaderStyle *Style HeaderRowSeparator string HeaderRowSeparatorStyle *Style Separator string SeparatorStyle *Style RowSeparator string RowSeparatorStyle *Style Data TableData Boxed bool LeftAlignment bool RightAlignment bool Writer io.Writer }
TablePrinter is able to render tables.
func (TablePrinter) Render ¶ added in v0.12.0
func (p TablePrinter) Render() error
Render prints the TablePrinter to the terminal.
func (TablePrinter) Srender ¶ added in v0.12.0
func (p TablePrinter) Srender() (string, error)
Srender renders the TablePrinter as a string.
func (TablePrinter) WithBoxed ¶ added in v0.12.25
func (p TablePrinter) WithBoxed(b ...bool) *TablePrinter
WithBoxed returns a new TablePrinter with a box around the table.
func (TablePrinter) WithCSVReader ¶ added in v0.12.0
func (p TablePrinter) WithCSVReader(reader *csv.Reader) *TablePrinter
WithCSVReader return a new TablePrinter with specified Data extracted from CSV.
func (TablePrinter) WithData ¶ added in v0.12.0
func (p TablePrinter) WithData(data [][]string) *TablePrinter
WithData returns a new TablePrinter with specific Data.
func (TablePrinter) WithHasHeader ¶ added in v0.12.0
func (p TablePrinter) WithHasHeader(b ...bool) *TablePrinter
WithHasHeader returns a new TablePrinter, where the first line is marked as a header.
func (TablePrinter) WithHeaderRowSeparator ¶ added in v0.12.36
func (p TablePrinter) WithHeaderRowSeparator(separator string) *TablePrinter
WithHeaderRowSeparator returns a new TablePrinter with a specific header HeaderRowSeparator.
func (TablePrinter) WithHeaderRowSeparatorStyle ¶ added in v0.12.36
func (p TablePrinter) WithHeaderRowSeparatorStyle(style *Style) *TablePrinter
WithHeaderRowSeparatorStyle returns a new TablePrinter with a specific header HeaderRowSeparatorStyle.
func (TablePrinter) WithHeaderStyle ¶ added in v0.12.0
func (p TablePrinter) WithHeaderStyle(style *Style) *TablePrinter
WithHeaderStyle returns a new TablePrinter with a specific HeaderStyle.
func (TablePrinter) WithLeftAlignment ¶ added in v0.12.33
func (p TablePrinter) WithLeftAlignment(b ...bool) *TablePrinter
WithLeftAlignment returns a new TablePrinter with left alignment.
func (TablePrinter) WithRightAlignment ¶ added in v0.12.33
func (p TablePrinter) WithRightAlignment(b ...bool) *TablePrinter
WithRightAlignment returns a new TablePrinter with right alignment.
func (TablePrinter) WithRowSeparator ¶ added in v0.12.36
func (p TablePrinter) WithRowSeparator(separator string) *TablePrinter
WithRowSeparator returns a new TablePrinter with a specific RowSeparator.
func (TablePrinter) WithRowSeparatorStyle ¶ added in v0.12.36
func (p TablePrinter) WithRowSeparatorStyle(style *Style) *TablePrinter
WithRowSeparatorStyle returns a new TablePrinter with a specific RowSeparatorStyle.
func (TablePrinter) WithSeparator ¶ added in v0.12.0
func (p TablePrinter) WithSeparator(separator string) *TablePrinter
WithSeparator returns a new TablePrinter with a specific separator.
func (TablePrinter) WithSeparatorStyle ¶ added in v0.12.0
func (p TablePrinter) WithSeparatorStyle(style *Style) *TablePrinter
WithSeparatorStyle returns a new TablePrinter with a specific SeparatorStyle.
func (TablePrinter) WithStyle ¶ added in v0.12.0
func (p TablePrinter) WithStyle(style *Style) *TablePrinter
WithStyle returns a new TablePrinter with a specific Style.
func (TablePrinter) WithWriter ¶ added in v0.12.40
func (p TablePrinter) WithWriter(writer io.Writer) *TablePrinter
WithWriter sets the Writer.
type TextPrinter ¶ added in v0.5.0
type TextPrinter interface { // Sprint formats using the default formats for its operands and returns the resulting string. // Spaces are added between operands when neither is a string. Sprint(a ...interface{}) string // Sprintln formats using the default formats for its operands and returns the resulting string. // Spaces are always added between operands and a newline is appended. Sprintln(a ...interface{}) string // Sprintf formats according to a format specifier and returns the resulting string. Sprintf(format string, a ...interface{}) string // Sprintfln formats according to a format specifier and returns the resulting string. // Spaces are always added between operands and a newline is appended. Sprintfln(format string, a ...interface{}) string // Print formats using the default formats for its operands and writes to standard output. // Spaces are added between operands when neither is a string. // It returns the number of bytes written and any write error encountered. Print(a ...interface{}) *TextPrinter // Println formats using the default formats for its operands and writes to standard output. // Spaces are always added between operands and a newline is appended. // It returns the number of bytes written and any write error encountered. Println(a ...interface{}) *TextPrinter // Printf formats according to a format specifier and writes to standard output. // It returns the number of bytes written and any write error encountered. Printf(format string, a ...interface{}) *TextPrinter // Printfln formats according to a format specifier and writes to standard output. // Spaces are always added between operands and a newline is appended. // It returns the number of bytes written and any write error encountered. Printfln(format string, a ...interface{}) *TextPrinter // PrintOnError prints every error which is not nil. // If every error is nil, nothing will be printed. // This can be used for simple error checking. PrintOnError(a ...interface{}) *TextPrinter // PrintOnErrorf wraps every error which is not nil and prints it. // If every error is nil, nothing will be printed. // This can be used for simple error checking. PrintOnErrorf(format string, a ...interface{}) *TextPrinter }
TextPrinter contains methods to print formatted text to the console or return it as a string.
type Theme ¶ added in v0.6.0
type Theme struct { DefaultText Style PrimaryStyle Style SecondaryStyle Style HighlightStyle Style InfoMessageStyle Style InfoPrefixStyle Style SuccessMessageStyle Style SuccessPrefixStyle Style WarningMessageStyle Style WarningPrefixStyle Style ErrorMessageStyle Style ErrorPrefixStyle Style FatalMessageStyle Style FatalPrefixStyle Style DescriptionMessageStyle Style DescriptionPrefixStyle Style ScopeStyle Style ProgressbarBarStyle Style ProgressbarTitleStyle Style HeaderTextStyle Style HeaderBackgroundStyle Style SpinnerStyle Style SpinnerTextStyle Style TimerStyle Style TableStyle Style TableHeaderStyle Style TableSeparatorStyle Style HeatmapStyle Style HeatmapHeaderStyle Style HeatmapSeparatorStyle Style SectionStyle Style BulletListTextStyle Style BulletListBulletStyle Style TreeStyle Style TreeTextStyle Style LetterStyle Style DebugMessageStyle Style DebugPrefixStyle Style BoxStyle Style BoxTextStyle Style BarLabelStyle Style BarStyle Style Checkmark Checkmark }
Theme for PTerm. Theme contains every Style used in PTerm. You can create own themes for your application or use one of the existing themes.
func (Theme) WithBarLabelStyle ¶ added in v0.12.7
WithBarLabelStyle returns a new theme with overridden value.
func (Theme) WithBarStyle ¶ added in v0.12.7
WithBarStyle returns a new theme with overridden value.
func (Theme) WithBoxStyle ¶ added in v0.12.8
WithBoxStyle returns a new theme with overridden value.
func (Theme) WithBoxTextStyle ¶ added in v0.12.8
WithBoxTextStyle returns a new theme with overridden value.
func (Theme) WithBulletListBulletStyle ¶ added in v0.10.0
WithBulletListBulletStyle returns a new theme with overridden value.
func (Theme) WithBulletListTextStyle ¶ added in v0.10.0
WithBulletListTextStyle returns a new theme with overridden value.
func (Theme) WithDebugMessageStyle ¶ added in v0.9.0
WithDebugMessageStyle returns a new theme with overridden value.
func (Theme) WithDebugPrefixStyle ¶ added in v0.9.0
WithDebugPrefixStyle returns a new theme with overridden value.
func (Theme) WithDescriptionMessageStyle ¶ added in v0.6.0
WithDescriptionMessageStyle returns a new theme with overridden value.
func (Theme) WithDescriptionPrefixStyle ¶ added in v0.6.0
WithDescriptionPrefixStyle returns a new theme with overridden value.
func (Theme) WithErrorMessageStyle ¶ added in v0.6.0
WithErrorMessageStyle returns a new theme with overridden value.
func (Theme) WithErrorPrefixStyle ¶ added in v0.6.0
WithErrorPrefixStyle returns a new theme with overridden value.
func (Theme) WithFatalMessageStyle ¶ added in v0.6.0
WithFatalMessageStyle returns a new theme with overridden value.
func (Theme) WithFatalPrefixStyle ¶ added in v0.6.0
WithFatalPrefixStyle returns a new theme with overridden value.
func (Theme) WithHighlightStyle ¶ added in v0.6.0
WithHighlightStyle returns a new theme with overridden value.
func (Theme) WithInfoMessageStyle ¶ added in v0.6.0
WithInfoMessageStyle returns a new theme with overridden value.
func (Theme) WithInfoPrefixStyle ¶ added in v0.6.0
WithInfoPrefixStyle returns a new theme with overridden value.
func (Theme) WithLetterStyle ¶ added in v0.8.0
WithLetterStyle returns a new theme with overridden value.
func (Theme) WithPrimaryStyle ¶ added in v0.6.0
WithPrimaryStyle returns a new theme with overridden value.
func (Theme) WithSecondaryStyle ¶ added in v0.6.0
WithSecondaryStyle returns a new theme with overridden value.
func (Theme) WithSuccessMessageStyle ¶ added in v0.6.0
WithSuccessMessageStyle returns a new theme with overridden value.
func (Theme) WithSuccessPrefixStyle ¶ added in v0.6.0
WithSuccessPrefixStyle returns a new theme with overridden value.
func (Theme) WithTreeStyle ¶ added in v0.9.3
WithTreeStyle returns a new theme with overridden value.
func (Theme) WithTreeTextStyle ¶ added in v0.9.3
WithTreeTextStyle returns a new theme with overridden value.
func (Theme) WithWarningMessageStyle ¶ added in v0.6.0
WithWarningMessageStyle returns a new theme with overridden value.
func (Theme) WithWarningPrefixStyle ¶ added in v0.6.0
WithWarningPrefixStyle returns a new theme with overridden value.
type TreeNode ¶ added in v0.9.3
TreeNode is used as items in a TreePrinter.
func NewTreeFromLeveledList
deprecated
added in
v0.9.3
func NewTreeFromLeveledList(leveledListItems LeveledList) TreeNode
NewTreeFromLeveledList converts a TreeItems list to a TreeNode and returns it.
Deprecated: use putils.TreeFromLeveledList instead.
type TreePrinter ¶ added in v0.12.0
type TreePrinter struct { Root TreeNode TreeStyle *Style TextStyle *Style TopRightCornerString string TopRightDownString string HorizontalString string VerticalString string RightDownLeftString string Indent int Writer io.Writer }
TreePrinter is able to render a list.
func (TreePrinter) Render ¶ added in v0.12.0
func (p TreePrinter) Render() error
Render prints the list to the terminal.
func (TreePrinter) Srender ¶ added in v0.12.0
func (p TreePrinter) Srender() (string, error)
Srender renders the list as a string.
func (TreePrinter) WithHorizontalString ¶ added in v0.12.0
func (p TreePrinter) WithHorizontalString(s string) *TreePrinter
WithHorizontalString returns a new list with a specific HorizontalString.
func (TreePrinter) WithIndent ¶ added in v0.12.0
func (p TreePrinter) WithIndent(indent int) *TreePrinter
WithIndent returns a new list with a specific amount of spacing between the levels. Indent must be at least 1.
func (TreePrinter) WithRoot ¶ added in v0.12.0
func (p TreePrinter) WithRoot(root TreeNode) *TreePrinter
WithRoot returns a new list with a specific Root.
func (TreePrinter) WithTextStyle ¶ added in v0.12.0
func (p TreePrinter) WithTextStyle(style *Style) *TreePrinter
WithTextStyle returns a new list with a specific text style.
func (TreePrinter) WithTopRightCornerString ¶ added in v0.12.0
func (p TreePrinter) WithTopRightCornerString(s string) *TreePrinter
WithTopRightCornerString returns a new list with a specific TopRightCornerString.
func (TreePrinter) WithTopRightDownStringOngoing ¶ added in v0.12.0
func (p TreePrinter) WithTopRightDownStringOngoing(s string) *TreePrinter
WithTopRightDownStringOngoing returns a new list with a specific TopRightDownString.
func (TreePrinter) WithTreeStyle ¶ added in v0.12.0
func (p TreePrinter) WithTreeStyle(style *Style) *TreePrinter
WithTreeStyle returns a new list with a specific tree style.
func (TreePrinter) WithVerticalString ¶ added in v0.12.0
func (p TreePrinter) WithVerticalString(s string) *TreePrinter
WithVerticalString returns a new list with a specific VerticalString.
func (TreePrinter) WithWriter ¶ added in v0.12.40
func (p TreePrinter) WithWriter(writer io.Writer) *TreePrinter
WithWriter sets the Writer.
Source Files ¶
- area_printer.go
- atoms.go
- barchart.go
- basic_text_printer.go
- bigtext_printer.go
- box_printer.go
- bulletlist_printer.go
- center_printer.go
- color.go
- deprecated.go
- errors.go
- header_printer.go
- heatmap_printer.go
- interactive_confirm_printer.go
- interactive_continue_printer.go
- interactive_multiselect_printer.go
- interactive_select_printer.go
- interactive_textinput_printer.go
- interface_live_printer.go
- interface_renderable_printer.go
- interface_text_printer.go
- logger.go
- multi_live_printer.go
- panel_printer.go
- paragraph_printer.go
- prefix_printer.go
- print.go
- progressbar_printer.go
- pterm.go
- rgb.go
- section_printer.go
- slog_handler.go
- spinner_printer.go
- table_printer.go
- terminal.go
- theme.go
- tree_printer.go
Directories ¶
Path | Synopsis |
---|---|
_examples
|
|
Package putils contains utility functions for PTerm, to make it's usage even easier! It contains pre-made functions, that utilize PTerm, to print various stuff to the terminal.
|
Package putils contains utility functions for PTerm, to make it's usage even easier! It contains pre-made functions, that utilize PTerm, to print various stuff to the terminal. |