-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from chelnak/enhanced_configuration
Enhanced configuration
- Loading branch information
Showing
5 changed files
with
145 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package charmap | ||
|
||
var Dots = []string{ | ||
"⠋", | ||
"⠙", | ||
"⠹", | ||
"⠸", | ||
"⠼", | ||
"⠴", | ||
"⠦", | ||
"⠧", | ||
"⠇", | ||
"⠏", | ||
} | ||
|
||
var Arrows = []string{ | ||
"←", | ||
"↖", | ||
"↑", | ||
"↗", | ||
"→", | ||
"↘", | ||
"↓", | ||
"↙", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package colors | ||
|
||
import "github.com/fatih/color" | ||
|
||
// Color represents an item in the color map. | ||
type Color int | ||
|
||
const ( | ||
// FgHiGreen is a foreground high intensity green color. | ||
FgHiGreen Color = iota | ||
|
||
// FgHiYellow is a foreground high intensity yellow color. | ||
FgHiYellow | ||
|
||
// FgHiBlue is a foreground high intensity blue color. | ||
FgHiBlue | ||
|
||
// FgHiRed is a foreground high intensity red color. | ||
FgHiRed | ||
) | ||
|
||
var lookup = map[Color]color.Attribute{ | ||
FgHiGreen: color.FgHiGreen, | ||
FgHiYellow: color.FgHiYellow, | ||
FgHiBlue: color.FgHiBlue, | ||
FgHiRed: color.FgHiRed, | ||
} | ||
|
||
// Get returns a color.Color for the given color. | ||
func GetColor(c Color) *color.Color { | ||
return color.New(lookup[c]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,52 @@ | ||
package ysmrr | ||
|
||
import "github.com/fatih/color" | ||
import ( | ||
"sync" | ||
|
||
"github.com/chelnak/ysmrr/pkg/colors" | ||
"github.com/fatih/color" | ||
) | ||
|
||
// Spinner manages a single spinner | ||
type spinner struct { | ||
c *color.Color | ||
msg string | ||
complete bool | ||
err bool | ||
mutex sync.Mutex | ||
spinnerColor *color.Color | ||
completeColor *color.Color | ||
errorColor *color.Color | ||
msg string | ||
complete bool | ||
err bool | ||
} | ||
|
||
// Update updates the spinner message | ||
func (s *spinner) Update(msg string) { | ||
s.mutex.Lock() | ||
defer s.mutex.Unlock() | ||
|
||
s.msg = msg | ||
} | ||
|
||
// Complete marks the spinner as complete | ||
func (s *spinner) Complete() { | ||
s.mutex.Lock() | ||
defer s.mutex.Unlock() | ||
|
||
s.complete = true | ||
} | ||
|
||
// Error marks the spinner as error | ||
func (s *spinner) Error() { | ||
s.mutex.Lock() | ||
defer s.mutex.Unlock() | ||
|
||
s.err = true | ||
} | ||
|
||
func NewSpinner(msg string, c *color.Color) *spinner { | ||
func NewSpinner(msg string, spinnerColor, completeColor, errorColor colors.Color) *spinner { | ||
return &spinner{ | ||
c: c, | ||
msg: msg, | ||
spinnerColor: colors.GetColor(spinnerColor), | ||
completeColor: colors.GetColor(completeColor), | ||
errorColor: colors.GetColor(errorColor), | ||
msg: msg, | ||
} | ||
} |