All Projects → briandowns → Spinner

briandowns / Spinner

Licence: apache-2.0
Go (golang) package with 90 configurable terminal spinner/progress indicators.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to Spinner

Alive Progress
A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
Stars: ✭ 2,940 (+79.6%)
Mutual labels:  cli, terminal, spinner, progress-bar, progressbar
Progress bar
Command-line progress bars and spinners for Elixir.
Stars: ✭ 281 (-82.83%)
Mutual labels:  cli, terminal, spinner, progress-bar, progressbar
Mpb
multi progress bar for Go cli applications
Stars: ✭ 1,221 (-25.41%)
Mutual labels:  cli, terminal, spinner, progress-bar
Tqdm
A Fast, Extensible Progress Bar for Python and CLI
Stars: ✭ 20,632 (+1160.35%)
Mutual labels:  cli, terminal, progress-bar, progressbar
Python Progressbar
Progressbar 2 - A progress bar for Python 2 and Python 3 - "pip install progressbar2"
Stars: ✭ 682 (-58.34%)
Mutual labels:  cli, terminal, progress-bar, progressbar
Spinnercpp
Simple header only library to add a spinner / progress indicator to any terminal application.
Stars: ✭ 37 (-97.74%)
Mutual labels:  cli, terminal, spinner, statusbar
Ruby Progressbar
Ruby/ProgressBar is a text progress bar library for Ruby.
Stars: ✭ 1,378 (-15.82%)
Mutual labels:  cli, terminal, progress-bar, progressbar
React Nprogress
⌛️ A React primitive for building slim progress bars.
Stars: ✭ 173 (-89.43%)
Mutual labels:  spinner, progress-bar, progressbar
Progressbar
A really basic thread-safe progress bar for Golang applications
Stars: ✭ 2,212 (+35.13%)
Mutual labels:  terminal, progress-bar, progressbar
Php Console Spinner
Colorful highly configurable spinner for php cli applications (suitable for async apps)
Stars: ✭ 225 (-86.26%)
Mutual labels:  cli, terminal, spinner
RxActivityIndicator-Android
A small library that helps you keep track of operations progress. It allows you to show progress bar (indicator) in a convenient way.
Stars: ✭ 12 (-99.27%)
Mutual labels:  progress-bar, progressbar, indicator
Node.cli Progress
⌛️ easy to use progress-bar for command-line/terminal applications
Stars: ✭ 466 (-71.53%)
Mutual labels:  cli, progress-bar, progressbar
Progressbar
Terminal-based progress bar for Java / JVM
Stars: ✭ 625 (-61.82%)
Mutual labels:  cli, terminal, progressbar
Yaspin
A lightweight terminal spinner for Python with safe pipes and redirects 🎁
Stars: ✭ 413 (-74.77%)
Mutual labels:  cli, terminal, spinner
Libspinner
A pure C single-header library with 70+ configurable terminal spinner/progress indicators.
Stars: ✭ 24 (-98.53%)
Mutual labels:  terminal, spinner, indicator
Lua cliargs
A command-line argument parsing module for Lua.
Stars: ✭ 84 (-94.87%)
Mutual labels:  cli, terminal
Coolindicator
A dazzling indicator
Stars: ✭ 85 (-94.81%)
Mutual labels:  progressbar, indicator
Run
⚡The resource runtime
Stars: ✭ 90 (-94.5%)
Mutual labels:  cli, terminal
Window Size
Reliable way to to get the height and width of the terminal/console in a node.js environment.
Stars: ✭ 79 (-95.17%)
Mutual labels:  cli, terminal
Yurnalist
An elegant console reporter, borrowed from Yarn
Stars: ✭ 88 (-94.62%)
Mutual labels:  spinner, progress-bar

Spinner

GoDoc Build Status

spinner is a simple package to add a spinner / progress indicator to any terminal application. Examples can be found below as well as full examples in the examples directory.

For more detail about the library and its features, reference your local godoc once installed.

