Extensible Go terminal spinner with advanced functions with 82 built-in spinners

Peek 2022-04-16 19-13 Go Reference GitHub release (latest SemVer)

Features

  • Start/Stop
  • Customizable character sets (spinners)
  • Custom spinner color, background
  • Custom spinner text
  • Restarting and reversing the spinner
  • Prefixed text, symbol and padding before the spinner
  • Changing spinner settings while it is active
  • Getting the spinner settings values
  • Chain, pipe or redirect output
  • Shows the seconds elasped since the spinner started (can be disabled)
  • Ability to Stop and persist the spinner with custom text and a symbol
  • Pre-built Succeed, Fail and Info functions that stops and persists the spinner with pre-defined cross-platform symbol and text

Usage

import "github.com/AnishDe12020/spintron"

func main() {
	s := spintron.New(spintron.Options{
		Text: "Working...",
	})

	s.Start() // Starts the spinner with the initial text
	// Some work that will take time. E.g. Downloading a file. Let us have a dummy
	// function for now
	err := DownloadFile()

	if err != nil {
		s.Fail("Failed to download the file") // Stops the spinner and shows a error sign with the given text
	} else {
		s.Success("Downloaded the file successfully") // Stops the spinner and shows a success sign with the given text
	}
}

Options

When a new spinner is created, it can be created with a struct of options. Here are the ones available -

Color (string) (default: cyan)

The color of the spinner

Text (string)

The text after the spinner

HideCursor (bool) (defaukt: true)

Hide the cursor or not

Symbol (string)

A symbol that will come before the prefix text

PrefixText (string)

Text that will come before the spinner

CharacterSet (string) (default: dots2)

Character set used for the spinner

Writer (io.Writer) (default: color.Output)

stdOut writer

Delay (time.Duration) (default: 100 ms)

Delay between frames in the character set

Padding (int)

Number of chatacters in padding on the left of the spinner

DisableElaspedSeconds (bool) (default: false)

Disable the elasped seconds timer

Examples

Reversing the spinner

time.Sleep(time.Second * 2) // Simulate a long running process
s.Reverse() // Reverse the spinner's character set
s.Text = "I have been reversed"
time.Sleep(time.Second * 2) // Simulate a long running process
s.Stop() // Stops the spinner

Updating the spinner color

time.Sleep(time.Second * 2)                // Simulate a long running process
s.UpdateCharSet(spintron.CharSets["moon"]) // Update spinner to use a different character set
s.Text = "My character set has been updated"
time.Sleep(time.Second * 2) // Simulate a long running process
s.Stop()                    // Stops the spinner

Updating the spinner speed

time.Sleep(time.Second * 2)                         // Simulate a long running process
s.UpdateSpeed(time.Duration(50) * time.Millisecond) // Update spinner to use a different speed, here making it twice that of the default speed
s.Text = "My speed has been updated to make me faster"
time.Sleep(time.Second * 2) // Simulate a long running process
s.Stop()                    // Stops the spinner

Adding padding to the spinner

time.Sleep(time.Second * 2) // Simulate a long running process
s.Padding = 10              // Add a padding of 10 characters to the left of the spinner
s.Text = "My padding has been updated"
time.Sleep(time.Second * 2) // Simulate a long running process
s.Stop()                    // Stops the spinner

Stop and persist the spinner

time.Sleep(time.Second * 2)   // Simulate a long running process
s.StopAndPersist("πŸ‘€", "Heya") // Stops the spinner and persists it with a custom symbol and text

Succeeding, Failing or stopping the spinner with an info message

s.Succeed("Done!") // Stops the spinner and persists it with a success sign and message
s.Fail("Uh oh! Something went wrong!") // Stops the spinner and persists it with an error sign and message
s.Info("Star the repo") // Stops the spinner and persists it with an info sign and message

Credits

