Documentation ¶
Overview ¶
Package spinner is a simple package to add a spinner / progress indicator to any terminal application.
Index ¶
- Constants
- Variables
- func GenerateNumberSequence(length int) []string
- type ActualSpinner
- func (s *ActualSpinner) Active() bool
- func (s *ActualSpinner) Color(colors ...string) error
- func (s *ActualSpinner) HideAndExecute(f func())
- func (s *ActualSpinner) Lock()
- func (s *ActualSpinner) Pause()
- func (s *ActualSpinner) Repaint()
- func (s *ActualSpinner) Restart()
- func (s *ActualSpinner) Reverse()
- func (s *ActualSpinner) Start()
- func (s *ActualSpinner) Stop()
- func (s *ActualSpinner) Unlock()
- func (s *ActualSpinner) UpdateCharSet(cs []string)
- func (s *ActualSpinner) UpdateSpeed(d time.Duration)
- type CISpinner
- func (s *CISpinner) Active() bool
- func (s *CISpinner) CurrentHeading() string
- func (s *CISpinner) Error(message string)
- func (s *CISpinner) HideAndExecute(f func())
- func (s *CISpinner) NewStep(message string)
- func (s *CISpinner) SetMessage(message string)
- func (s *CISpinner) Skip()
- func (s *CISpinner) StampShadow()
- func (s *CISpinner) Start()
- func (s *CISpinner) Stop()
- func (s *CISpinner) Success(message string)
- type GitlabSpinner
- func (s *GitlabSpinner) Active() bool
- func (s *GitlabSpinner) CurrentHeading() string
- func (s *GitlabSpinner) Error(message string)
- func (s *GitlabSpinner) HideAndExecute(f func())
- func (s *GitlabSpinner) NewStep(message string)
- func (s *GitlabSpinner) SetMessage(message string)
- func (s *GitlabSpinner) Skip()
- func (s *GitlabSpinner) StampShadow()
- func (s *GitlabSpinner) Start()
- func (s *GitlabSpinner) Stop()
- func (s *GitlabSpinner) Success(message string)
- type NullSpinner
- func (s *NullSpinner) Active() bool
- func (s *NullSpinner) CurrentHeading() string
- func (s *NullSpinner) Error(message string)
- func (s *NullSpinner) HideAndExecute(f func())
- func (s *NullSpinner) NewStep(message string)
- func (s *NullSpinner) SetMessage(message string)
- func (s *NullSpinner) Skip()
- func (s *NullSpinner) StampShadow()
- func (s *NullSpinner) Start()
- func (s *NullSpinner) Stop()
- func (s *NullSpinner) Success(message string)
- type Option
- type Options
- type StdoutSpinner
- func (s *StdoutSpinner) Active() bool
- func (s *StdoutSpinner) CurrentHeading() string
- func (s *StdoutSpinner) Error(message string)
- func (s *StdoutSpinner) HideAndExecute(f func())
- func (s *StdoutSpinner) NewStep(message string)
- func (s *StdoutSpinner) SetMessage(message string)
- func (s *StdoutSpinner) Skip()
- func (s *StdoutSpinner) Spin()
- func (s *StdoutSpinner) StampShadow()
- func (s *StdoutSpinner) Start()
- func (s *StdoutSpinner) Stop()
- func (s *StdoutSpinner) Success(message string)
- type SubenvSpinner
- func (s *SubenvSpinner) Active() bool
- func (s *SubenvSpinner) CurrentHeading() string
- func (s *SubenvSpinner) Error(message string)
- func (s *SubenvSpinner) HideAndExecute(f func())
- func (s *SubenvSpinner) NewStep(message string)
- func (s *SubenvSpinner) SetMessage(message string)
- func (s *SubenvSpinner) Skip()
- func (s *SubenvSpinner) StampShadow()
- func (s *SubenvSpinner) Start()
- func (s *SubenvSpinner) Stop()
- func (s *SubenvSpinner) SubEnv(message string) string
- func (s *SubenvSpinner) Success(message string)
Constants ¶
const ( TICK = "✔" CROSS = "✖" SKIP = "⋯" DASH = "-" )
Variables ¶
var CharSets = map[int][]string{
0: {"←", "↖", "↑", "↗", "→", "↘", "↓", "↙"},
1: {"▁", "▃", "▄", "▅", "▆", "▇", "█", "▇", "▆", "▅", "▄", "▃", "▁"},
2: {"▖", "▘", "▝", "▗"},
3: {"┤", "┘", "┴", "└", "├", "┌", "┬", "┐"},
4: {"◢", "◣", "◤", "◥"},
5: {"◰", "◳", "◲", "◱"},
6: {"◴", "◷", "◶", "◵"},
7: {"◐", "◓", "◑", "◒"},
8: {".", "o", "O", "@", "*"},
9: {"|", "/", "-", "\\"},
10: {"◡◡", "⊙⊙", "◠◠"},
11: {"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"},
12: {">))'>", " >))'>", " >))'>", " >))'>", " >))'>", " <'((<", " <'((<", " <'((<"},
13: {"⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈"},
14: {"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"},
15: {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"},
16: {"▉", "▊", "▋", "▌", "▍", "▎", "▏", "▎", "▍", "▌", "▋", "▊", "▉"},
17: {"■", "□", "▪", "▫"},
18: {"←", "↑", "→", "↓"},
19: {"╫", "╪"},
20: {"⇐", "⇖", "⇑", "⇗", "⇒", "⇘", "⇓", "⇙"},
21: {"⠁", "⠁", "⠉", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠤", "⠄", "⠄", "⠤", "⠠", "⠠", "⠤", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋", "⠉", "⠈", "⠈"},
22: {"⠈", "⠉", "⠋", "⠓", "⠒", "⠐", "⠐", "⠒", "⠖", "⠦", "⠤", "⠠", "⠠", "⠤", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋", "⠉", "⠈"},
23: {"⠁", "⠉", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠤", "⠄", "⠄", "⠤", "⠴", "⠲", "⠒", "⠂", "⠂", "⠒", "⠚", "⠙", "⠉", "⠁"},
24: {"⠋", "⠙", "⠚", "⠒", "⠂", "⠂", "⠒", "⠲", "⠴", "⠦", "⠖", "⠒", "⠐", "⠐", "⠒", "⠓", "⠋"},
25: {"ヲ", "ァ", "ィ", "ゥ", "ェ", "ォ", "ャ", "ュ", "ョ", "ッ", "ア", "イ", "ウ", "エ", "オ", "カ", "キ", "ク", "ケ", "コ", "サ", "シ", "ス", "セ", "ソ", "タ", "チ", "ツ", "テ", "ト", "ナ", "ニ", "ヌ", "ネ", "ノ", "ハ", "ヒ", "フ", "ヘ", "ホ", "マ", "ミ", "ム", "メ", "モ", "ヤ", "ユ", "ヨ", "ラ", "リ", "ル", "レ", "ロ", "ワ", "ン"},
26: {".", "..", "..."},
27: {"▁", "▂", "▃", "▄", "▅", "▆", "▇", "█", "▉", "▊", "▋", "▌", "▍", "▎", "▏", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█", "▇", "▆", "▅", "▄", "▃", "▂", "▁"},
28: {".", "o", "O", "°", "O", "o", "."},
29: {"+", "x"},
30: {"v", "<", "^", ">"},
31: {">>--->", " >>--->", " >>--->", " >>--->", " >>--->", " <---<<", " <---<<", " <---<<", " <---<<", "<---<<"},
32: {"|", "||", "|||", "||||", "|||||", "|||||||", "||||||||", "|||||||", "||||||", "|||||", "||||", "|||", "||", "|"},
33: {"[ ]", "[= ]", "[== ]", "[=== ]", "[==== ]", "[===== ]", "[====== ]", "[======= ]", "[======== ]", "[========= ]", "[==========]"},
34: {"(*---------)", "(-*--------)", "(--*-------)", "(---*------)", "(----*-----)", "(-----*----)", "(------*---)", "(-------*--)", "(--------*-)", "(---------*)"},
35: {"█▒▒▒▒▒▒▒▒▒", "███▒▒▒▒▒▒▒", "█████▒▒▒▒▒", "███████▒▒▒", "██████████"},
36: {"[ ]", "[=> ]", "[===> ]", "[=====> ]", "[======> ]", "[========> ]", "[==========> ]", "[============> ]", "[==============> ]", "[================> ]", "[==================> ]", "[===================>]"},
39: {"🌍", "🌎", "🌏"},
40: {"◜", "◝", "◞", "◟"},
41: {"⬒", "⬔", "⬓", "⬕"},
42: {"⬖", "⬘", "⬗", "⬙"},
43: {"[>>> >]", "[]>>>> []", "[] >>>> []", "[] >>>> []", "[] >>>> []", "[] >>>>[]", "[>> >>]"},
44: {"♠", "♣", "♥", "♦"},
45: {"➞", "➟", "➠", "➡", "➠", "➟"},
46: {" | ", ` \ `, "_ ", ` \ `, " | ", " / ", " _", " / "},
47: {" . . . .", ". . . .", ". . . .", ". . . .", ". . . . ", ". . . . ."},
48: {" | ", " / ", " _ ", ` \ `, " | ", ` \ `, " _ ", " / "},
49: {"⎺", "⎻", "⎼", "⎽", "⎼", "⎻"},
50: {"▹▹▹▹▹", "▸▹▹▹▹", "▹▸▹▹▹", "▹▹▸▹▹", "▹▹▹▸▹", "▹▹▹▹▸"},
51: {"[ ]", "[ =]", "[ ==]", "[ ===]", "[====]", "[=== ]", "[== ]", "[= ]"},
52: {"( ● )", "( ● )", "( ● )", "( ● )", "( ●)", "( ● )", "( ● )", "( ● )", "( ● )"},
53: {"✶", "✸", "✹", "✺", "✹", "✷"},
54: {"▐|\\____________▌", "▐_|\\___________▌", "▐__|\\__________▌", "▐___|\\_________▌", "▐____|\\________▌", "▐_____|\\_______▌", "▐______|\\______▌", "▐_______|\\_____▌", "▐________|\\____▌", "▐_________|\\___▌", "▐__________|\\__▌", "▐___________|\\_▌", "▐____________|\\▌", "▐____________/|▌", "▐___________/|_▌", "▐__________/|__▌", "▐_________/|___▌", "▐________/|____▌", "▐_______/|_____▌", "▐______/|______▌", "▐_____/|_______▌", "▐____/|________▌", "▐___/|_________▌", "▐__/|__________▌", "▐_/|___________▌", "▐/|____________▌"},
55: {"▐⠂ ▌", "▐⠈ ▌", "▐ ⠂ ▌", "▐ ⠠ ▌", "▐ ⡀ ▌", "▐ ⠠ ▌", "▐ ⠂ ▌", "▐ ⠈ ▌", "▐ ⠂ ▌", "▐ ⠠ ▌", "▐ ⡀ ▌", "▐ ⠠ ▌", "▐ ⠂ ▌", "▐ ⠈ ▌", "▐ ⠂▌", "▐ ⠠▌", "▐ ⡀▌", "▐ ⠠ ▌", "▐ ⠂ ▌", "▐ ⠈ ▌", "▐ ⠂ ▌", "▐ ⠠ ▌", "▐ ⡀ ▌", "▐ ⠠ ▌", "▐ ⠂ ▌", "▐ ⠈ ▌", "▐ ⠂ ▌", "▐ ⠠ ▌", "▐ ⡀ ▌", "▐⠠ ▌"},
56: {"¿", "?"},
57: {"⢹", "⢺", "⢼", "⣸", "⣇", "⡧", "⡗", "⡏"},
58: {"⢄", "⢂", "⢁", "⡁", "⡈", "⡐", "⡠"},
59: {". ", ".. ", "...", " ..", " .", " "},
60: {".", "o", "O", "°", "O", "o", "."},
61: {"▓", "▒", "░"},
62: {"▌", "▀", "▐", "▄"},
63: {"⊶", "⊷"},
64: {"▪", "▫"},
65: {"□", "■"},
66: {"▮", "▯"},
67: {"-", "=", "≡"},
68: {"d", "q", "p", "b"},
69: {"∙∙∙", "●∙∙", "∙●∙", "∙∙●", "∙∙∙"},
70: {"🌑 ", "🌒 ", "🌓 ", "🌔 ", "🌕 ", "🌖 ", "🌗 ", "🌘 "},
71: {"☗", "☖"},
72: {"⧇", "⧆"},
73: {"◉", "◎"},
74: {"㊂", "㊀", "㊁"},
75: {"⦾", "⦿"},
76: {"ဝ", "၀"},
77: {"▌", "▀", "▐▄"},
}
CharSets contains the available character sets
Functions ¶
func GenerateNumberSequence ¶
GenerateNumberSequence will generate a slice of integers at the provided length and convert them each to a string.
Types ¶
type ActualSpinner ¶
type ActualSpinner struct { Delay time.Duration // Delay is the speed of the indicator Prefix string // Prefix is the text preppended to the indicator Suffix string // Suffix is the text appended to the indicator FinalMSG string // string displayed after Stop() is called Writer io.Writer // to make testing better, exported so users have access. Use `WithWriter` to update after initialization. HideCursor bool // hideCursor determines if the cursor is visible PreUpdate func(s *ActualSpinner) // will be triggered before every spinner update PostUpdate func(s *ActualSpinner) // will be triggered after every spinner update // contains filtered or unexported fields }
ActualSpinner struct to hold the provided options.
func NewActualSpinner ¶
func NewActualSpinner(cs []string, d time.Duration, options ...Option) *ActualSpinner
New provides a pointer to an instance of ActualSpinner with the supplied options.
func (*ActualSpinner) Active ¶
func (s *ActualSpinner) Active() bool
Active will return whether or not the spinner is currently active.
func (*ActualSpinner) Color ¶
func (s *ActualSpinner) Color(colors ...string) error
Color will set the struct field for the given color to be used.
func (*ActualSpinner) HideAndExecute ¶
func (s *ActualSpinner) HideAndExecute(f func())
func (*ActualSpinner) Lock ¶
func (s *ActualSpinner) Lock()
Lock allows for manual control to lock the spinner.
func (*ActualSpinner) Pause ¶
func (s *ActualSpinner) Pause()
func (*ActualSpinner) Repaint ¶
func (s *ActualSpinner) Repaint()
func (*ActualSpinner) Restart ¶
func (s *ActualSpinner) Restart()
Restart will stop and start the indicator.
func (*ActualSpinner) Reverse ¶
func (s *ActualSpinner) Reverse()
Reverse will reverse the order of the slice assigned to the indicator.
func (*ActualSpinner) Unlock ¶
func (s *ActualSpinner) Unlock()
Unlock allows for manual control to unlock the spinner.
func (*ActualSpinner) UpdateCharSet ¶
func (s *ActualSpinner) UpdateCharSet(cs []string)
UpdateCharSet will change the current character set to the given one.
func (*ActualSpinner) UpdateSpeed ¶
func (s *ActualSpinner) UpdateSpeed(d time.Duration)
UpdateSpeed will set the indicator delay to the given value.
type CISpinner ¶
type CISpinner struct {
// contains filtered or unexported fields
}
func (*CISpinner) CurrentHeading ¶
func (*CISpinner) HideAndExecute ¶
func (s *CISpinner) HideAndExecute(f func())
func (*CISpinner) SetMessage ¶
func (*CISpinner) StampShadow ¶
func (s *CISpinner) StampShadow()
type GitlabSpinner ¶
type GitlabSpinner struct {
// contains filtered or unexported fields
}
func NewGitlabSpinner ¶
func NewGitlabSpinner(out io.Writer, colors aurora.Aurora) *GitlabSpinner
func (*GitlabSpinner) Active ¶
func (s *GitlabSpinner) Active() bool
func (*GitlabSpinner) CurrentHeading ¶
func (s *GitlabSpinner) CurrentHeading() string
func (*GitlabSpinner) Error ¶
func (s *GitlabSpinner) Error(message string)
func (*GitlabSpinner) HideAndExecute ¶
func (s *GitlabSpinner) HideAndExecute(f func())
func (*GitlabSpinner) NewStep ¶
func (s *GitlabSpinner) NewStep(message string)
func (*GitlabSpinner) SetMessage ¶
func (s *GitlabSpinner) SetMessage(message string)
func (*GitlabSpinner) Skip ¶
func (s *GitlabSpinner) Skip()
func (*GitlabSpinner) StampShadow ¶
func (s *GitlabSpinner) StampShadow()
func (*GitlabSpinner) Start ¶
func (s *GitlabSpinner) Start()
func (*GitlabSpinner) Stop ¶
func (s *GitlabSpinner) Stop()
func (*GitlabSpinner) Success ¶
func (s *GitlabSpinner) Success(message string)
type NullSpinner ¶
type NullSpinner struct {
// contains filtered or unexported fields
}
func NewNullSpinner ¶
func NewNullSpinner() *NullSpinner
func (*NullSpinner) Active ¶
func (s *NullSpinner) Active() bool
func (*NullSpinner) CurrentHeading ¶
func (s *NullSpinner) CurrentHeading() string
func (*NullSpinner) Error ¶
func (s *NullSpinner) Error(message string)
func (*NullSpinner) HideAndExecute ¶
func (s *NullSpinner) HideAndExecute(f func())
func (*NullSpinner) NewStep ¶
func (s *NullSpinner) NewStep(message string)
func (*NullSpinner) SetMessage ¶
func (s *NullSpinner) SetMessage(message string)
func (*NullSpinner) Skip ¶
func (s *NullSpinner) Skip()
func (*NullSpinner) StampShadow ¶
func (s *NullSpinner) StampShadow()
func (*NullSpinner) Start ¶
func (s *NullSpinner) Start()
func (*NullSpinner) Stop ¶
func (s *NullSpinner) Stop()
func (*NullSpinner) Success ¶
func (s *NullSpinner) Success(message string)
type Option ¶
type Option func(*ActualSpinner)
Option is a function that takes a spinner and applies a given configuration.
func WithFinalMSG ¶
WithFinalMSG adds the given string ot the spinner as the final message to be written.
func WithHiddenCursor ¶
WithHiddenCursor hides the cursor if hideCursor = true given.
func WithSuffix ¶
WithSuffix adds the given string to the spinner as the suffix.
func WithWriter ¶
WithWriter adds the given writer to the spinner. This function should be favored over directly assigning to the struct value.
type StdoutSpinner ¶
type StdoutSpinner struct {
// contains filtered or unexported fields
}
func NewStdoutSpinner ¶
func (*StdoutSpinner) Active ¶
func (s *StdoutSpinner) Active() bool
func (*StdoutSpinner) CurrentHeading ¶
func (s *StdoutSpinner) CurrentHeading() string
func (*StdoutSpinner) Error ¶
func (s *StdoutSpinner) Error(message string)
func (*StdoutSpinner) HideAndExecute ¶
func (s *StdoutSpinner) HideAndExecute(f func())
func (*StdoutSpinner) NewStep ¶
func (s *StdoutSpinner) NewStep(message string)
func (*StdoutSpinner) SetMessage ¶
func (s *StdoutSpinner) SetMessage(message string)
func (*StdoutSpinner) Skip ¶
func (s *StdoutSpinner) Skip()
func (*StdoutSpinner) Spin ¶
func (s *StdoutSpinner) Spin()
func (*StdoutSpinner) StampShadow ¶
func (s *StdoutSpinner) StampShadow()
func (*StdoutSpinner) Start ¶
func (s *StdoutSpinner) Start()
func (*StdoutSpinner) Stop ¶
func (s *StdoutSpinner) Stop()
func (*StdoutSpinner) Success ¶
func (s *StdoutSpinner) Success(message string)
type SubenvSpinner ¶
type SubenvSpinner struct {
// contains filtered or unexported fields
}
func NewSubenvSpinner ¶
func NewSubenvSpinner(env map[string]string, spinner wrappableSpinner) *SubenvSpinner
func (*SubenvSpinner) Active ¶
func (s *SubenvSpinner) Active() bool
func (*SubenvSpinner) CurrentHeading ¶
func (s *SubenvSpinner) CurrentHeading() string
func (*SubenvSpinner) Error ¶
func (s *SubenvSpinner) Error(message string)
func (*SubenvSpinner) HideAndExecute ¶
func (s *SubenvSpinner) HideAndExecute(f func())
func (*SubenvSpinner) NewStep ¶
func (s *SubenvSpinner) NewStep(message string)
func (*SubenvSpinner) SetMessage ¶
func (s *SubenvSpinner) SetMessage(message string)
func (*SubenvSpinner) Skip ¶
func (s *SubenvSpinner) Skip()
func (*SubenvSpinner) StampShadow ¶
func (s *SubenvSpinner) StampShadow()
func (*SubenvSpinner) Start ¶
func (s *SubenvSpinner) Start()
func (*SubenvSpinner) Stop ¶
func (s *SubenvSpinner) Stop()
func (*SubenvSpinner) SubEnv ¶
func (s *SubenvSpinner) SubEnv(message string) string
func (*SubenvSpinner) Success ¶
func (s *SubenvSpinner) Success(message string)