Contributions welcome!

Installation

go get github.com/briandowns/spinner

Available Character Sets

90 Character Sets. Some examples below:

(Numbered by their slice index)

index character set sample gif
0 ←↖↑↗→↘↓↙ Sample Gif
1 ▁▃▄▅▆▇█▇▆▅▄▃▁ Sample Gif
2 ▖▘▝▗ Sample Gif
3 ┤┘┴└├┌┬┐ Sample Gif
4 ◢◣◤◥ Sample Gif
5 ◰◳◲◱ Sample Gif
6 ◴◷◶◵ Sample Gif
7 ◐◓◑◒ Sample Gif
8 .oO@* Sample Gif
9 |/-\ Sample Gif
10 ◡◡⊙⊙◠◠ Sample Gif
11 ⣾⣽⣻⢿⡿⣟⣯⣷ Sample Gif
12 >))'> >))'> >))'> >))'> >))'> <'((< <'((< <'((< Sample Gif
13 ⠁⠂⠄⡀⢀⠠⠐⠈ Sample Gif
14 ⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏ Sample Gif
15 abcdefghijklmnopqrstuvwxyz Sample Gif
16 ▉▊▋▌▍▎▏▎▍▌▋▊▉ Sample Gif
17 ■□▪▫ Sample Gif
18 ←↑→↓ Sample Gif
19 ╫╪ Sample Gif
20 ⇐⇖⇑⇗⇒⇘⇓⇙ Sample Gif
21 ⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈ Sample Gif
22 ⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈ Sample Gif
23 ⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁ Sample Gif
24 ⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋ Sample Gif
25 ヲァィゥェォャュョッアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン Sample Gif
26 . .. ... Sample Gif
27 ▁▂▃▄▅▆▇█▉▊▋▌▍▎▏▏▎▍▌▋▊▉█▇▆▅▄▃▂▁ Sample Gif
28 .oO°Oo. Sample Gif
29 +x Sample Gif
30 v<^> Sample Gif
31 >>---> >>---> >>---> >>---> >>---> <---<< <---<< <---<< <---<< <---<< Sample Gif
32 | || ||| |||| ||||| |||||| ||||| |||| ||| || | Sample Gif
33 [] [=] [==] [===] [====] [=====] [======] [=======] [========] [=========] [==========] Sample Gif
34 (*---------) (-*--------) (--*-------) (---*------) (----*-----) (-----*----) (------*---) (-------*--) (--------*-) (---------*) Sample Gif
35 █▒▒▒▒▒▒▒▒▒ ███▒▒▒▒▒▒▒ █████▒▒▒▒▒ ███████▒▒▒ ██████████ Sample Gif
36 [ ] [=> ] [===> ] [=====> ] [======> ] [========> ] [==========> ] [============> ] [==============> ] [================> ] [==================> ] [===================>] Sample Gif
37 🕐 🕑 🕒 🕓 🕔 🕕 🕖 🕗 🕘 🕙 🕚 🕛 Sample Gif
38 🕐 🕜 🕑 🕝 🕒 🕞 🕓 🕟 🕔 🕠 🕕 🕡 🕖 🕢 🕗 🕣 🕘 🕤 🕙 🕥 🕚 🕦 🕛 🕧 Sample Gif
39 🌍 🌎 🌏 Sample Gif
40 ◜ ◝ ◞ ◟ Sample Gif
41 ⬒ ⬔ ⬓ ⬕ Sample Gif
42 ⬖ ⬘ ⬗ ⬙ Sample Gif
43 [>>> >] []>>>> [] [] >>>> [] [] >>>> [] [] >>>> [] [] >>>>[] [>> >>] Sample Gif

Features

  • Start
  • Stop
  • Restart
  • Reverse direction
  • Update the spinner character set
  • Update the spinner speed
  • Prefix or append text
  • Change spinner color, background, and text attributes such as bold / italics
  • Get spinner status
  • Chain, pipe, redirect output
  • Output final string on spinner/indicator completion

Examples

package main

import (
	"github.com/briandowns/spinner"
	"time"
)

func main() {
	s := spinner.New(spinner.CharSets[9], 100*time.Millisecond)  // Build our new spinner
	s.Start()                                                    // Start the spinner
	time.Sleep(4 * time.Second)                                  // Run for some time to simulate work
	s.Stop()
}

Update the character set and restart the spinner

s.UpdateCharSet(spinner.CharSets[1])  // Update spinner to use a different character set
s.Restart()                           // Restart the spinner
time.Sleep(4 * time.Second)
s.Stop()

Update spin speed and restart the spinner

s.UpdateSpeed(200 * time.Millisecond) // Update the speed the spinner spins at
s.Restart()
time.Sleep(4 * time.Second)
s.Stop()

Reverse the direction of the spinner

s.Reverse() // Reverse the direction the spinner is spinning
s.Restart()
time.Sleep(4 * time.Second)
s.Stop()

Provide your own spinner

(or send me an issue or pull request to add to the project)

someSet := []string{"+", "-"}
s := spinner.New(someSet, 100*time.Millisecond)

Prefix or append text to the spinner

s.Prefix = "prefixed text: " // Prefix text before the spinner
s.Suffix = "  :appended text" // Append text after the spinner

Set or change the color of the spinner. Default color is white. The spinner will need to be restarted to pick up the change.

s.Color("red") // Set the spinner color to red

You can specify both the background and foreground color, as well as additional attributes such as bold or underline.

s.Color("red", "bold") // Set the spinner color to a bold red

To set the background to black, the foreground to a bold red:

s.Color("bgBlack", "bold", "fgRed")

Below is the full color and attribute list:

// default colors
red
black
green
yellow
blue
magenta
cyan
white

// attributes
reset
bold
faint
italic
underline
blinkslow
blinkrapid
reversevideo
concealed
crossedout

// foreground text
fgBlack
fgRed
fgGreen
fgYellow
fgBlue
fgMagenta
fgCyan
fgWhite

// foreground Hi-Intensity text
fgHiBlack
fgHiRed
fgHiGreen
fgHiYellow
fgHiBlue
fgHiMagenta
fgHiCyan
fgHiWhite

// background text
bgBlack
bgRed
bgGreen
bgYellow
bgBlue
bgMagenta
bgCyan
bgWhite

// background Hi-Intensity text
bgHiBlack
bgHiRed
bgHiGreen
bgHiYellow
bgHiBlue
bgHiMagenta
bgHiCyan
bgHiWhite

Generate a sequence of numbers

setOfDigits := spinner.GenerateNumberSequence(25)    // Generate a 25 digit string of numbers
s := spinner.New(setOfDigits, 100*time.Millisecond)

Get spinner status

fmt.Println(s.Active())

Unix pipe and redirect

Feature suggested and write up by dekz

Setting the Spinner Writer to Stderr helps show progress to the user, with the enhancement to chain, pipe or redirect the output.

This is the preferred method of setting a Writer at this time.

s := spinner.New(spinner.CharSets[11], 100*time.Millisecond, spinner.WithWriter(os.Stderr))
s.Suffix = " Encrypting data..."
s.Start()
// Encrypt the data into ciphertext
fmt.Println(os.Stdout, ciphertext)
> myprog encrypt "Secret text" > encrypted.txt
⣯ Encrypting data...
> cat encrypted.txt
1243hjkbas23i9ah27sj39jghv237n2oa93hg83

Final String Output

Add additional output when the spinner/indicator has completed. The "final" output string can be multi-lined and will be written to wherever the io.Writer has been configured for.

s := spinner.New(spinner.CharSets[9], 100*time.Millisecond)
s.FinalMSG = "Complete!\nNew line!\nAnother one!\n"
s.Start()                 
time.Sleep(4 * time.Second)
s.Stop()                   

Output

Complete!
New line!
Another one!
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].