Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Spinner ¶
type Spinner interface { // Advance the spinner forward one frame. The previous frame will be // overwritten by the new frame. On the first call to Advance the cursor // will also be hidden. Advance() // Done will remove the spinner, show the cursor and reset the spinner // ready for reuse. Done() // Width overrides the width of the spinner. By default the number of // characters in the first frame are used to determine the width of the // spinner, however this doesn't take into account things like control // characters. Width(w int) // Porcelain stops the spinner from producing any output and calls to // Advance and Done will do nothing. Porcelain() // Writer sets the writer to use when producing the spinner. By default the // writer is stdout. Setting the writer sets porcelain mode to false. If a // custom writer is used then setting porcelain needs to happen outside of // the Spinner and after the writer is set. Writer(writer Writer) }
A Spinner outputs a spinner in place to stdout, allowing activity to be indicated. Run in porcelain mode a Spinner does nothing. A spinner will try to detect if it's not running in a terminal and set porcelain mode if it is.
func New ¶
New returns a new Spinner that uses the given frames for the spinner animation. The Spinner will attempt to determine if it's running in the console, engaging porcelain mode if it isn't. The first frame of the animation is used to determine the width of the spinner. If no frames are provided then the basic frames ("|", "/", "-", and "\") are used.
Example ¶
package main import ( "github.com/domdavis/gospin" ) func main() { // This is the same as gospin.Basic() gospin.New() // New spinner with custom frames gospin.New("-", "+", "*", "+", "-", " ") // Basic ascii spinner using |,/,-, and \ gospin.Basic() // Spinner with a single dot that moves in a circle gospin.Dot() // Spinner with multiple dots moving in a circle gospin.Dots() // Spinner that uses the frames ".", "..", "...", "" gospin.Ellipses() // Spinner that uses scrolling ellipses. gospin.Scrolling() }
Output:
type Writer ¶
type Writer interface { // Write len(b) bytes to the output or output buffer. It returns the number // of bytes written and an error, if any. Write returns a non-nil error when // n != len(b). The contents of Write may not appear on the output until // Sync is called. Write(b []byte) (int, error) // Sync flushes the writer to the output it is tied to. Sync() error }
A Writer allows strings to be written to an output. Output may not appear until Sync is called.