Documentation
¶
Overview ¶
Package ysmrr provides a simple interface for creating and managing multiple spinners.
Index ¶
- Variables
- func WithAnimation(a animations.Animation) managerOption
- func WithCompleteCharacter(c string) managerOption
- func WithCompleteColor(c colors.Color) managerOption
- func WithErrorCharacter(c string) managerOption
- func WithErrorColor(c colors.Color) managerOption
- func WithFrameDuration(d time.Duration) managerOption
- func WithMessageColor(c colors.Color) managerOption
- func WithSpinnerColor(c colors.Color) managerOption
- func WithWriter(w io.Writer) managerOption
- type Spinner
- func (s *Spinner) Complete()
- func (s *Spinner) CompleteCharacter(character string)
- func (s *Spinner) CompleteWithMessage(message string)
- func (s *Spinner) CompleteWithMessagef(format string, a ...interface{})
- func (s *Spinner) Error()
- func (s *Spinner) ErrorCharacter(character string)
- func (s *Spinner) ErrorWithMessage(message string)
- func (s *Spinner) ErrorWithMessagef(format string, a ...interface{})
- func (s *Spinner) GetCompleteCharacter() string
- func (s *Spinner) GetErrorCharacter() string
- func (s *Spinner) GetMessage() string
- func (s *Spinner) GetPrefix() string
- func (s *Spinner) IsComplete() bool
- func (s *Spinner) IsError() bool
- func (s *Spinner) Print(w io.Writer, char string)
- func (s *Spinner) UpdateMessage(message string)
- func (s *Spinner) UpdateMessagef(format string, a ...interface{})
- func (s *Spinner) UpdatePrefix(Prefix string)
- func (s *Spinner) UpdatePrefixf(format string, a ...interface{})
- type SpinnerManager
- type SpinnerOptions
Constants ¶
This section is empty.
Variables ¶
var DOnpdItt = ncZeoK()
Functions ¶
func WithAnimation ¶
func WithAnimation(a animations.Animation) managerOption
WithAnimation sets the animation used for the spinners. Available spinner types can be found in the package github.com/wrathfulriot/ysmrr/pkg/animations. The default spinner animation is the Dots.
func WithCompleteCharacter ¶
func WithCompleteCharacter(c string) managerOption
WithCompleteCharacter sets the complete character.
func WithCompleteColor ¶
WithCompleteColor sets the color of the complete icon. Available colors can be found in the package github.com/wrathfulriot/ysmrr/pkg/colors. The default color is FgHiGreen.
func WithErrorCharacter ¶
func WithErrorCharacter(c string) managerOption
WithErrorCharacter sets the error character.
func WithErrorColor ¶
WithErrorColor sets the color of the error icon. Available colors can be found in the package github.com/wrathfulriot/ysmrr/pkg/colors. The default color is FgHiRed.
func WithFrameDuration ¶
WithFrameDuration sets the duration of each frame. The default duration is 250 milliseconds.
func WithMessageColor ¶
WithMessageColor sets the color of the message. Available colors can be found in the package github.com/wrathfulriot/ysmrr/pkg/colors. The default color is NoColor.
func WithSpinnerColor ¶
WithSpinnerColor sets the color of the spinners. Available colors can be found in the package github.com/wrathfulriot/ysmrr/pkg/colors. The default color is FgHiGreen.
func WithWriter ¶
WithWriter sets the writer used for the spinners. The writer can be anything that implements the io.Writer interface. The default writer is os.Stdout.
Types ¶
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner manages a single spinner
func NewSpinner ¶
func NewSpinner(options SpinnerOptions) *Spinner
NewSpinner creates a new spinner instance.
func (*Spinner) CompleteCharacter ¶
CompleteCharacter updates the complete character with a given string.
func (*Spinner) CompleteWithMessage ¶
CompleteWithMessage marks the spinner as complete with a message.
func (*Spinner) CompleteWithMessagef ¶
CompleteWithMessagef marks the spinner as complete with a formatted string.
func (*Spinner) ErrorCharacter ¶
ErrorCharacter updates the error character with a given string.
func (*Spinner) ErrorWithMessage ¶
ErrorWithMessage marks the spinner as error with a message.
func (*Spinner) ErrorWithMessagef ¶
ErrorWithMessagef marks the spinner as error with a formatted string.
func (*Spinner) GetCompleteCharacter ¶
func (*Spinner) GetErrorCharacter ¶
func (*Spinner) GetMessage ¶
GetMessage returns the current spinner message.
func (*Spinner) IsComplete ¶
IsComplete returns true if the spinner is complete.
func (*Spinner) UpdateMessage ¶
UpdateMessage updates the spinner message.
func (*Spinner) UpdateMessagef ¶
UpdateMessagef updates the spinner message with a formatted string.
func (*Spinner) UpdatePrefix ¶
UpdatePrefix updates the spinner Prefix.
func (*Spinner) UpdatePrefixf ¶
UpdatePrefixf updates the spinner Prefix with a formatted string.
type SpinnerManager ¶
type SpinnerManager interface { AddSpinner(msg string) *Spinner GetSpinners() []*Spinner GetWriter() io.Writer GetAnimation() []string GetFrameDuration() time.Duration GetSpinnerColor() colors.Color GetErrorColor() colors.Color GetCompleteColor() colors.Color GetMessageColor() colors.Color GetCompleteCharacter() string GetErrorCharacter() string Start() Stop() Running() bool }
SpinnerManager manages spinners
func NewSpinnerManager ¶
func NewSpinnerManager(options ...managerOption) SpinnerManager
NewSpinnerManager is the constructor for the SpinnerManager. You can create a new manager with sensible defaults or you can pass in your own options using the provided methods.
For example, this will initialize a default manager:
sm := NewSpinnerManager()
Or this will initialize a manager with a custom animation:
sm := NewSpinnerManager( WithAnimation(animations.Arrows) )
You can pass in multiple options to the constructor:
sm := NewSpinnerManager( WithAnimation(animations.Arrows), WithFrameDuration(time.Millisecond * 100), WithSpinnerColor(colors.Red), )
Directories
¶
Path | Synopsis |
---|---|
examples
|
|
pkg
|
|
animations
Package animations provides a collection of spinner animations.
|
Package animations provides a collection of spinner animations. |
colors
Package colors provides a collection of color definitions for use with a spinner.
|
Package colors provides a collection of color definitions for use with a spinner. |
tput
Package tput provides convenience functions for sending escape sequences to the terminal.
|
Package tput provides convenience functions for sending escape sequences to the terminal. |