mirror of
https://github.com/mudler/luet.git
synced 2025-09-06 01:30:29 +00:00
Update vendor
This commit is contained in:
7
vendor/github.com/briandowns/spinner/.travis.yml
generated
vendored
7
vendor/github.com/briandowns/spinner/.travis.yml
generated
vendored
@@ -1,7 +1,10 @@
|
|||||||
|
arch:
|
||||||
|
- amd64
|
||||||
|
- ppc64le
|
||||||
language: go
|
language: go
|
||||||
go:
|
go:
|
||||||
- 1.11
|
- 1.13
|
||||||
- 1.12.5
|
- 1.14.1
|
||||||
env:
|
env:
|
||||||
- GOARCH: amd64
|
- GOARCH: amd64
|
||||||
- GOARCH: 386
|
- GOARCH: 386
|
||||||
|
101
vendor/github.com/briandowns/spinner/README.md
generated
vendored
101
vendor/github.com/briandowns/spinner/README.md
generated
vendored
@@ -17,52 +17,52 @@ go get github.com/briandowns/spinner
|
|||||||
## Available Character Sets
|
## Available Character Sets
|
||||||
(Numbered by their slice index)
|
(Numbered by their slice index)
|
||||||
|
|
||||||
index | character set | sample gif
|
| index | character set | sample gif |
|
||||||
------|---------------|---------------
|
| ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
|
||||||
0 | ```←↖↑↗→↘↓↙``` | 
|
| 0 | ```←↖↑↗→↘↓↙``` |  |
|
||||||
1 | ```▁▃▄▅▆▇█▇▆▅▄▃▁``` | 
|
| 1 | ```▁▃▄▅▆▇█▇▆▅▄▃▁``` |  |
|
||||||
2 | ```▖▘▝▗``` | 
|
| 2 | ```▖▘▝▗``` |  |
|
||||||
3 | ```┤┘┴└├┌┬┐``` | 
|
| 3 | ```┤┘┴└├┌┬┐``` |  |
|
||||||
4 | ```◢◣◤◥``` | 
|
| 4 | ```◢◣◤◥``` |  |
|
||||||
5 | ```◰◳◲◱``` | 
|
| 5 | ```◰◳◲◱``` |  |
|
||||||
6 | ```◴◷◶◵``` | 
|
| 6 | ```◴◷◶◵``` |  |
|
||||||
7 | ```◐◓◑◒``` | 
|
| 7 | ```◐◓◑◒``` |  |
|
||||||
8 | ```.oO@*``` | 
|
| 8 | ```.oO@*``` |  |
|
||||||
9 | ```|/-\``` | 
|
| 9 | ```\|/-\``` |  |
|
||||||
10 | ```◡◡⊙⊙◠◠``` | 
|
| 10 | ```◡◡⊙⊙◠◠``` |  |
|
||||||
11 | ```⣾⣽⣻⢿⡿⣟⣯⣷``` | 
|
| 11 | ```⣾⣽⣻⢿⡿⣟⣯⣷``` |  |
|
||||||
12 | ```>))'> >))'> >))'> >))'> >))'> <'((< <'((< <'((<``` | 
|
| 12 | ```>))'> >))'> >))'> >))'> >))'> <'((< <'((< <'((<``` |  |
|
||||||
13 | ```⠁⠂⠄⡀⢀⠠⠐⠈``` | 
|
| 13 | ```⠁⠂⠄⡀⢀⠠⠐⠈``` |  |
|
||||||
14 | ```⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏``` | 
|
| 14 | ```⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏``` |  |
|
||||||
15 | ```abcdefghijklmnopqrstuvwxyz``` | 
|
| 15 | ```abcdefghijklmnopqrstuvwxyz``` |  |
|
||||||
16 | ```▉▊▋▌▍▎▏▎▍▌▋▊▉``` | 
|
| 16 | ```▉▊▋▌▍▎▏▎▍▌▋▊▉``` |  |
|
||||||
17 | ```■□▪▫``` | 
|
| 17 | ```■□▪▫``` |  |
|
||||||
18 | ```←↑→↓``` | 
|
| 18 | ```←↑→↓``` |  |
|
||||||
19 | ```╫╪``` | 
|
| 19 | ```╫╪``` |  |
|
||||||
20 | ```⇐⇖⇑⇗⇒⇘⇓⇙``` | 
|
| 20 | ```⇐⇖⇑⇗⇒⇘⇓⇙``` |  |
|
||||||
21 | ```⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈``` | 
|
| 21 | ```⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈``` |  |
|
||||||
22 | ```⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈``` | 
|
| 22 | ```⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈``` |  |
|
||||||
23 | ```⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁``` | 
|
| 23 | ```⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁``` |  |
|
||||||
24 | ```⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋``` | 
|
| 24 | ```⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋``` |  |
|
||||||
25 | ```ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン``` | 
|
| 25 | ```ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン``` |  |
|
||||||
26 | ```. .. ...``` | 
|
| 26 | ```. .. ...``` |  |
|
||||||
27 | ```▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▏▎▍▌▋▊▉█▇▆▅▄▃▂▁``` | 
|
| 27 | ```▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▏▎▍▌▋▊▉█▇▆▅▄▃▂▁``` |  |
|
||||||
28 | ```.oO°Oo.``` | 
|
| 28 | ```.oO°Oo.``` |  |
|
||||||
29 | ```+x``` | 
|
| 29 | ```+x``` |  |
|
||||||
30 | ```v<^>``` | 
|
| 30 | ```v<^>``` |  |
|
||||||
31 | ```>>---> >>---> >>---> >>---> >>---> <---<< <---<< <---<< <---<< <---<<``` | 
|
| 31 | ```>>---> >>---> >>---> >>---> >>---> <---<< <---<< <---<< <---<< <---<<``` |  |
|
||||||
32 | ```| || ||| |||| ||||| |||||| ||||| |||| ||| || |``` | 
|
| 32 | ```\| \|\| \|\|\| \|\|\|\| \|\|\|\|\| \|\|\|\|\|\| \|\|\|\|\| \|\|\|\| \|\|\| \|\| \|``` |  |
|
||||||
33 | ```[] [=] [==] [===] [====] [=====] [======] [=======] [========] [=========] [==========]``` | 
|
| 33 | ```[] [=] [==] [===] [====] [=====] [======] [=======] [========] [=========] [==========]``` |  |
|
||||||
34 | ```(*---------) (-*--------) (--*-------) (---*------) (----*-----) (-----*----) (------*---) (-------*--) (--------*-) (---------*)``` | 
|
| 34 | ```(*---------) (-*--------) (--*-------) (---*------) (----*-----) (-----*----) (------*---) (-------*--) (--------*-) (---------*)``` |  |
|
||||||
35 | ```█▒▒▒▒▒▒▒▒▒ ███▒▒▒▒▒▒▒ █████▒▒▒▒▒ ███████▒▒▒ ██████████``` | 
|
| 35 | ```█▒▒▒▒▒▒▒▒▒ ███▒▒▒▒▒▒▒ █████▒▒▒▒▒ ███████▒▒▒ ██████████``` |  |
|
||||||
36 | ```[ ] [=> ] [===> ] [=====> ] [======> ] [========> ] [==========> ] [============> ] [==============> ] [================> ] [==================> ] [===================>]``` | 
|
| 36 | ```[ ] [=> ] [===> ] [=====> ] [======> ] [========> ] [==========> ] [============> ] [==============> ] [================> ] [==================> ] [===================>]``` |  |
|
||||||
37 | ```🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘 🕙 🕚 🕛``` | 
|
| 37 | ```🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘 🕙 🕚 🕛``` |  |
|
||||||
38 | ```🕐 🕜 🕑 🕝 🕒 🕞 🕓 🕟 🕔 🕠 🕕 🕡 🕖 🕢 🕗 🕣 🕘 🕤 🕙 🕥 🕚 🕦 🕛 🕧``` | 
|
| 38 | ```🕐 🕜 🕑 🕝 🕒 🕞 🕓 🕟 🕔 🕠 🕕 🕡 🕖 🕢 🕗 🕣 🕘 🕤 🕙 🕥 🕚 🕦 🕛 🕧``` |  |
|
||||||
39 | ```🌍 🌎 🌏``` | 
|
| 39 | ```🌍 🌎 🌏``` |  |
|
||||||
40 | ```◜ ◝ ◞ ◟``` | 
|
| 40 | ```◜ ◝ ◞ ◟``` |  |
|
||||||
41 | ```⬒ ⬔ ⬓ ⬕``` | 
|
| 41 | ```⬒ ⬔ ⬓ ⬕``` |  |
|
||||||
42 | ```⬖ ⬘ ⬗ ⬙``` | 
|
| 42 | ```⬖ ⬘ ⬗ ⬙``` |  |
|
||||||
43 | ```[>>> >] []>>>> [] [] >>>> [] [] >>>> [] [] >>>> [] [] >>>>[] [>> >>]``` | 
|
| 43 | ```[>>> >] []>>>> [] [] >>>> [] [] >>>> [] [] >>>> [] [] >>>>[] [>> >>]``` |  |
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ s.Prefix = "prefixed text: " // Prefix text before the spinner
|
|||||||
s.Suffix = " :appended text" // Append text after the spinner
|
s.Suffix = " :appended text" // Append text after the spinner
|
||||||
```
|
```
|
||||||
|
|
||||||
## Set or change the color of the spinner. Default color is white. This will restart the spinner with the new color.
|
## Set or change the color of the spinner. Default color is white. The spinner will need to be restarted to pick up the change.
|
||||||
|
|
||||||
```Go
|
```Go
|
||||||
s.Color("red") // Set the spinner color to red
|
s.Color("red") // Set the spinner color to red
|
||||||
@@ -240,12 +240,13 @@ fmt.Println(s.Active())
|
|||||||
|
|
||||||
Feature suggested and write up by [dekz](https://github.com/dekz)
|
Feature suggested and write up by [dekz](https://github.com/dekz)
|
||||||
|
|
||||||
Setting the Spinner Writer to Stderr helps show progress to the user, with the enhancement to chain, pipe or redirect the output.
|
Setting the Spinner Writer to Stderr helps show progress to the user, with the enhancement to chain, pipe or redirect the output.
|
||||||
|
|
||||||
|
This is the preferred method of setting a Writer at this time.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
s := spinner.New(spinner.CharSets[11], 100*time.Millisecond)
|
s := spinner.New(spinner.CharSets[11], 100*time.Millisecond, spinner.WithWriter(os.Stderr))
|
||||||
s.Suffix = " Encrypting data..."
|
s.Suffix = " Encrypting data..."
|
||||||
s.Writer = os.Stderr
|
|
||||||
s.Start()
|
s.Start()
|
||||||
// Encrypt the data into ciphertext
|
// Encrypt the data into ciphertext
|
||||||
fmt.Println(os.Stdout, ciphertext)
|
fmt.Println(os.Stdout, ciphertext)
|
||||||
|
2
vendor/github.com/briandowns/spinner/go.mod
generated
vendored
2
vendor/github.com/briandowns/spinner/go.mod
generated
vendored
@@ -1,5 +1,7 @@
|
|||||||
module github.com/briandowns/spinner
|
module github.com/briandowns/spinner
|
||||||
|
|
||||||
|
go 1.14
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/fatih/color v1.7.0
|
github.com/fatih/color v1.7.0
|
||||||
github.com/mattn/go-colorable v0.1.2 // indirect
|
github.com/mattn/go-colorable v0.1.2 // indirect
|
||||||
|
139
vendor/github.com/briandowns/spinner/spinner.go
generated
vendored
139
vendor/github.com/briandowns/spinner/spinner.go
generated
vendored
@@ -14,13 +14,13 @@
|
|||||||
package spinner
|
package spinner
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
@@ -161,7 +161,7 @@ var colorAttributeMap = map[string]color.Attribute{
|
|||||||
"bgHiWhite": color.BgHiWhite,
|
"bgHiWhite": color.BgHiWhite,
|
||||||
}
|
}
|
||||||
|
|
||||||
// validColor will make sure the given color is actually allowed
|
// validColor will make sure the given color is actually allowed.
|
||||||
func validColor(c string) bool {
|
func validColor(c string) bool {
|
||||||
if validColors[c] {
|
if validColors[c] {
|
||||||
return true
|
return true
|
||||||
@@ -169,8 +169,9 @@ func validColor(c string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spinner struct to hold the provided options
|
// Spinner struct to hold the provided options.
|
||||||
type Spinner struct {
|
type Spinner struct {
|
||||||
|
mu *sync.RWMutex //
|
||||||
Delay time.Duration // Delay is the speed of the indicator
|
Delay time.Duration // Delay is the speed of the indicator
|
||||||
chars []string // chars holds the chosen character set
|
chars []string // chars holds the chosen character set
|
||||||
Prefix string // Prefix is the text preppended to the indicator
|
Prefix string // Prefix is the text preppended to the indicator
|
||||||
@@ -178,20 +179,21 @@ type Spinner struct {
|
|||||||
FinalMSG string // string displayed after Stop() is called
|
FinalMSG string // string displayed after Stop() is called
|
||||||
lastOutput string // last character(set) written
|
lastOutput string // last character(set) written
|
||||||
color func(a ...interface{}) string // default color is white
|
color func(a ...interface{}) string // default color is white
|
||||||
lock *sync.RWMutex //
|
Writer io.Writer // to make testing better, exported so users have access. Use `WithWriter` to update after initialization.
|
||||||
Writer io.Writer // to make testing better, exported so users have access
|
|
||||||
active bool // active holds the state of the spinner
|
active bool // active holds the state of the spinner
|
||||||
stopChan chan struct{} // stopChan is a channel used to stop the indicator
|
stopChan chan struct{} // stopChan is a channel used to stop the indicator
|
||||||
HideCursor bool // hideCursor determines if the cursor is visible
|
HideCursor bool // hideCursor determines if the cursor is visible
|
||||||
|
PreUpdate func(s *Spinner) // will be triggered before every spinner update
|
||||||
|
PostUpdate func(s *Spinner) // will be triggered after every spinner update
|
||||||
}
|
}
|
||||||
|
|
||||||
// New provides a pointer to an instance of Spinner with the supplied options
|
// New provides a pointer to an instance of Spinner with the supplied options.
|
||||||
func New(cs []string, d time.Duration, options ...Option) *Spinner {
|
func New(cs []string, d time.Duration, options ...Option) *Spinner {
|
||||||
s := &Spinner{
|
s := &Spinner{
|
||||||
Delay: d,
|
Delay: d,
|
||||||
chars: cs,
|
chars: cs,
|
||||||
color: color.New(color.FgWhite).SprintFunc(),
|
color: color.New(color.FgWhite).SprintFunc(),
|
||||||
lock: &sync.RWMutex{},
|
mu: &sync.RWMutex{},
|
||||||
Writer: color.Output,
|
Writer: color.Output,
|
||||||
active: false,
|
active: false,
|
||||||
stopChan: make(chan struct{}, 1),
|
stopChan: make(chan struct{}, 1),
|
||||||
@@ -204,10 +206,10 @@ func New(cs []string, d time.Duration, options ...Option) *Spinner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Option is a function that takes a spinner and applies
|
// Option is a function that takes a spinner and applies
|
||||||
// a given configuration
|
// a given configuration.
|
||||||
type Option func(*Spinner)
|
type Option func(*Spinner)
|
||||||
|
|
||||||
// Options contains fields to configure the spinner
|
// Options contains fields to configure the spinner.
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Color string
|
Color string
|
||||||
Suffix string
|
Suffix string
|
||||||
@@ -215,7 +217,7 @@ type Options struct {
|
|||||||
HideCursor bool
|
HideCursor bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithColor adds the given color to the spinner
|
// WithColor adds the given color to the spinner.
|
||||||
func WithColor(color string) Option {
|
func WithColor(color string) Option {
|
||||||
return func(s *Spinner) {
|
return func(s *Spinner) {
|
||||||
s.Color(color)
|
s.Color(color)
|
||||||
@@ -223,7 +225,7 @@ func WithColor(color string) Option {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithSuffix adds the given string to the spinner
|
// WithSuffix adds the given string to the spinner
|
||||||
// as the suffix
|
// as the suffix.
|
||||||
func WithSuffix(suffix string) Option {
|
func WithSuffix(suffix string) Option {
|
||||||
return func(s *Spinner) {
|
return func(s *Spinner) {
|
||||||
s.Suffix = suffix
|
s.Suffix = suffix
|
||||||
@@ -231,7 +233,7 @@ func WithSuffix(suffix string) Option {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithFinalMSG adds the given string ot the spinner
|
// WithFinalMSG adds the given string ot the spinner
|
||||||
// as the final message to be written
|
// as the final message to be written.
|
||||||
func WithFinalMSG(finalMsg string) Option {
|
func WithFinalMSG(finalMsg string) Option {
|
||||||
return func(s *Spinner) {
|
return func(s *Spinner) {
|
||||||
s.FinalMSG = finalMsg
|
s.FinalMSG = finalMsg
|
||||||
@@ -239,31 +241,42 @@ func WithFinalMSG(finalMsg string) Option {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithHiddenCursor hides the cursor
|
// WithHiddenCursor hides the cursor
|
||||||
// if hideCursor = true given
|
// if hideCursor = true given.
|
||||||
func WithHiddenCursor(hideCursor bool) Option {
|
func WithHiddenCursor(hideCursor bool) Option {
|
||||||
return func(s *Spinner) {
|
return func(s *Spinner) {
|
||||||
s.HideCursor = hideCursor
|
s.HideCursor = hideCursor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Active will return whether or not the spinner is currently active
|
// WithWriter adds the given writer to the spinner. This
|
||||||
|
// function should be favored over directly assigning to
|
||||||
|
// the struct value.
|
||||||
|
func WithWriter(w io.Writer) Option {
|
||||||
|
return func(s *Spinner) {
|
||||||
|
s.mu.Lock()
|
||||||
|
s.Writer = w
|
||||||
|
s.mu.Unlock()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Active will return whether or not the spinner is currently active.
|
||||||
func (s *Spinner) Active() bool {
|
func (s *Spinner) Active() bool {
|
||||||
return s.active
|
return s.active
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start will start the indicator
|
// Start will start the indicator.
|
||||||
func (s *Spinner) Start() {
|
func (s *Spinner) Start() {
|
||||||
s.lock.Lock()
|
s.mu.Lock()
|
||||||
if s.active {
|
if s.active {
|
||||||
s.lock.Unlock()
|
s.mu.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if s.HideCursor && runtime.GOOS != "windows" {
|
if s.HideCursor && runtime.GOOS != "windows" {
|
||||||
// hides the cursor
|
// hides the cursor
|
||||||
fmt.Print("\033[?25l")
|
fmt.Fprint(s.Writer, "\033[?25l")
|
||||||
}
|
}
|
||||||
s.active = true
|
s.active = true
|
||||||
s.lock.Unlock()
|
s.mu.Unlock()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
@@ -272,8 +285,17 @@ func (s *Spinner) Start() {
|
|||||||
case <-s.stopChan:
|
case <-s.stopChan:
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
s.lock.Lock()
|
s.mu.Lock()
|
||||||
|
if !s.active {
|
||||||
|
s.mu.Unlock()
|
||||||
|
return
|
||||||
|
}
|
||||||
s.erase()
|
s.erase()
|
||||||
|
|
||||||
|
if s.PreUpdate != nil {
|
||||||
|
s.PreUpdate(s)
|
||||||
|
}
|
||||||
|
|
||||||
var outColor string
|
var outColor string
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
if s.Writer == os.Stderr {
|
if s.Writer == os.Stderr {
|
||||||
@@ -282,14 +304,18 @@ func (s *Spinner) Start() {
|
|||||||
outColor = fmt.Sprintf("\r%s%s%s ", s.Prefix, s.color(s.chars[i]), s.Suffix)
|
outColor = fmt.Sprintf("\r%s%s%s ", s.Prefix, s.color(s.chars[i]), s.Suffix)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
outColor = fmt.Sprintf("%s%s%s ", s.Prefix, s.color(s.chars[i]), s.Suffix)
|
outColor = fmt.Sprintf("\r%s%s%s ", s.Prefix, s.color(s.chars[i]), s.Suffix)
|
||||||
}
|
}
|
||||||
outPlain := fmt.Sprintf("%s%s%s ", s.Prefix, s.chars[i], s.Suffix)
|
outPlain := fmt.Sprintf("\r%s%s%s ", s.Prefix, s.chars[i], s.Suffix)
|
||||||
fmt.Fprint(s.Writer, outColor)
|
fmt.Fprint(s.Writer, outColor)
|
||||||
s.lastOutput = outPlain
|
s.lastOutput = outPlain
|
||||||
delay := s.Delay
|
delay := s.Delay
|
||||||
s.lock.Unlock()
|
|
||||||
|
|
||||||
|
if s.PostUpdate != nil {
|
||||||
|
s.PostUpdate(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
s.mu.Unlock()
|
||||||
time.Sleep(delay)
|
time.Sleep(delay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,40 +323,41 @@ func (s *Spinner) Start() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop stops the indicator
|
// Stop stops the indicator.
|
||||||
func (s *Spinner) Stop() {
|
func (s *Spinner) Stop() {
|
||||||
s.lock.Lock()
|
s.mu.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.mu.Unlock()
|
||||||
if s.active {
|
if s.active {
|
||||||
s.active = false
|
s.active = false
|
||||||
if s.HideCursor && runtime.GOOS != "windows" {
|
if s.HideCursor && runtime.GOOS != "windows" {
|
||||||
// makes the cursor visible
|
// makes the cursor visible
|
||||||
fmt.Print("\033[?25h")
|
fmt.Fprint(s.Writer, "\033[?25h")
|
||||||
}
|
}
|
||||||
s.erase()
|
s.erase()
|
||||||
if s.FinalMSG != "" {
|
if s.FinalMSG != "" {
|
||||||
fmt.Fprintf(s.Writer, s.FinalMSG)
|
fmt.Fprint(s.Writer, s.FinalMSG)
|
||||||
}
|
}
|
||||||
s.stopChan <- struct{}{}
|
s.stopChan <- struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restart will stop and start the indicator
|
// Restart will stop and start the indicator.
|
||||||
func (s *Spinner) Restart() {
|
func (s *Spinner) Restart() {
|
||||||
s.Stop()
|
s.Stop()
|
||||||
s.Start()
|
s.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reverse will reverse the order of the slice assigned to the indicator
|
// Reverse will reverse the order of the slice assigned to the indicator.
|
||||||
func (s *Spinner) Reverse() {
|
func (s *Spinner) Reverse() {
|
||||||
s.lock.Lock()
|
s.mu.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.mu.Unlock()
|
||||||
for i, j := 0, len(s.chars)-1; i < j; i, j = i+1, j-1 {
|
for i, j := 0, len(s.chars)-1; i < j; i, j = i+1, j-1 {
|
||||||
s.chars[i], s.chars[j] = s.chars[j], s.chars[i]
|
s.chars[i], s.chars[j] = s.chars[j], s.chars[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Color will set the struct field for the given color to be used
|
// Color will set the struct field for the given color to be used. The spinner
|
||||||
|
// will need to be explicitly restarted.
|
||||||
func (s *Spinner) Color(colors ...string) error {
|
func (s *Spinner) Color(colors ...string) error {
|
||||||
colorAttributes := make([]color.Attribute, len(colors))
|
colorAttributes := make([]color.Attribute, len(colors))
|
||||||
|
|
||||||
@@ -342,63 +369,55 @@ func (s *Spinner) Color(colors ...string) error {
|
|||||||
colorAttributes[index] = colorAttributeMap[c]
|
colorAttributes[index] = colorAttributeMap[c]
|
||||||
}
|
}
|
||||||
|
|
||||||
s.lock.Lock()
|
s.mu.Lock()
|
||||||
s.color = color.New(colorAttributes...).SprintFunc()
|
s.color = color.New(colorAttributes...).SprintFunc()
|
||||||
s.lock.Unlock()
|
s.mu.Unlock()
|
||||||
s.Restart()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateSpeed will set the indicator delay to the given value
|
// UpdateSpeed will set the indicator delay to the given value.
|
||||||
func (s *Spinner) UpdateSpeed(d time.Duration) {
|
func (s *Spinner) UpdateSpeed(d time.Duration) {
|
||||||
s.lock.Lock()
|
s.mu.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.mu.Unlock()
|
||||||
s.Delay = d
|
s.Delay = d
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateCharSet will change the current character set to the given one
|
// UpdateCharSet will change the current character set to the given one.
|
||||||
func (s *Spinner) UpdateCharSet(cs []string) {
|
func (s *Spinner) UpdateCharSet(cs []string) {
|
||||||
s.lock.Lock()
|
s.mu.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.mu.Unlock()
|
||||||
s.chars = cs
|
s.chars = cs
|
||||||
}
|
}
|
||||||
|
|
||||||
// erase deletes written characters
|
// erase deletes written characters.
|
||||||
//
|
|
||||||
// Caller must already hold s.lock.
|
// Caller must already hold s.lock.
|
||||||
func (s *Spinner) erase() {
|
func (s *Spinner) erase() {
|
||||||
n := utf8.RuneCountInString(s.lastOutput)
|
n := utf8.RuneCountInString(s.lastOutput)
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
var clearString string
|
clearString := "\r" + strings.Repeat(" ", n) + "\r"
|
||||||
for i := 0; i < n; i++ {
|
fmt.Fprint(s.Writer, clearString)
|
||||||
clearString += " "
|
|
||||||
}
|
|
||||||
clearString += "\r"
|
|
||||||
fmt.Fprintf(s.Writer, clearString)
|
|
||||||
s.lastOutput = ""
|
s.lastOutput = ""
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
del, _ := hex.DecodeString("7f")
|
for _, c := range []string{"\b", "\127", "\b", "\033[K"} { // "\033[K" for macOS Terminal
|
||||||
for _, c := range []string{"\b", string(del), "\b", "\033[K"} { // "\033[K" for macOS Terminal
|
fmt.Fprint(s.Writer, strings.Repeat(c, n))
|
||||||
for i := 0; i < n; i++ {
|
|
||||||
fmt.Fprintf(s.Writer, c)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
fmt.Fprintf(s.Writer, "\r\033[K") // erases to end of line
|
||||||
s.lastOutput = ""
|
s.lastOutput = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lock allows for manual control to lock the spinner
|
// Lock allows for manual control to lock the spinner.
|
||||||
func (s *Spinner) Lock() {
|
func (s *Spinner) Lock() {
|
||||||
s.lock.Lock()
|
s.mu.Lock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unlock allows for manual control to unlock the spinner
|
// Unlock allows for manual control to unlock the spinner.
|
||||||
func (s *Spinner) Unlock() {
|
func (s *Spinner) Unlock() {
|
||||||
s.lock.Unlock()
|
s.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateNumberSequence will generate a slice of integers at the
|
// GenerateNumberSequence will generate a slice of integers at the
|
||||||
// provided length and convert them each to a string
|
// provided length and convert them each to a string.
|
||||||
func GenerateNumberSequence(length int) []string {
|
func GenerateNumberSequence(length int) []string {
|
||||||
numSeq := make([]string, length)
|
numSeq := make([]string, length)
|
||||||
for i := 0; i < length; i++ {
|
for i := 0; i < length; i++ {
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@@ -49,7 +49,7 @@ github.com/asdine/storm/codec/json
|
|||||||
github.com/asdine/storm/index
|
github.com/asdine/storm/index
|
||||||
github.com/asdine/storm/internal
|
github.com/asdine/storm/internal
|
||||||
github.com/asdine/storm/q
|
github.com/asdine/storm/q
|
||||||
# github.com/briandowns/spinner v1.7.0
|
# github.com/briandowns/spinner v1.12.1-0.20201220203425-e201aaea0a31
|
||||||
## explicit
|
## explicit
|
||||||
github.com/briandowns/spinner
|
github.com/briandowns/spinner
|
||||||
# github.com/cavaliercoder/grab v1.0.1-0.20201108051000-98a5bfe305ec
|
# github.com/cavaliercoder/grab v1.0.1-0.20201108051000-98a5bfe305ec
|
||||||
|
Reference in New Issue
Block a user