spinner

package
v12.120.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Overview

Package spinner provides methods for creating spinner animation for long-running tasks

Index

Examples

Constants

This section is empty.

Variables

View Source
var DisableAnimation = false

DisableAnimation is global animation off switch flag

View Source
var ErrColorTag = "{r}"

ErrColorTag is cross color tag (see fmtc package)

View Source
var ErrSymbol = "✖ "

ErrSymbol contains symbol for action with problems

View Source
var OkColorTag = "{g}"

OkColorTag is check color tag (see fmtc package)

View Source
var OkSymbol = "✔ "

OkSymbol contains symbol for action with no problems

View Source
var SkipColorTag = "{s-}"

SkipColorTag is skipped action color tag (see fmtc package)

View Source
var SkipSymbol = "✔ "

SkipSymbol contains symbol for skipped action

View Source
var SpinnerColorTag = "{y}"

SpinnerColorTag is spinner animation color tag (see fmtc package)

View Source
var TimeColorTag = "{s-}"

TimeColorTag is time color tag (see fmtc package)

Functions

func Done

func Done(ok bool)

Done finishes spinner animation and shows task status

Example
Show("My long running task with good result")
time.Sleep(time.Second)
Done(true)

Show("My long running task with bad result")
time.Sleep(time.Second)
Done(false)
Output:

func Show

func Show(message string, args ...any)

Show shows spinner with given task description

Example
file := "file.txt"

// Customize design
OkSymbol = "🤟"     // Set success status symbol
OkColorTag = "{b}" // Set success status symbol color

Show("Removing file %s", file)
time.Sleep(time.Second)
Done(true)
Output:

func Skip added in v12.46.0

func Skip()

Skip finishes spinner animation and mark it as skipped

Example
Show("My skipped running task")
time.Sleep(time.Second)
Skip()
Output:

func Update

func Update(message string, args ...any)

Update updates task description

Example
Show("My long running task")
time.Sleep(time.Second)
Show("My long running task still working")
time.Sleep(time.Second)
Done(true)
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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