All commits uptil 561dc95 are made by Brian Downs and the contributors to the original repository, briandowns/spinner. The project has since been renamed to Spintron to differentiate from the original project.

This is a fork of the original Go Spinner repository Brian Downs licensed under Apache 2.0.

Owner
Anish De
14 β€’ Tech Enthusiast β€’ Fullstack Web Developer β€’ Blogger β€’ Tech YouTuber
Anish De
Similar Resources

Fully featured Go (golang) command line option parser with built-in auto-completion support.

go-getoptions Go option parser inspired on the flexibility of Perl’s GetOpt::Long. Table of Contents Quick overview Examples Simple script Program wit

Jun 15, 2022

Lux is a command-line interface for controlling and monitoring Govee lighting strips built in Go.

What is Lux? Lux is a command-line interface for controlling and monitoring Govee lighting strips built in Go. Lux provides it's users with the abilit

Jun 18, 2022

A twitch focused command line tool for producing, archiving and managing live stream content. Built for Linux.

twinx is a live-streaming command line tool for Linux. It connects streaming services (like Twitch, OBS and YouTube) together via a common title and description.

May 27, 2022

A command line tool for simplified docker volume command built with go

dockervol A command line tool for simplified docker volume command built with go. Features: Remove anonymous volume (beta) Remove volume by matching n

Dec 18, 2021

CLI to run a docker image with R. CLI built using cobra library in go.

CLI  to run a docker image with R. CLI built using cobra library in go.

BlueBeak Installation Guide Task 1: Building the CLI The directory structure looks like Fastest process: 1)cd into bbtools 2)cd into bbtools/bin 3)I h

Dec 20, 2021

Gowget - A simple wget tool built using golang to download files from the internet whether it is zip

gowget wget built using golang About: A simple wget tool built using golang to d

May 21, 2022

Go-file-downloader-ftctl - A file downloader cli built using golang. Makes use of cobra for building the cli and go concurrent feature to download files.

ftctl This is a file downloader cli written in Golang which uses the concurrent feature of go to download files. The cli is built using cobra. How to

Jan 2, 2022

Custom i3status bar built with Barista.

Custom i3status Customized i3status command built with Barista. Includes a Barista module for strongSwan. Install go install enr0n.net/i3status/cmd/i3

