Documentation ¶
Overview ¶
Package gospinner is a spinner package to create spinners in a fast, beatiful and easy way. No more ugly and old cli applications, give feedback to your users
Use the simplest spinner and start getting awsome cli applications:
s, _ := gospinner.NewSpinnerWithColor(gospinner.Ball, gospinner.FgGreen) s.Start("Loading") // Do stuff s.Finish()
However sometimes you want custom colors for your spinners:
s, _ := s, _ := gospinner.NewSpinnerNoColor(gospinner.GrowHorizontal) s.Start("Loading") // Do stuff s.Finish()
Easy right? but that finish line is a little bit sad, Lets use some cool finishers!
s, _ := gospinner.NewSpinner(gospinner.Pong) s.Start("Loading job 1") // Do job 1 ... s.Succeed() s.Start("Loading job 2") // Do job 2 ... s.Fail() s.Start("Loading job 3") // Do job 3 ... s.Warn()
You have more stuff to customize it, check it on the documentation.
Index ¶
- type Animation
- type AnimationKind
- type Color
- type ColorAttr
- type Spinner
- func (s *Spinner) Fail() error
- func (s *Spinner) Finish() error
- func (s *Spinner) FinishWithMessage(symbol, closingMessage string) error
- func (s *Spinner) FinishWithSymbol(symbol string) error
- func (s *Spinner) Render() error
- func (s *Spinner) Reset()
- func (s *Spinner) SetMessage(message string)
- func (s *Spinner) Start(message string) error
- func (s *Spinner) StartWithSpeed(message string, speed time.Duration) error
- func (s *Spinner) Stop() error
- func (s *Spinner) Succeed() error
- func (s *Spinner) Warn() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Animation ¶
type Animation struct {
// contains filtered or unexported fields
}
Animation represents an animation with frames and speed (recommended)
type AnimationKind ¶
type AnimationKind int
AnimationKind represents the kind of the animation
const ( Ball AnimationKind = iota Column Slash Square Triangle Dots Dots2 Pipe SimpleDots SimpleDotsScrolling GrowVertical GrowHorizontal Arrow BouncingBar BouncingBall Pong ProgressBar )
type ColorAttr ¶
ColorAttr is an adaptation of fatih color attributes as own type for easy usage for the lib users
type Spinner ¶
type Spinner struct { // Writer will be the target of the printing Writer io.Writer // Our locker sync.Mutex // contains filtered or unexported fields }
Spinner is a representation of the animation itself
func NewSpinner ¶
func NewSpinner(kind AnimationKind) (*Spinner, error)
NewSpinner creates a new spinner with the common default values, this should be the most used one, fast and easy.
func NewSpinnerNoColor ¶
func NewSpinnerNoColor(kind AnimationKind) (*Spinner, error)
NewSpinnerNoColor creates an spinner that doesn't have color, shoud be compatible with all the terminals
func NewSpinnerWithColor ¶
func NewSpinnerWithColor(kind AnimationKind, color ColorAttr) (*Spinner, error)
NewSpinnerWithColor creates an spinner with a custom color, same as the default one, but instead you can select the color you want for the spinner
func (*Spinner) FinishWithMessage ¶
FinishWithMessage will finish animation setting a message and a symbol where the spinner was
func (*Spinner) FinishWithSymbol ¶
FinishWithSymbol will finish the animation with a symbol where the spinner is
func (*Spinner) SetMessage ¶
SetMessage will set new message on the animation without stoping it
func (*Spinner) Start ¶
Start will animate with the recommended speed, this should be the default choice.
func (*Spinner) StartWithSpeed ¶
StartWithSpeed will start animation witha custom speed for the spinner