Update vendor

This commit is contained in:
Ettore Di Giacinto
2021-02-17 10:46:13 +01:00
parent b3e3abec8f
commit 49d7efa9ea
5 changed files with 138 additions and 113 deletions

View File

@@ -1,7 +1,10 @@
arch:
- amd64
- ppc64le
language: go
go:
- 1.11
- 1.12.5
- 1.13
- 1.14.1
env:
- GOARCH: amd64
- GOARCH: 386

View File

@@ -17,52 +17,52 @@ go get github.com/briandowns/spinner
## Available Character Sets
(Numbered by their slice index)
index | character set | sample gif
------|---------------|---------------
0 | ```←↖↑↗→↘↓↙``` | ![Sample Gif](gifs/0.gif)
1 | ```▁▃▄▅▆▇█▇▆▅▄▃▁``` | ![Sample Gif](gifs/1.gif)
2 | ```▖▘▝▗``` | ![Sample Gif](gifs/2.gif)
3 | ```┤┘┴└├┌┬┐``` | ![Sample Gif](gifs/3.gif)
4 | ```◢◣◤◥``` | ![Sample Gif](gifs/4.gif)
5 | ```◰◳◲◱``` | ![Sample Gif](gifs/5.gif)
6 | ```◴◷◶◵``` | ![Sample Gif](gifs/6.gif)
7 | ```◐◓◑◒``` | ![Sample Gif](gifs/7.gif)
8 | ```.oO@*``` | ![Sample Gif](gifs/8.gif)
9 | ```|/-\``` | ![Sample Gif](gifs/9.gif)
10 | ```◡◡⊙⊙◠◠``` | ![Sample Gif](gifs/10.gif)
11 | ```⣾⣽⣻⢿⡿⣟⣯⣷``` | ![Sample Gif](gifs/11.gif)
12 | ```>))'> >))'> >))'> >))'> >))'> <'((< <'((< <'((<``` | ![Sample Gif](gifs/12.gif)
13 | ```⠁⠂⠄⡀⢀⠠⠐⠈``` | ![Sample Gif](gifs/13.gif)
14 | ```⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏``` | ![Sample Gif](gifs/14.gif)
15 | ```abcdefghijklmnopqrstuvwxyz``` | ![Sample Gif](gifs/15.gif)
16 | ```▉▊▋▌▍▎▏▎▍▌▋▊▉``` | ![Sample Gif](gifs/16.gif)
17 | ```■□▪▫``` | ![Sample Gif](gifs/17.gif)
18 | ```←↑→↓``` | ![Sample Gif](gifs/18.gif)
19 | ```╫╪``` | ![Sample Gif](gifs/19.gif)
20 | ```⇐⇖⇑⇗⇒⇘⇓⇙``` | ![Sample Gif](gifs/20.gif)
21 | ```⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈``` | ![Sample Gif](gifs/21.gif)
22 | ```⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈``` | ![Sample Gif](gifs/22.gif)
23 | ```⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁``` | ![Sample Gif](gifs/23.gif)
24 | ```⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋``` | ![Sample Gif](gifs/24.gif)
25 | ```ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン``` | ![Sample Gif](gifs/25.gif)
26 | ```. .. ...``` | ![Sample Gif](gifs/26.gif)
27 | ```▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▏▎▍▌▋▊▉█▇▆▅▄▃▂▁``` | ![Sample Gif](gifs/27.gif)
28 | ```.oO°Oo.``` | ![Sample Gif](gifs/28.gif)
29 | ```+x``` | ![Sample Gif](gifs/29.gif)
30 | ```v<^>``` | ![Sample Gif](gifs/30.gif)
31 | ```>>---> >>---> >>---> >>---> >>---> <---<< <---<< <---<< <---<< <---<<``` | ![Sample Gif](gifs/31.gif)
32 | ```| || ||| |||| ||||| |||||| ||||| |||| ||| || |``` | ![Sample Gif](gifs/32.gif)
33 | ```[] [=] [==] [===] [====] [=====] [======] [=======] [========] [=========] [==========]``` | ![Sample Gif](gifs/33.gif)
34 | ```(*---------) (-*--------) (--*-------) (---*------) (----*-----) (-----*----) (------*---) (-------*--) (--------*-) (---------*)``` | ![Sample Gif](gifs/34.gif)
35 | ```█▒▒▒▒▒▒▒▒▒ ███▒▒▒▒▒▒▒ █████▒▒▒▒▒ ███████▒▒▒ ██████████``` | ![Sample Gif](gifs/35.gif)
36 | ```[ ] [=> ] [===> ] [=====> ] [======> ] [========> ] [==========> ] [============> ] [==============> ] [================> ] [==================> ] [===================>]``` | ![Sample Gif](gifs/36.gif)
37 | ```🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘 🕙 🕚 🕛``` | ![Sample Gif](gifs/37.gif)
38 | ```🕐 🕜 🕑 🕝 🕒 🕞 🕓 🕟 🕔 🕠 🕕 🕡 🕖 🕢 🕗 🕣 🕘 🕤 🕙 🕥 🕚 🕦 🕛 🕧``` | ![Sample Gif](gifs/38.gif)
39 | ```🌍 🌎 🌏``` | ![Sample Gif](gifs/39.gif)
40 | ```◜ ◝ ◞ ◟``` | ![Sample Gif](gifs/40.gif)
41 | ```⬒ ⬔ ⬓ ⬕``` | ![Sample Gif](gifs/41.gif)
42 | ```⬖ ⬘ ⬗ ⬙``` | ![Sample Gif](gifs/42.gif)
43 | ```[>>> >] []>>>> [] [] >>>> [] [] >>>> [] [] >>>> [] [] >>>>[] [>> >>]``` | ![Sample Gif](gifs/43.gif)
| index | character set | sample gif |
| ----- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
| 0 | ```←↖↑↗→↘↓↙``` | ![Sample Gif](gifs/0.gif) |
| 1 | ```▁▃▄▅▆▇█▇▆▅▄▃▁``` | ![Sample Gif](gifs/1.gif) |
| 2 | ```▖▘▝▗``` | ![Sample Gif](gifs/2.gif) |
| 3 | ```┤┘┴└├┌┬┐``` | ![Sample Gif](gifs/3.gif) |
| 4 | ```◢◣◤◥``` | ![Sample Gif](gifs/4.gif) |
| 5 | ```◰◳◲◱``` | ![Sample Gif](gifs/5.gif) |
| 6 | ```◴◷◶◵``` | ![Sample Gif](gifs/6.gif) |
| 7 | ```◐◓◑◒``` | ![Sample Gif](gifs/7.gif) |
| 8 | ```.oO@*``` | ![Sample Gif](gifs/8.gif) |
| 9 | ```\|/-\``` | ![Sample Gif](gifs/9.gif) |
| 10 | ```◡◡⊙⊙◠◠``` | ![Sample Gif](gifs/10.gif) |
| 11 | ```⣾⣽⣻⢿⡿⣟⣯⣷``` | ![Sample Gif](gifs/11.gif) |
| 12 | ```>))'> >))'> >))'> >))'> >))'> <'((< <'((< <'((<``` | ![Sample Gif](gifs/12.gif) |
| 13 | ```⠁⠂⠄⡀⢀⠠⠐⠈``` | ![Sample Gif](gifs/13.gif) |
| 14 | ```⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏``` | ![Sample Gif](gifs/14.gif) |
| 15 | ```abcdefghijklmnopqrstuvwxyz``` | ![Sample Gif](gifs/15.gif) |
| 16 | ```▉▊▋▌▍▎▏▎▍▌▋▊▉``` | ![Sample Gif](gifs/16.gif) |
| 17 | ```■□▪▫``` | ![Sample Gif](gifs/17.gif) |
| 18 | ```←↑→↓``` | ![Sample Gif](gifs/18.gif) |
| 19 | ```╫╪``` | ![Sample Gif](gifs/19.gif) |
| 20 | ```⇐⇖⇑⇗⇒⇘⇓⇙``` | ![Sample Gif](gifs/20.gif) |
| 21 | ```⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈``` | ![Sample Gif](gifs/21.gif) |
| 22 | ```⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈``` | ![Sample Gif](gifs/22.gif) |
| 23 | ```⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁``` | ![Sample Gif](gifs/23.gif) |
| 24 | ```⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋``` | ![Sample Gif](gifs/24.gif) |
| 25 | ```ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン``` | ![Sample Gif](gifs/25.gif) |
| 26 | ```. .. ...``` | ![Sample Gif](gifs/26.gif) |
| 27 | ```▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▏▎▍▌▋▊▉█▇▆▅▄▃▂▁``` | ![Sample Gif](gifs/27.gif) |
| 28 | ```.oO°Oo.``` | ![Sample Gif](gifs/28.gif) |
| 29 | ```+x``` | ![Sample Gif](gifs/29.gif) |
| 30 | ```v<^>``` | ![Sample Gif](gifs/30.gif) |
| 31 | ```>>---> >>---> >>---> >>---> >>---> <---<< <---<< <---<< <---<< <---<<``` | ![Sample Gif](gifs/31.gif) |
| 32 | ```\| \|\| \|\|\| \|\|\|\| \|\|\|\|\| \|\|\|\|\|\| \|\|\|\|\| \|\|\|\| \|\|\| \|\| \|``` | ![Sample Gif](gifs/32.gif) |
| 33 | ```[] [=] [==] [===] [====] [=====] [======] [=======] [========] [=========] [==========]``` | ![Sample Gif](gifs/33.gif) |
| 34 | ```(*---------) (-*--------) (--*-------) (---*------) (----*-----) (-----*----) (------*---) (-------*--) (--------*-) (---------*)``` | ![Sample Gif](gifs/34.gif) |
| 35 | ```█▒▒▒▒▒▒▒▒▒ ███▒▒▒▒▒▒▒ █████▒▒▒▒▒ ███████▒▒▒ ██████████``` | ![Sample Gif](gifs/35.gif) |
| 36 | ```[ ] [=> ] [===> ] [=====> ] [======> ] [========> ] [==========> ] [============> ] [==============> ] [================> ] [==================> ] [===================>]``` | ![Sample Gif](gifs/36.gif) |
| 37 | ```🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘 🕙 🕚 🕛``` | ![Sample Gif](gifs/37.gif) |
| 38 | ```🕐 🕜 🕑 🕝 🕒 🕞 🕓 🕟 🕔 🕠 🕕 🕡 🕖 🕢 🕗 🕣 🕘 🕤 🕙 🕥 🕚 🕦 🕛 🕧``` | ![Sample Gif](gifs/38.gif) |
| 39 | ```🌍 🌎 🌏``` | ![Sample Gif](gifs/39.gif) |
| 40 | ```◜ ◝ ◞ ◟``` | ![Sample Gif](gifs/40.gif) |
| 41 | ```⬒ ⬔ ⬓ ⬕``` | ![Sample Gif](gifs/41.gif) |
| 42 | ```⬖ ⬘ ⬗ ⬙``` | ![Sample Gif](gifs/42.gif) |
| 43 | ```[>>> >] []>>>> [] [] >>>> [] [] >>>> [] [] >>>> [] [] >>>>[] [>> >>]``` | ![Sample Gif](gifs/43.gif) |
## Features
@@ -139,7 +139,7 @@ s.Prefix = "prefixed text: " // Prefix text before 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
s.Color("red") // Set the spinner color to red
@@ -242,10 +242,11 @@ 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.
This is the preferred method of setting a Writer at this time.
```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.Writer = os.Stderr
s.Start()
// Encrypt the data into ciphertext
fmt.Println(os.Stdout, ciphertext)

View File

@@ -1,5 +1,7 @@
module github.com/briandowns/spinner
go 1.14
require (
github.com/fatih/color v1.7.0
github.com/mattn/go-colorable v0.1.2 // indirect

View File

@@ -14,13 +14,13 @@
package spinner
import (
"encoding/hex"
"errors"
"fmt"
"io"
"os"
"runtime"
"strconv"
"strings"
"sync"
"time"
"unicode/utf8"
@@ -161,7 +161,7 @@ var colorAttributeMap = map[string]color.Attribute{
"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 {
if validColors[c] {
return true
@@ -169,8 +169,9 @@ func validColor(c string) bool {
return false
}
// Spinner struct to hold the provided options
// Spinner struct to hold the provided options.
type Spinner struct {
mu *sync.RWMutex //
Delay time.Duration // Delay is the speed of the indicator
chars []string // chars holds the chosen character set
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
lastOutput string // last character(set) written
color func(a ...interface{}) string // default color is white
lock *sync.RWMutex //
Writer io.Writer // to make testing better, exported so users have access
Writer io.Writer // to make testing better, exported so users have access. Use `WithWriter` to update after initialization.
active bool // active holds the state of the spinner
stopChan chan struct{} // stopChan is a channel used to stop the indicator
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 {
s := &Spinner{
Delay: d,
chars: cs,
color: color.New(color.FgWhite).SprintFunc(),
lock: &sync.RWMutex{},
mu: &sync.RWMutex{},
Writer: color.Output,
active: false,
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
// a given configuration
// a given configuration.
type Option func(*Spinner)
// Options contains fields to configure the spinner
// Options contains fields to configure the spinner.
type Options struct {
Color string
Suffix string
@@ -215,7 +217,7 @@ type Options struct {
HideCursor bool
}
// WithColor adds the given color to the spinner
// WithColor adds the given color to the spinner.
func WithColor(color string) Option {
return func(s *Spinner) {
s.Color(color)
@@ -223,7 +225,7 @@ func WithColor(color string) Option {
}
// WithSuffix adds the given string to the spinner
// as the suffix
// as the suffix.
func WithSuffix(suffix string) Option {
return func(s *Spinner) {
s.Suffix = suffix
@@ -231,7 +233,7 @@ func WithSuffix(suffix string) Option {
}
// 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 {
return func(s *Spinner) {
s.FinalMSG = finalMsg
@@ -239,31 +241,42 @@ func WithFinalMSG(finalMsg string) Option {
}
// WithHiddenCursor hides the cursor
// if hideCursor = true given
// if hideCursor = true given.
func WithHiddenCursor(hideCursor bool) Option {
return func(s *Spinner) {
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 {
return s.active
}
// Start will start the indicator
// Start will start the indicator.
func (s *Spinner) Start() {
s.lock.Lock()
s.mu.Lock()
if s.active {
s.lock.Unlock()
s.mu.Unlock()
return
}
if s.HideCursor && runtime.GOOS != "windows" {
// hides the cursor
fmt.Print("\033[?25l")
fmt.Fprint(s.Writer, "\033[?25l")
}
s.active = true
s.lock.Unlock()
s.mu.Unlock()
go func() {
for {
@@ -272,8 +285,17 @@ func (s *Spinner) Start() {
case <-s.stopChan:
return
default:
s.lock.Lock()
s.mu.Lock()
if !s.active {
s.mu.Unlock()
return
}
s.erase()
if s.PreUpdate != nil {
s.PreUpdate(s)
}
var outColor string
if runtime.GOOS == "windows" {
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)
}
} 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)
s.lastOutput = outPlain
delay := s.Delay
s.lock.Unlock()
if s.PostUpdate != nil {
s.PostUpdate(s)
}
s.mu.Unlock()
time.Sleep(delay)
}
}
@@ -297,40 +323,41 @@ func (s *Spinner) Start() {
}()
}
// Stop stops the indicator
// Stop stops the indicator.
func (s *Spinner) Stop() {
s.lock.Lock()
defer s.lock.Unlock()
s.mu.Lock()
defer s.mu.Unlock()
if s.active {
s.active = false
if s.HideCursor && runtime.GOOS != "windows" {
// makes the cursor visible
fmt.Print("\033[?25h")
fmt.Fprint(s.Writer, "\033[?25h")
}
s.erase()
if s.FinalMSG != "" {
fmt.Fprintf(s.Writer, s.FinalMSG)
fmt.Fprint(s.Writer, s.FinalMSG)
}
s.stopChan <- struct{}{}
}
}
// Restart will stop and start the indicator
// Restart will stop and start the indicator.
func (s *Spinner) Restart() {
s.Stop()
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() {
s.lock.Lock()
defer s.lock.Unlock()
s.mu.Lock()
defer s.mu.Unlock()
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]
}
}
// 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 {
colorAttributes := make([]color.Attribute, len(colors))
@@ -342,63 +369,55 @@ func (s *Spinner) Color(colors ...string) error {
colorAttributes[index] = colorAttributeMap[c]
}
s.lock.Lock()
s.mu.Lock()
s.color = color.New(colorAttributes...).SprintFunc()
s.lock.Unlock()
s.Restart()
s.mu.Unlock()
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) {
s.lock.Lock()
defer s.lock.Unlock()
s.mu.Lock()
defer s.mu.Unlock()
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) {
s.lock.Lock()
defer s.lock.Unlock()
s.mu.Lock()
defer s.mu.Unlock()
s.chars = cs
}
// erase deletes written characters
//
// erase deletes written characters.
// Caller must already hold s.lock.
func (s *Spinner) erase() {
n := utf8.RuneCountInString(s.lastOutput)
if runtime.GOOS == "windows" {
var clearString string
for i := 0; i < n; i++ {
clearString += " "
}
clearString += "\r"
fmt.Fprintf(s.Writer, clearString)
clearString := "\r" + strings.Repeat(" ", n) + "\r"
fmt.Fprint(s.Writer, clearString)
s.lastOutput = ""
return
}
del, _ := hex.DecodeString("7f")
for _, c := range []string{"\b", string(del), "\b", "\033[K"} { // "\033[K" for macOS Terminal
for i := 0; i < n; i++ {
fmt.Fprintf(s.Writer, c)
}
for _, c := range []string{"\b", "\127", "\b", "\033[K"} { // "\033[K" for macOS Terminal
fmt.Fprint(s.Writer, strings.Repeat(c, n))
}
fmt.Fprintf(s.Writer, "\r\033[K") // erases to end of line
s.lastOutput = ""
}
// Lock allows for manual control to lock the spinner
// Lock allows for manual control to lock the spinner.
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() {
s.lock.Unlock()
s.mu.Unlock()
}
// 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 {
numSeq := make([]string, length)
for i := 0; i < length; i++ {

2
vendor/modules.txt vendored
View File

@@ -49,7 +49,7 @@ github.com/asdine/storm/codec/json
github.com/asdine/storm/index
github.com/asdine/storm/internal
github.com/asdine/storm/q
# github.com/briandowns/spinner v1.7.0
# github.com/briandowns/spinner v1.12.1-0.20201220203425-e201aaea0a31
## explicit
github.com/briandowns/spinner
# github.com/cavaliercoder/grab v1.0.1-0.20201108051000-98a5bfe305ec