slok / gospinner

Make beautiful and fast spinners in Go
MIT License
17 stars 3 forks source link

Gospinner GoDoc Build Status

Gospinner lets you make simple spinners for your go cli applications. Is fast and easy to use. Simple customizations and ready to go defaults!

gospinner

Install

go get github.com/slok/gospinner

Running examples

Examples

Default spinner

s, _ := gospinner.NewSpinner(gospinner.Dots)
s.Start("Loading")
// Do stuff
s.Finish()

Custom color spinner

s, _ := gospinner.NewSpinnerWithColor(gospinner.Ball, gospinner.FgGreen)
s.Start("Loading")
// Do stuff
s.Finish()

No color spinner

s, _ := s, _ := gospinner.NewSpinnerNoColor(gospinner.GrowHorizontal)
s.Start("Loading")
// Do stuff
s.Finish()

Spinner with 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()

Changing message while spinning and finishing with custom message

s, _ := gospinner.NewSpinner(gospinner.Square)
s.Start("Loading")
// Do stuff
s.SetMessage("Starting server dependencies")
// Do more stuff
s.SetMessage("Starting server")
// Do more stuff
s.FinishWithMessage("⚔", "Finished!")

Available spinners:

For more customizations you should check the documentation

Credits

Xabier Larrakoetxea

License

The MIT License (MIT) - see LICENSE.md for more details