Jan 10, 2022
Comments
  • chore(deps): bump github.com/mattn/go-isatty from 0.0.8 to 0.0.14

    chore(deps): bump github.com/mattn/go-isatty from 0.0.8 to 0.0.14

    Bumps github.com/mattn/go-isatty from 0.0.8 to 0.0.14.

    Commits
    • 504425e Merge pull request #66 from cookieY/sys
    • ee4b64c Update golang.org/x/sys commit hash to 0f9fa26a
    • 68134e7 Merge pull request #65 from shogo82148/introduce-go-build-comments
    • bea4d7c Merge pull request #64 from shogo82148/migrate-github-actions
    • 3ba961d add //go:build
    • 56b25a0 migrate from travis-ci to GitHub Actions
    • 712ea5b Merge pull request #62 from marcauberer/master
    • be5a901 Fix typo
    • 8b0c6d8 Merge pull request #61 from tklauser/fix-solaris-isterminal
    • 518b0c1 Don't set termio in IsTerminal on solaris
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • chore(deps): bump github.com/fatih/color from 1.7.0 to 1.13.0

    chore(deps): bump github.com/fatih/color from 1.7.0 to 1.13.0

    Bumps github.com/fatih/color from 1.7.0 to 1.13.0.

    Release notes

    Sourced from github.com/fatih/color's releases.

    v1.13.0

    This release updates the following dependencies:

    github.com/mattn/go-colorable v0.1.9
    github.com/mattn/go-isatty v0.0.14
    

    v1.12.0

    This release adds support for the NO_COLOR. For more information check out: https://no-color.org The pull request adding this change is: fatih/color#137

    v1.11.0

    This release removes the vendor/ folder introduced by the PR: fatih/color#138

    v1.10.0

    This release includes the changes from: #115 which upgrades the go-colorable and go-isatty dependencies with various bug fixes and improvements

    github.com/mattn/go-colorable v0.1.8
    github.com/mattn/go-isatty v0.0.12
    

    v1.9.0

    Includes the changes from: fatih/color#109 which upgrades the go-colorable and go-isatty dependencies to fix WASM compilation issues:

    github.com/mattn/go-colorable v0.1.4
    github.com/mattn/go-isatty v0.0.11
    

    v1.8.0

    Includes changes from fatih/color#108, most notable:

    • Add Go module support
    • Update /vendor folder content according to the new Go modules rules.
    • Replace .travis.yml with GitHub Actions
    Commits
    • a05da93 Merge pull request #146 from fatih/dependabot/go_modules/github.com/mattn/go-...
    • cef423d Bump github.com/mattn/go-colorable from 0.1.8 to 0.1.9
    • 503f536 Merge pull request #145 from DrKhyz/fix/typo-readme
    • 65d7546 typo/ add 'color' in front FgBlue to be declared
    • 063d636 Merge pull request #144 from fatih/dependabot/go_modules/github.com/mattn/go-...
    • ab503e9 Bump github.com/mattn/go-isatty from 0.0.13 to 0.0.14
    • 30388e0 Merge pull request #140 from fatih/dependabot/go_modules/github.com/mattn/go-...
    • 351c3d7 Bump github.com/mattn/go-isatty from 0.0.12 to 0.0.13
    • cf45235 Merge pull request #137 from fatih/add-no-color-support
    • f4c4316 Merge pull request #139 from fatih/improve-ci
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • [ImgBot] Optimize images

    [ImgBot] Optimize images

    Beep boop. Your images are optimized!

    Your image file size has been reduced by 29% πŸŽ‰

    Details

    | File | Before | After | Percent reduction | |:--|:--|:--|:--| | /gifs/22.gif | 3.20kb | 1.87kb | 41.75% | | /gifs/24.gif | 2.98kb | 1.87kb | 37.41% | | /gifs/33.gif | 3.05kb | 1.99kb | 34.68% | | /gifs/21.gif | 2.59kb | 1.74kb | 32.65% | | /vendor/github.com/defaltd/log-symbols/screenshot.png | 379.16kb | 255.44kb | 32.63% | | /gifs/14.gif | 3.02kb | 2.06kb | 31.88% | | /gifs/43.gif | 12.72kb | 8.89kb | 30.14% | | /gifs/40.gif | 3.02kb | 2.16kb | 28.42% | | /gifs/13.gif | 2.59kb | 1.86kb | 28.42% | | /gifs/34.gif | 6.72kb | 4.87kb | 27.62% | | /gifs/27.gif | 4.09kb | 2.97kb | 27.31% | | /gifs/16.gif | 3.92kb | 2.86kb | 26.91% | | /gifs/35.gif | 20.91kb | 15.30kb | 26.85% | | /gifs/36.gif | 7.43kb | 5.44kb | 26.82% | | /gifs/11.gif | 3.21kb | 2.35kb | 26.79% | | /gifs/5.gif | 4.47kb | 3.28kb | 26.78% | | /gifs/17.gif | 3.02kb | 2.21kb | 26.70% | | /gifs/28.gif | 4.13kb | 3.03kb | 26.54% | | /gifs/6.gif | 3.66kb | 2.75kb | 24.75% | | /gifs/42.gif | 3.91kb | 2.95kb | 24.48% | | /gifs/20.gif | 5.14kb | 4.00kb | 22.25% | | /gifs/1.gif | 3.30kb | 2.56kb | 22.25% | | /gifs/30.gif | 3.95kb | 3.08kb | 22.09% | | /gifs/18.gif | 3.81kb | 3.03kb | 20.64% | | /gifs/29.gif | 4.00kb | 3.18kb | 20.46% | | /gifs/19.gif | 5.34kb | 4.28kb | 19.77% | | /gifs/41.gif | 4.98kb | 4.00kb | 19.58% | | /gifs/0.gif | 4.04kb | 3.32kb | 17.85% | | /gifs/32.gif | 6.20kb | 5.11kb | 17.62% | | /gifs/12.gif | 15.49kb | 12.82kb | 17.26% | | /gifs/8.gif | 4.19kb | 3.47kb | 17.12% | | /gifs/10.gif | 4.46kb | 3.70kb | 17.01% | | /gifs/9.gif | 3.07kb | 2.55kb | 17.00% | | /gifs/7.gif | 6.34kb | 5.30kb | 16.38% | | /gifs/39.gif | 23.82kb | 19.95kb | 16.24% | | /gifs/26.gif | 6.99kb | 5.88kb | 15.84% | | /gifs/2.gif | 3.32kb | 2.84kb | 14.29% | | /gifs/4.gif | 7.36kb | 6.37kb | 13.37% | | /gifs/31.gif | 10.76kb | 9.39kb | 12.74% | | | | | | | Total : | 604.36kb | 430.73kb | 28.73% |


    πŸ“ docs | :octocat: repo | πŸ™‹πŸΎ issues | πŸͺ marketplace

    ~Imgbot - Part of Optimole family

