spin

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const ClearLine = "\r\033[K"

ClearLine go to the beginning of the line and clear it

Variables

View Source
var (
	Box1    = `⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏`
	Box2    = `⠋⠙⠚⠞⠖⠦⠴⠲⠳⠓`
	Box3    = `⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆`
	Box4    = `⠋⠙⠚⠒⠂⠂⠒⠲⠴⠦⠖⠒⠐⠐⠒⠓⠋`
	Box5    = `⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠴⠲⠒⠂⠂⠒⠚⠙⠉⠁`
	Box6    = `⠈⠉⠋⠓⠒⠐⠐⠒⠖⠦⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈`
	Box7    = `⠁⠁⠉⠙⠚⠒⠂⠂⠒⠲⠴⠤⠄⠄⠤⠠⠠⠤⠦⠖⠒⠐⠐⠒⠓⠋⠉⠈⠈`
	Spin1   = `|/-\`
	Spin2   = `◴◷◶◵`
	Spin3   = `◰◳◲◱`
	Spin4   = `◐◓◑◒`
	Spin5   = `▉▊▋▌▍▎▏▎▍▌▋▊▉`
	Spin6   = `▌▄▐▀`
	Spin7   = `╫╪`
	Spin8   = `■□▪▫`
	Spin9   = `←↑→↓`
	Spin10  = `⦾⦿`
	Spin11  = `⌜⌝⌟⌞`
	Spin12  = `┤┘┴└├┌┬┐`
	Spin13  = `⇑⇗⇒⇘⇓⇙⇐⇖`
	Spin14  = `☰☱☳☷☶☴`
	Spin15  = `䷀䷪䷡䷊䷒䷗䷁䷖䷓䷋䷠䷫`
	Default = Box1
)

Spinner types.

Functions

This section is empty.

Types

type Option

type Option func(s *Spinner)

Option describes an option to override a default when creating a new Spinner.

func WithDoneMessage

func WithDoneMessage(text string) Option

WithDoneMessage sets the final message as done.

func WithFrames

func WithFrames(frames string) Option

WithFrames sets the frames string.

func WithTimePerFrame

func WithTimePerFrame(d time.Duration) Option

WithTimePerFrame sets how long each frame shall be shown.

type Spinner

type Spinner struct {
	// contains filtered or unexported fields
}

Spinner main type

func New

func New(text string, opts ...Option) *Spinner

New creates a Spinner object with the provided text. By default, the Default spinner frames are used, and new frames are rendered every 100 milliseconds. Options can be provided to override these default settings.

func (*Spinner) Set

func (s *Spinner) Set(frames string)

Set frames to the given string which must not use spaces.

func (*Spinner) Start

func (s *Spinner) Start() *Spinner

Start shows the spinner.

func (*Spinner) Stop

func (s *Spinner) Stop() bool

Stop hides the spinner.

Jump to

Keyboard shortcuts

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