TERMite
Termite is my playground for terminal app utilities and visual elements such as progress bars and indicators, cursor control and screen updates.
Install
go get github.com/sha1n/termite
Examples
Spinner
refreshInterval := time.Millisecond * 100
spinner := termite.NewSpinner(termite.StdoutWriter, "Processing...", refreshInterval, termite.DefaultSpinnerFormatter())
if _, e := spinner.Start(); e == nil {
doWork()
_ = spinner.Stop("Done!")
}
Progress Bar
termWidth, _, _ := termite.GetTerminalDimensions()
progressBar := termite.NewProgressBar(termite.StdoutWriter, tickCount, width, termWidth, termite.DefaultProgressBarFormatter())
if tick, cancel, err := progressBar.Start(); err == nil {
defer cancel()
doWork(tick)
}
Showcase
The code for this demo can be found in internal/main.go (go run internal/main.go
).