Advanced ANSI style & color support for your terminal applications
Advanced ANSI style & color support for your terminal applications

termenv lets you safely use advanced styling options on the terminal. It gathers information about the terminal environment in terms of its ANSI & col

Jun 29, 2022
Advanced WSL launcher / installer. (Win10 FCU x64/arm64 or later.)
Advanced WSL launcher / installer. (Win10 FCU x64/arm64 or later.)

wsldl Advanced WSL Distribution Launcher / Installer Detailed documentation is here ?? Requirements Windows 10 1709 Fall Creators Update or later(x64/

Jun 26, 2022
Stonks is a terminal based stock visualizer and tracker that displays realtime stocks in graph format in a terminal.
Stonks is a terminal based stock visualizer and tracker that displays realtime stocks in graph format in a terminal.

Stonks is a terminal based stock visualizer and tracker. Installation Requirements: golang >= 1.13 Manual Clone the repo Run make && make install Pack

Jun 21, 2022
Demonstrating how you can take an action to your intrusions detected by Falco using OpenFaaS functions
Demonstrating how you can take an action to your intrusions detected by Falco using OpenFaaS functions

Kubernetes Response Engine powered by OpenFaaS Although Falco can be used to detect any intrusion attempts and sends alerts to channels according to t

Nov 15, 2021
webify - Turn functions and commands into web services
webify - Turn functions and commands into web services

webify is a very basic CGI server which forwards all requests to a single script. A design goal is to be as zero-config as possible.

Jun 29, 2022
This repository contains utility functions that do not make sense in other packages.

Installation go get github.com/IQ-tech/go-utils Executing code before process exits AtInterruption receives a function that will be called once befor

Dec 9, 2021
Package osargs provides functions to parse command line arguments

osargs About Package osargs provides functions to parse command line arguments. It is published on https://github.com/vbsw/osargs and https://gitlab.c

May 8, 2022
A CLI tool for working with CloudWatch logs. It performs functions that I need at work.

CloudWatch Logs Utility A simple utility for working with CloudWatch Logs. AWS should probably build this themselves, but since they won't, I am here

Dec 31, 2021
UltiTuner: a small helper tool to configure functions for Ultimaker S-Line printers

UltiTuner UltiTuner is a small helper tool to configure functions for Ultimaker

Apr 25, 2022
List of serverless functions for AWS S3. Easy deploy with Vercel CLI

List of serverless functions for AWS S3. Easy deploy with Vercel CLI

Jan 22, 2022