spinner

package
v0.0.0-...-782d1f4 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package spinner Originally created by Brian Downs https://github.com/briandowns/spinner

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package spinner is a simple package to add a spinner / progress indicator to any terminal application.

Index

Constants

This section is empty.

Variables

View Source
var CharSets = map[int][]string{
	0: {"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"},
	1: {"⢹", "⢺", "⢼", "⣸", "⣇", "⡧", "⡗", "⡏"},
}

CharSets contains the available character sets

Functions

This section is empty.

Types

type Option

type Option func(*Spinner)

Option is a function that takes a spinner and applies a given configuration

func WithFinalMSG

func WithFinalMSG(finalMsg string) Option

WithFinalMSG adds the given string to the spinner as the final message to be written

func WithHiddenCursor

func WithHiddenCursor(hideCursor bool) Option

WithHiddenCursor hides the cursor if hideCursor = true given

type Options

type Options struct {
	Suffix     string
	FinalMSG   string
	HideCursor bool
}

Options contains fields to configure the spinner

type Spinner

type Spinner struct {
	Delay time.Duration // Delay is the speed of the indicator

	Prefix   string // Prefix is the text prepended to the indicator
	Suffix   string // Suffix is the text appended to the indicator
	FinalMSG string // string displayed after Stop() is called

	Writer io.Writer // to make testing better, exported so users have access

	HideCursor bool // hideCursor determines if the cursor is visible
	// contains filtered or unexported fields
}

Spinner struct to hold the provided options

func New

func New(cs []string, d time.Duration, options ...Option) *Spinner

New provides a pointer to an instance of Spinner with the supplied options

func (*Spinner) Active

func (s *Spinner) Active() bool

Active will return whether or not the spinner is currently active

func (*Spinner) Lock

func (s *Spinner) Lock()

Lock allows for manual control to lock the spinner

func (*Spinner) Restart

func (s *Spinner) Restart()

Restart will stop and start the indicator

func (*Spinner) Start

func (s *Spinner) Start()

Start will start the indicator

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop stops the indicator

func (*Spinner) Unlock

func (s *Spinner) Unlock()

Unlock allows for manual control to unlock the spinner

func (*Spinner) UpdateCharSet

func (s *Spinner) UpdateCharSet(cs []string)

UpdateCharSet will change the current character set to the given one

func (*Spinner) UpdateSpeed

func (s *Spinner) UpdateSpeed(d time.Duration)

UpdateSpeed will set the indicator delay to the given value

Jump to

Keyboard shortcuts

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