uispinner

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: MIT Imports: 5 Imported by: 2

README

uispinner

GoDoc Go

A Go library to render multiple spinners in terminal applications, support multi process and tree structure.

feature

  1. support multi process
  2. tree structure supported
  3. chain method revise spinner
  4. update spinner dynamic
  5. every spinner has self interval

install

go get github.com/jaxleof/uispinner
go get github.com/briandowns/spinner #this package supply many spinners

usage

cj := uispinner.New()
// Only multiples of 50*time.Millisecond are supported because io fresh is slow
spinner1 := cj.AddSpinner(spinner.CharSets[34], 50*time.Millisecond).SetComplete("helloWorld").SetPrefix("abc").SetSuffix("ab")
spinner2 := cj.AddSpinner(spinner.CharSets[0], 100*time.Millisecond).SetComplete("good")
cj.Start()
time.Sleep(time.Second * 5)
spinner1.Done()
spinner2.Done()
cj.Stop()

snapshot

snap.png

thanks

  1. uilive. uilive is a go library for updating terminal output in realtime, which support whole uispinner.
  2. spinner, which supply many interesting spinner.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Process

type Process struct {
	Spinners []*Spinner
	// contains filtered or unexported fields
}

responsible for docking with io and fresh io

func New

func New() *Process

return a new process

func (*Process) AddSpinner

func (p *Process) AddSpinner(stringSet []string, interval time.Duration) *Spinner

add a spinner to process manager

func (*Process) Bypass

func (p *Process) Bypass() io.Writer

return a io.Writer Bypass creates an io.Writer which allows non-buffered output to be written to the underlying output

func (*Process) Start

func (p *Process) Start()

process start work

func (*Process) Stop

func (p *Process) Stop()

process stop work

type Spinner

type Spinner struct {
	Complete      string
	SpinnerString []string
	// contains filtered or unexported fields
}

responsible for managing spinner info

func (*Spinner) AddSpinner added in v0.5.0

func (s *Spinner) AddSpinner(in []string, interval time.Duration) *Spinner

create a spinner and merge it into parent spinner

func (*Spinner) Done

func (s *Spinner) Done()

spinner done, whose childs will be done too.

func (*Spinner) Reverse

func (s *Spinner) Reverse() *Spinner

reverse spinner CharSet

func (*Spinner) SetCharSet

func (s *Spinner) SetCharSet(in []string) *Spinner

decorate spinner

func (*Spinner) SetComplete

func (s *Spinner) SetComplete(in string) *Spinner

set complete word, which will be show when spinner is done

func (*Spinner) SetInterval

func (s *Spinner) SetInterval(interval time.Duration) *Spinner

set Spinner's fresh interval

func (*Spinner) SetPrefix

func (s *Spinner) SetPrefix(in string) *Spinner

decorate spinner, set prefix of spinner, which will be show when spinner is work

func (*Spinner) SetSuffix

func (s *Spinner) SetSuffix(in string) *Spinner

decorate spinner, set suffix of spinner, which will be show when spinner is work

func (*Spinner) String

func (s *Spinner) String(front []bool) string

integrate a spinner, return status of spinner now

func (*Spinner) Work added in v0.5.0

func (s *Spinner) Work()

let a spinner into work status

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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