Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { // Interval is how often the spinner updates. This controls the speed of the spinner. // The default value is 100ms. Interval time.Duration // Out is where the spinner is written. The default value is os.Stderr. Out io.Writer // Message is the text written after the spinner. Message string // Count is the total amount of items to track the progress of. Count int // MaxMessageLength is the max length of the message that is written. If the message is // longer then this length it will be truncated. The default max length is 80. MaxMessageLength int // PersistMessages is whether or not messages should be persisted to Out when the message // is updated. By default messages are not persisted and are replaced. PersistMessages bool }
Options allows for customization of a spinner.
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner represents the state of the spinner.
func (*Spinner) Inc ¶
func (s *Spinner) Inc()
Inc increments the progress of the spinner. If the spinner has already reached full progress, Inc does nothing.
func (*Spinner) UpdateMessage ¶
UpdateMessage changes the current message being shown by the spinner.
func (*Spinner) Write ¶
Write writes p to the spinner's writer after the current frame has been erased. Write will always immediately return successfully as p is first written to an internal buffer. The actual writing of the data to the spinner's writer will not occur until the appropriate time during the spinner animation.
Write will add a newline to the end of p in order to ensure that it does not interfere with the spinner animation.
type TTYOptions ¶
type TTYSpinner ¶
type TTYSpinner struct { *Spinner // contains filtered or unexported fields }
TTYSpinner is a wrapper over a spinner that handles whether or not the spinner's output is a tty. If out is a tty, it functions the same as a Spinner. If out is not a tty, then the spinner will simply write messages to it without the spinner animation.
func (*TTYSpinner) Start ¶
func (s *TTYSpinner) Start()
Start starts the spinner if out is a tty, otherwise it writes the message to out directly.
func (*TTYSpinner) UpdateMessage ¶
func (s *TTYSpinner) UpdateMessage(m string)
UpdateMessage either updates the spinner message, or writes m directy to out depending on whether or not out is a tty.