Skip to content

Commit

Permalink
Merge pull request #105 from replicatedhq/reset-password
Browse files Browse the repository at this point in the history
Less colors, more compatible
  • Loading branch information
marccampbell authored Oct 24, 2019
2 parents 4e146a7 + 6db2158 commit 3de42f6
Showing 1 changed file with 33 additions and 41 deletions.
74 changes: 33 additions & 41 deletions pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ func (l *Logger) Info(msg string, args ...interface{}) {
return
}

yellow := color.New(color.FgHiYellow)
yellow.Printf(" ")
yellow.Println(fmt.Sprintf(msg, args...))
yellow.Println("")
fmt.Printf(" ")
fmt.Println(fmt.Sprintf(msg, args...))
fmt.Println("")
}

func (l *Logger) ActionWithoutSpinner(msg string, args ...interface{}) {
Expand All @@ -60,19 +59,17 @@ func (l *Logger) ActionWithoutSpinner(msg string, args ...interface{}) {
return
}

white := color.New(color.FgHiWhite)
white.Printf(" • ")
white.Println(fmt.Sprintf(msg, args...))
fmt.Printf(" • ")
fmt.Println(fmt.Sprintf(msg, args...))
}

func (l *Logger) ChildActionWithoutSpinner(msg string, args ...interface{}) {
if l.isSilent {
return
}

white := color.New(color.FgHiWhite)
white.Printf(" • ")
white.Println(fmt.Sprintf(msg, args...))
fmt.Printf(" • ")
fmt.Println(fmt.Sprintf(msg, args...))
}

func (l *Logger) ActionWithSpinner(msg string, args ...interface{}) {
Expand All @@ -82,10 +79,9 @@ func (l *Logger) ActionWithSpinner(msg string, args ...interface{}) {

s := spin.New()

c := color.New(color.FgHiCyan)
c.Printf(" • ")
c.Printf(msg, args...)
c.Printf(" %s", s.Next())
fmt.Printf(" • ")
fmt.Printf(msg, args...)
fmt.Printf(" %s", s.Next())

l.spinnerStopCh = make(chan bool)
l.spinnerMsg = msg
Expand All @@ -97,10 +93,10 @@ func (l *Logger) ActionWithSpinner(msg string, args ...interface{}) {
case <-l.spinnerStopCh:
return
case <-time.After(time.Millisecond * 100):
c.Printf("\r")
c.Printf(" • ")
c.Printf(msg, args...)
c.Printf(" %s", s.Next())
fmt.Printf("\r")
fmt.Printf(" • ")
fmt.Printf(msg, args...)
fmt.Printf(" %s", s.Next())
}
}
}()
Expand All @@ -113,10 +109,9 @@ func (l *Logger) ChildActionWithSpinner(msg string, args ...interface{}) {

s := spin.New()

c := color.New(color.FgHiCyan)
c.Printf(" • ")
c.Printf(msg, args...)
c.Printf(" %s", s.Next())
fmt.Printf(" • ")
fmt.Printf(msg, args...)
fmt.Printf(" %s", s.Next())

l.spinnerStopCh = make(chan bool)
l.spinnerMsg = msg
Expand All @@ -128,10 +123,10 @@ func (l *Logger) ChildActionWithSpinner(msg string, args ...interface{}) {
case <-l.spinnerStopCh:
return
case <-time.After(time.Millisecond * 100):
c.Printf("\r")
c.Printf(" • ")
c.Printf(msg, args...)
c.Printf(" %s", s.Next())
fmt.Printf("\r")
fmt.Printf(" • ")
fmt.Printf(msg, args...)
fmt.Printf(" %s", s.Next())
}
}
}()
Expand All @@ -142,14 +137,13 @@ func (l *Logger) FinishChildSpinner() {
return
}

white := color.New(color.FgHiWhite)
green := color.New(color.FgHiGreen)

white.Printf("\r")
white.Printf(" • ")
white.Printf(l.spinnerMsg, l.spinnerArgs...)
fmt.Printf("\r")
fmt.Printf(" • ")
fmt.Printf(l.spinnerMsg, l.spinnerArgs...)
green.Printf(" ✓")
white.Printf(" \n")
fmt.Printf(" \n")

l.spinnerStopCh <- true
close(l.spinnerStopCh)
Expand All @@ -160,14 +154,13 @@ func (l *Logger) FinishSpinner() {
return
}

white := color.New(color.FgHiWhite)
green := color.New(color.FgHiGreen)

white.Printf("\r")
white.Printf(" • ")
white.Printf(l.spinnerMsg, l.spinnerArgs...)
fmt.Printf("\r")
fmt.Printf(" • ")
fmt.Printf(l.spinnerMsg, l.spinnerArgs...)
green.Printf(" ✓")
white.Printf(" \n")
fmt.Printf(" \n")

l.spinnerStopCh <- true
close(l.spinnerStopCh)
Expand All @@ -178,14 +171,13 @@ func (l *Logger) FinishSpinnerWithError() {
return
}

white := color.New(color.FgHiWhite)
red := color.New(color.FgHiRed)

white.Printf("\r")
white.Printf(" • ")
white.Printf(l.spinnerMsg, l.spinnerArgs...)
fmt.Printf("\r")
fmt.Printf(" • ")
fmt.Printf(l.spinnerMsg, l.spinnerArgs...)
red.Printf(" ✗")
white.Printf(" \n")
fmt.Printf(" \n")

l.spinnerStopCh <- true
close(l.spinnerStopCh)
Expand Down

0 comments on commit 3de42f6

Please sign in to comment.