-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspinner.go
More file actions
66 lines (54 loc) · 1.36 KB
/
Copy pathspinner.go
File metadata and controls
66 lines (54 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"fmt"
"os"
"sync"
"time"
"github.com/theckman/yacspin"
)
type SpinnerUpdater struct {
S *yacspin.Spinner
Success int32
Failed int32
Output string
mu sync.Mutex
}
func CreateSpinnerFromMethods() *yacspin.Spinner {
cfg := yacspin.Config{
Frequency: 100 * time.Millisecond,
CharSet: yacspin.CharSets[40],
SuffixAutoColon: true,
Message: "Initializing Download",
// StopMessage: "Done downloading subtitle",
StopCharacter: "✓",
StopColors: []string{"fgGreen"},
StopFailCharacter: "✗",
StopFailMessage: "Failed while downloading subtitle",
StopFailColors: []string{"fgRed"},
}
s, err := yacspin.New(cfg)
if err != nil {
exitf("failed to generate spinner from methods: %v", err)
}
if err := s.CharSet(yacspin.CharSets[11]); err != nil {
exitf("failed to set charset: %v", err)
}
if err := s.Colors("fgYellow"); err != nil {
exitf("failed to set color: %v", err)
}
if err := s.StopColors("fgGreen"); err != nil {
exitf("failed to set stop colors: %v", err)
}
if err := s.StopFailColors("fgRed"); err != nil {
exitf("failed to set stop fail colors: %v", err)
}
s.Suffix(" ")
s.StopCharacter("✓")
s.StopFailCharacter("✗")
s.StopFailMessage("failed")
return s
}
func exitf(format string, a ...interface{}) {
fmt.Printf(format, a...)
os.Exit(1)
}