round

package module
v0.0.0-...-49e79c6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2017 License: MIT Imports: 8 Imported by: 0

README ΒΆ

round

Go command line spinner.

About

Package round is a command line spinner. Start one with Go.

The package will intelligently decide whether to write spinners on stdout, stderr or neither, depending if a terminal is present.

Wrappers for Stdout and Stderr are provided so as not to interfere with the spinner while running.

Get It

go get github.com/dedelala/round
go-round
go install github.com/dedelala/round/go-round

go-round is a command line program that adds a spinner to almost anything. It copies stdin to stdout. You can read go-round help for usage.

Use It

import "github.com/dedelala/round"

Make It Go

round.Go(round.Pipe)

Write Out

fmt.Fprintln(round.Stdout, "Like a record!")
fmt.Fprintln(round.Stderr, "Wahhhhh!")

Don't write directly to os.Stdout or os.Stderr while a spinner is running. There be dragons.

Make It Stop

round.Stop()

Built-In Styles!

Style = Unicode Set
Block β–ˆ 2580β€”259F Block Elements
Cylon @ 0020β€”007F Basic Latin
Hearts πŸ’– 1F300β€”1F5FF Miscellaneous Symbols and Pictographs
Moon πŸŒ“ 1F300β€”1F5FF Miscellaneous Symbols and Pictographs
Pipe - 0020β€”007F Basic Latin

Make Your Own Scroller

s := round.NewScroller(12, "[%v]", "Do Not Panic!")
round.Start(s)

Documentation ΒΆ

Overview ΒΆ

Package round is a command line spinner. Start one with Go.

The package will intelligently decide whether to write spinners on stdout, stderr or neither, depending if a terminal is present.

Wrappers for Stdout and Stderr are provided so as not to interfere with the spinner while running.

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

View Source
var (
	// Stdout is a spin-safe version of os.Stdout.
	Stdout io.Writer

	// Stderr is a spin-safe version of os.Stderr.
	Stderr io.Writer
)
View Source
var Block = Style{
	[]string{"▏", "β–Ž", "▍", "β–Œ", "β–‹", "β–Š", "β–‰", "β–ˆ", "β–‡", "β–†", "β–…", "β–„", "β–ƒ", "β–‚", "▁", ""},
	60 * time.Millisecond,
}

Block is a good old trusty block thing. It uses "β–ˆ" from 2580β€”259F Block Elements.

View Source
var Cylon = NewBouncer(7, "\x1b[1m(\x1b[31m%v\x1b[0;1m)\x1b[0m", "@")

Cylon is ominous. It uses "@" from 0020β€”007F Basic Latin.

View Source
var Hearts = Style{
	[]string{"πŸ’–πŸ’›πŸ’šπŸ’™πŸ’œ", "πŸ’œπŸ’–πŸ’›πŸ’šπŸ’™", "πŸ’™πŸ’œπŸ’–πŸ’›πŸ’š", "πŸ’šπŸ’™πŸ’œπŸ’–πŸ’›", "πŸ’›πŸ’šπŸ’™πŸ’œπŸ’–"},
	90 * time.Millisecond,
}

Hearts is clearly the best style! It uses "πŸ’œ" from 1F300β€”1F5FF Misc Symbols and Pictographs.

View Source
var Moon = Style{[]string{"πŸŒ‘", "πŸŒ’", "πŸŒ“", "πŸŒ”", "πŸŒ•", "πŸŒ–", "πŸŒ—", "🌘"}, 90 * time.Millisecond}

Moon is a series of moon phases. It uses "πŸŒ•" from 1F300β€”1F5FF Misc Symbols and Pictographs.

View Source
var Pipe = Style{[]string{"|", "/", "-", "\\"}, 60 * time.Millisecond}

Pipe is guaranteed to work. It uses "|" from 0020β€”007F Basic Latin.

Functions ΒΆ

func Go ΒΆ

func Go(s Style)

Go makes a spinner go. It will Stop first if there is one running already.

func Stop ΒΆ

func Stop()

Stop will stop and remove the spinner.

Types ΒΆ

type Style ΒΆ

type Style struct {
	Frames []string
	Rate   time.Duration
}

Style is a spinner style. Any number of frames is allowed, each frame can be any length. The following Styles are supplied: Block, Cylon, Hearts, Moon, Pipe.

func NewBouncer ΒΆ

func NewBouncer(width int, format, text string) Style

NewBouncer creates a Style with some text that bounces back and forth.

func NewInvertedBouncer ΒΆ

func NewInvertedBouncer(width int, format, text string) Style

NewInvertedBouncer creates a Style just like NewBouncer except it goes in the opposite direction at the start. For the true pedant.

func NewInvertedScroller ΒΆ

func NewInvertedScroller(width int, format, text string) Style

NewInvertedScroller creates a Style for a text scroller with the specified width and format. It scrolls from left to right.

func NewScroller ΒΆ

func NewScroller(width int, format, text string) Style

NewScroller creates a Style for a text scroller with the specified width and format. It scrolls from right to left.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL