Documentation
¶
Index ¶
- Variables
- 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 Printf(format string, a ...interface{})
- func Println(a ...interface{})
- func Printo(a ...interface{})
- func RemoveColorFromString(a ...interface{}) string
- func SetDefaultOutput(w io.Writer)
- func Sprint(a ...interface{}) string
- func Sprintf(format string, a ...interface{}) string
- func Sprintln(a ...interface{}) string
- func Sprinto(a ...interface{}) string
- type Color
- func (c Color) Print(a ...interface{})
- func (c Color) Printf(format string, a ...interface{})
- func (c Color) Println(a ...interface{})
- func (c Color) Sprint(a ...interface{}) string
- func (c Color) Sprintf(format string, a ...interface{}) string
- func (c Color) Sprintln(a ...interface{}) string
- func (c Color) String() string
- type GenericPrinter
- type HeaderPrinter
- func (p HeaderPrinter) Print(a ...interface{}) GenericPrinter
- func (p HeaderPrinter) Printf(format string, a ...interface{}) GenericPrinter
- func (p HeaderPrinter) Println(a ...interface{}) GenericPrinter
- func (p HeaderPrinter) Sprint(a ...interface{}) string
- func (p HeaderPrinter) Sprintf(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
- type Prefix
- type PrefixPrinter
- func (p PrefixPrinter) GetFormattedPrefix() string
- func (p PrefixPrinter) Print(a ...interface{}) GenericPrinter
- func (p PrefixPrinter) Printf(format string, a ...interface{}) GenericPrinter
- func (p PrefixPrinter) Println(a ...interface{}) GenericPrinter
- func (p PrefixPrinter) Sprint(a ...interface{}) string
- func (p PrefixPrinter) Sprintf(format string, a ...interface{}) string
- func (p PrefixPrinter) Sprintln(a ...interface{}) string
- func (p PrefixPrinter) WithFatal(b ...bool) *PrefixPrinter
- func (p PrefixPrinter) WithMessageStyle(style Style) *PrefixPrinter
- func (p PrefixPrinter) WithPrefix(prefix Prefix) *PrefixPrinter
- func (p PrefixPrinter) WithScope(scope Scope) *PrefixPrinter
- type Progressbar
- func (p *Progressbar) Add(count int) *Progressbar
- func (p *Progressbar) GetElapsedTime() time.Duration
- func (p *Progressbar) Increment() *Progressbar
- func (p Progressbar) Start() *Progressbar
- func (p *Progressbar) Stop() *Progressbar
- func (p Progressbar) WithBarStyle(style Style) *Progressbar
- func (p Progressbar) WithCurrent(current int) *Progressbar
- func (p Progressbar) WithElapsedTimeRoundingFactor(duration time.Duration) *Progressbar
- func (p Progressbar) WithLastCharacter(char string) *Progressbar
- func (p Progressbar) WithLineCharacter(char string) *Progressbar
- func (p Progressbar) WithShowCount(b ...bool) *Progressbar
- func (p Progressbar) WithShowElapsedTime(b ...bool) *Progressbar
- func (p Progressbar) WithShowPercentage(b ...bool) *Progressbar
- func (p Progressbar) WithShowTitle(b ...bool) *Progressbar
- func (p Progressbar) WithTitle(name string) *Progressbar
- func (p Progressbar) WithTitleStyle(style Style) *Progressbar
- func (p Progressbar) WithTotal(total int) *Progressbar
- func (p Progressbar) WithUpdateDelay(delay time.Duration) *Progressbar
- type Scope
- type SectionPrinter
- func (p SectionPrinter) Print(a ...interface{}) GenericPrinter
- func (p SectionPrinter) Printf(format string, a ...interface{}) GenericPrinter
- func (p SectionPrinter) Println(a ...interface{}) GenericPrinter
- func (p SectionPrinter) Sprint(a ...interface{}) string
- func (p SectionPrinter) Sprintf(format string, a ...interface{}) string
- func (p SectionPrinter) Sprintln(a ...interface{}) string
- func (p SectionPrinter) WithLevel(level int) *SectionPrinter
- func (p SectionPrinter) WithStyle(style Style) *SectionPrinter
- func (p SectionPrinter) WithTopPadding(level int) *SectionPrinter
- type Spinner
- func (s *Spinner) Fail(message ...interface{})
- func (s Spinner) Start(text ...interface{}) *Spinner
- func (s *Spinner) Stop()
- func (s *Spinner) Success(message ...interface{})
- func (s *Spinner) UpdateText(text string)
- func (s *Spinner) Warning(message ...interface{})
- func (s Spinner) WithDelay(delay time.Duration) *Spinner
- func (s Spinner) WithMessageStyle(style Style) *Spinner
- func (s Spinner) WithRemoveWhenDone(b ...bool) *Spinner
- func (s Spinner) WithSequence(sequence ...string) *Spinner
- func (s Spinner) WithStyle(style Style) *Spinner
- func (s Spinner) WithText(text string) *Spinner
- 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) Println(a ...interface{})
- func (s Style) Sprint(a ...interface{}) string
- func (s Style) Sprintf(format string, a ...interface{}) string
- func (s Style) Sprintln(a ...interface{}) string
- func (s Style) String() string
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 ( // Info returns a PrefixPrinter, which can be used to print text with an "info" Prefix. Info = PrefixPrinter{ Prefix: Prefix{ Text: "INFO", Style: NewStyle(FgBlack, BgCyan), }, MessageStyle: NewStyle(FgLightCyan), } // Warning returns a PrefixPrinter, which can be used to print text with a "warning" Prefix. Warning = PrefixPrinter{ Prefix: Prefix{ Text: "WARNING", Style: NewStyle(FgBlack, BgYellow), }, MessageStyle: NewStyle(FgYellow), } // Success returns a PrefixPrinter, which can be used to print text with a "success" Prefix. Success = PrefixPrinter{ Prefix: Prefix{ Text: "SUCCESS", Style: NewStyle(FgBlack, BgGreen), }, MessageStyle: NewStyle(FgGreen), } // Error returns a PrefixPrinter, which can be used to print text with an "error" Prefix. Error = PrefixPrinter{ Prefix: Prefix{ Text: "ERROR", Style: NewStyle(FgBlack, BgLightRed), }, MessageStyle: NewStyle(FgLightRed), } // Fatal returns a PrefixPrinter, which can be used to print text with an "fatal" Prefix. // NOTICE: Fatal terminates the application immediately! Fatal = PrefixPrinter{ Prefix: Prefix{ Text: "FATAL", Style: NewStyle(FgBlack, BgLightRed), }, MessageStyle: NewStyle(FgLightRed), Fatal: true, } // Description returns a PrefixPrinter, which can be used to print text with a "description" Prefix. Description = PrefixPrinter{ Prefix: Prefix{ Text: "Description", Style: Style{FgLightWhite, BgDarkGray}, }, MessageStyle: Style{FgLightWhite}, } )
var ActiveProgressBars []*Progressbar
ActiveProgressBars contains all running progressbars. Generally, there should only be one active Progressbar at a time.
var ( // DefaultHeader returns the printer for a default header text. // Defaults to LightWhite, Bold Text and a Gray DefaultHeader background. DefaultHeader = HeaderPrinter{ TextStyle: Style{FgLightWhite, Bold}, BackgroundStyle: Style{BgGray}, Margin: 5, } )
var ( // DefaultProgressbar is the default progressbar. DefaultProgressbar = Progressbar{ Total: 100, LineCharacter: "█", LastCharacter: "█", ElapsedTimeRoundingFactor: time.Second, BarStyle: Style{FgLightCyan}, TitleStyle: Style{FgCyan}, ShowTitle: true, ShowCount: true, ShowPercentage: true, ShowElapsedTime: true, BarFiller: " ", } )
var DefaultSection = SectionPrinter{ Style: NewStyle(FgLightYellow, Underscore), Level: 1, TopPadding: 1, }
DefaultSection is the default section printer.
var DefaultSpinner = Spinner{ Sequence: []string{"▀ ", " ▀", " ▄", "▄ "}, Style: Style{FgLightCyan}, Delay: time.Millisecond * 200, MessageStyle: Style{FgLightWhite}, SuccessPrinter: Success, FailPrinter: Error, WarningPrinter: Warning, }
DefaultSpinner is the default spinner.
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") )
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) )
Functions ¶
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 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 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. To create a new line, which Example: pterm.Printo("Hello, World") time.Sleep(time.Second) pterm.Oprint("Hello, Earth!")
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 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.
Types ¶
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{})
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) 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 Color.
func (Color) Println ¶
func (c Color) 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 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.
type GenericPrinter ¶
type GenericPrinter 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
// 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{}) GenericPrinter
// 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{}) GenericPrinter
// 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{}) GenericPrinter
}
GenericPrinter contains methods to print formatted text to the console or return it as a string.
type HeaderPrinter ¶ added in v0.0.1
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{}) GenericPrinter
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) Printf ¶ added in v0.0.1
func (p HeaderPrinter) Printf(format string, a ...interface{}) GenericPrinter
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) Println ¶ added in v0.0.1
func (p HeaderPrinter) Println(a ...interface{}) GenericPrinter
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) 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
type PrefixPrinter ¶
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{}) GenericPrinter
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) Printf ¶
func (p PrefixPrinter) Printf(format string, a ...interface{}) GenericPrinter
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) Println ¶
func (p PrefixPrinter) Println(a ...interface{}) GenericPrinter
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) 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) 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) 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.
type Progressbar ¶ added in v0.2.1
type Progressbar struct {
Title string
Total int
Current int
UpdateDelay time.Duration
LineCharacter string
LastCharacter string
ElapsedTimeRoundingFactor time.Duration
BarFiller string
ShowElapsedTime bool
ShowCount bool
ShowTitle bool
ShowPercentage bool
TitleStyle Style
BarStyle Style
IsActive bool
// contains filtered or unexported fields
}
Progressbar shows a progress animation in the terminal.
func (*Progressbar) Add ¶ added in v0.2.1
func (p *Progressbar) Add(count int) *Progressbar
Add to current value.
func (*Progressbar) GetElapsedTime ¶ added in v0.2.1
func (p *Progressbar) GetElapsedTime() time.Duration
GetElapsedTime returns the elapsed time, since the progressbar was started.
func (*Progressbar) Increment ¶ added in v0.2.1
func (p *Progressbar) Increment() *Progressbar
Increment current value by one.
func (Progressbar) Start ¶ added in v0.2.1
func (p Progressbar) Start() *Progressbar
Start the progressbar.
func (*Progressbar) Stop ¶ added in v0.2.1
func (p *Progressbar) Stop() *Progressbar
Stop the progressbar.
func (Progressbar) WithBarStyle ¶ added in v0.3.0
func (p Progressbar) WithBarStyle(style Style) *Progressbar
WithBarStyle sets the style of the bar.
func (Progressbar) WithCurrent ¶ added in v0.3.0
func (p Progressbar) WithCurrent(current int) *Progressbar
WithCurrent sets the current value of the progressbar.
func (Progressbar) WithElapsedTimeRoundingFactor ¶ added in v0.3.0
func (p Progressbar) WithElapsedTimeRoundingFactor(duration time.Duration) *Progressbar
WithElapsedTimeRoundingFactor sets the rounding factor of the elapsed time.
func (Progressbar) WithLastCharacter ¶ added in v0.3.0
func (p Progressbar) WithLastCharacter(char string) *Progressbar
WithLastCharacter sets the last character of the progressbar.
func (Progressbar) WithLineCharacter ¶ added in v0.3.0
func (p Progressbar) WithLineCharacter(char string) *Progressbar
WithLineCharacter sets the line character of the progressbar.
func (Progressbar) WithShowCount ¶ added in v0.3.0
func (p Progressbar) WithShowCount(b ...bool) *Progressbar
WithShowCount sets if the total and current count should be displayed in the progressbar.
func (Progressbar) WithShowElapsedTime ¶ added in v0.3.0
func (p Progressbar) WithShowElapsedTime(b ...bool) *Progressbar
WithShowElapsedTime sets if the elapsed time should be displayed in the progressbar.
func (Progressbar) WithShowPercentage ¶ added in v0.3.0
func (p Progressbar) WithShowPercentage(b ...bool) *Progressbar
WithShowPercentage sets if the completed percentage should be displayed in the progressbar.
func (Progressbar) WithShowTitle ¶ added in v0.3.0
func (p Progressbar) WithShowTitle(b ...bool) *Progressbar
WithShowTitle sets if the title should be displayed in the progressbar.
func (Progressbar) WithTitle ¶ added in v0.3.0
func (p Progressbar) WithTitle(name string) *Progressbar
WithTitle sets the name of the progressbar.
func (Progressbar) WithTitleStyle ¶ added in v0.3.0
func (p Progressbar) WithTitleStyle(style Style) *Progressbar
WithTitleStyle sets the style of the title.
func (Progressbar) WithTotal ¶ added in v0.3.0
func (p Progressbar) WithTotal(total int) *Progressbar
WithTotal sets the total value of the progressbar.
func (Progressbar) WithUpdateDelay ¶ added in v0.3.0
func (p Progressbar) WithUpdateDelay(delay time.Duration) *Progressbar
WithUpdateDelay sets the update delay of the progressbar.
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
SectionPrinter can print errors of the default Error type.
func (SectionPrinter) Print ¶ added in v0.3.2
func (p SectionPrinter) Print(a ...interface{}) GenericPrinter
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) Printf ¶ added in v0.3.2
func (p SectionPrinter) Printf(format string, a ...interface{}) GenericPrinter
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) Println ¶ added in v0.3.2
func (p SectionPrinter) Println(a ...interface{}) GenericPrinter
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) 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) 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(level int) *SectionPrinter
WithTopPadding returns a new SectionPrinter with a specific top padding.
type Spinner ¶ added in v0.1.0
type Spinner struct {
Text string
Sequence []string
Style Style
Delay time.Duration
MessageStyle Style
SuccessPrinter GenericPrinter
FailPrinter GenericPrinter
WarningPrinter GenericPrinter
RemoveWhenDone bool
IsActive bool
}
Spinner 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 GenericPrinter is used to display all outputs, after the spinner is done.
func (*Spinner) Fail ¶ added in v0.1.0
func (s *Spinner) Fail(message ...interface{})
Fail displays the fail printer. If no message is given, the text of the spinner will be reused as the default message.
func (*Spinner) Stop ¶ added in v0.1.0
func (s *Spinner) Stop()
Stop terminates the Spinner immediately. The Spinner will not resolve into anything.
func (*Spinner) Success ¶ added in v0.1.0
func (s *Spinner) Success(message ...interface{})
Success displays the success printer. If no message is given, the text of the spinner will be reused as the default message.
func (*Spinner) UpdateText ¶ added in v0.2.0
UpdateText updates the message of the active spinner. Can be used live.
func (*Spinner) Warning ¶ added in v0.1.0
func (s *Spinner) Warning(message ...interface{})
Warning displays the warning printer. If no message is given, the text of the spinner will be reused as the default message.
func (Spinner) WithMessageStyle ¶ added in v0.1.0
WithMessageStyle adds a style to the spinner message.
func (Spinner) WithRemoveWhenDone ¶ added in v0.3.0
WithRemoveWhenDone removes the spinner after it is done.
func (Spinner) WithSequence ¶ added in v0.1.0
WithSequence adds a sequence to the spinner.
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) 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) 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.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
_examples
|
|
|
demo
command
|
|
|
header
command
|
|
|
header-custom
command
|
|
|
override-default-printer
command
|
|
|
print-with-color
command
|
|
|
progressbar
command
|
|
|
section
command
|
|
|
spinner
command
|
|