ttyprogress

package module
v0.0.0-...-8fc7b8e Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: Apache-2.0 Imports: 18 Imported by: 5

README

Progress Indicators for Terminal Output

This module provides various progress indicators for terminal output and a framework to create new such indicators.

It is possible to combine multiple progress indicators in a 'Context' object. It covers and manages trailing lines of a terminal output and acts as group to add any number of indicators. Additionally, indicators can be grouped again. Those groups are visualized as indicators, also.

The following indicators are directly supported by the library:

There are various presets with the visualization of bars and spinners. Additionally, they can freely be configured.

Usage

The usage of the library based on the Context type. It is created using the For function for an io.Writer, which should represent a terminal output. The Context acts as Container for a sequence of indicators.

import "github.com/mandelsoft/ttyprogress"

func main() {
	
    // setup output context
    p := ttyprogress.For(os.Stdout)
	
    // configure indicator (types)
    bar := ttyprogress.NewBar().
            SetPredefined(10).
            SetTotal(500).
            SetWidth(ttyprogress.PercentTerminalSize(30)).
            PrependMessage("Downloading...").
            PrependElapsed().AppendCompleted().
            AppendFunc(ttyprogress.Amount(units.Bytes(1024)))

    // instantiate bar definition for context
    // (similar to elem, _ := bar.Add(p) )
    // and run some process updating the progress on the indicator element.
    ttyprogress.RunWith(p, bar, func(elem ttyprogress.Bar) {
        for i := 0; i <= 20; i++ {
            elem.Set(i * 5 * 5)
            time.Sleep(time.Millisecond * 500)
        }
    })

    // close context to indicate, that no new indicators are created anymore
    p.Close()
	
    // wait until all indicators are finished	
    p.Wait(context.Background())
}

Once a Context object is created for a writer, the writer MUST NOT be used until the progress is finished (for example by calling Wait). As long a Close is not called, it is possible to add progress indicators.

To create an indicator a definition has to be created and configured by calling configuration methods. Every definition can be instantiated multiple time by adding it to a context (or group).

Close on the context or group MUST be called prior to Wait. Wait waits until the context object is closed and all added indicators are closed and finished.

Progress indicators are defined by progress indicator definition objects. For every archetype there is one constructor function providing a basic configuration.


bartype := ttyprogress.NewBar()

This configuration can be refined by various chainable setters.

bartype.SetWidth(ttypprogress.PercentTerminalSize(50))

Any such configuration can be used as preconfigured type, which can be instantiated with New. It creates a new configuration based on the given one, which can furthermore be configured independently of the original configuration.

newtype := ttyprogress.New(bartype)

To save a configuration to a new immutable basic type, the function TypeFor can be used:

var BarElapsed = ttyprogress.TypeFor(NewBar(5).SetWidth(50).AppendElapsed())

This type is now independent of further modifications of the initial configuration and does not provide methods for further modifications. But it can be used to create new preconfigured configurations with New, again. See the type example in examples/progress/def.

newtype := ttyprogress.New(BarElapsed)

Any configuration, regardless of its creation method, can be used to add an arbitrary number of instances of such a progress indicator to a Context object.

newtype.Add(p)

The indicator is started by calling the Start method. Some indicator archetypes implicitly start the indicator when some progress is indicated by an appropriate indicator method like Incr on a Bar indicator.

Once all indicators are added the Context object can be closed. It is not possible anymore o add more indicators to a closed group. With calling the Wait method, the calling Go routine waits until the group and all included indicators are closed.

If a context is given Wait also returns if the context is cancelled.

ctx, _ := context.WithTimeout(context.Background(), time.Minute)
p.Wait(ctx)

Examples

Here some examples for the usage of the various archetypes are shown.

Spinner

The Spinner progress indicator visualizes unlimited progress by cycling a sequence of fixed sized strings. The look is completely configurable, but there are several preconfigured setting. They can be found in ttyprogress.SpinnerTypes. It maps an integer to a spinner configuration.

spinner := ttyprogress.NewSpinner().
	         SetPredefined(1000).
			 SetSpeed(1).
			 SetColor(color.New(color.BgGreen, color.Underline)).
			 PrependMessage("working on task ...").
			 AppendElapsed()

Spinner Demo

This example can be found in examples/progress/spinner/main.go.

Scrolling Text Spinners

A scrolling text spinner is basically a spinner. But it uses a scrolling text to indicate the progress.

spinner := ttyprogress.NewScrollingSpinner("doing some calculations", 10).
		SetDone("calculations done").
		AppendElapsed()

Scrolling Text Spinner Demo

Scrolling text can also be used as decorator for other progress indicators using the specs.ScrollingText(text, length) decorator.

Progress Bar

The Bar progress indicator visualizers the progress by a fixed length sequence of characters. The look is completely configurable, but there are several preconfigured setting. They can be found in ttyprogress.BarTypes. It maps an integer to a bar configuration. For the brackets around the progress sequence predefined ones can be provided by the map ttyprogress.BracketTypes.

The progress is defined an integer value between 0 and a configurable total amount. It can be set absolutely by calling Set or incrementally ba calling Incr.

bar := ttyprogress.NewBar().
		SetPredefined(10).
		SetTotal(500).
		SetWidth(ttyprogress.PercentTerminalSize(30)).
		PrependMessage("Downloading...").
		PrependElapsed().AppendCompleted().
		AppendFunc(ttyprogress.Amount(units.Bytes(1024))).

Progress Bar Demo

This example can be found in examples/progress/bar/main.go.

The LineBar progress indicator does not use an explicit progress visualization, but the complete progress line by reversing the output according to the achieved progress.

bar := ttyprogress.NewLineBar().
		SetTotal(500).
		PrependMessage("Downloading...").
		PrependElapsed().AppendCompleted().
		SetDecoratorFormat(ttycolors.FmtGreen).
		AppendFunc(ttyprogress.Amount(units.Bytes(1024)))

Line Bar Demo

This example can be found in examples/progress/linebar/main.go.

Progress Bar for Steps

If there is a fixed set of sequential steps the progress can be indicated with a Steps indicator archetype. It is a Bar progress indicator prepared to indicate the progress of a predefined sequence of steps.

bar := ttyprogress.NewSteps("downloading", "unpacking", "installing", "verifying").
		PrependStep().
		PrependFunc(ttyprogress.Message("progressbar"), 0).
		PrependElapsed().AppendCompleted()

Progress Bar Demo

This example can be found in examples/progress/steps/main.go.

Progress Bar for estimated Total Time.

If there is a time estimation for a progress the Estimated archetype can be used. It is a progress bar indicating the progress based on elapsed and total time. Instead of setting the progress, the estimated total time can be updated.

est := ttyprogress.NewEstimated(10 *time.Second).
		SetWidth(ttyprogress.ReserveTerminalSize(40)).
		SetPredefined(10).
		PrependFunc(ttyprogress.Message("Downloading...")).
		PrependEstimated().
		AppendCompleted().
		AppendElapsed()

Estimated Total Time Demo

This example can be found in examples/progress/estimated/main.go.

Text Output

The Text progress indicator visualizes an output steam. During the progress it shows a configured number of trailing lines by providing an io.Writer. After the indicator is closed the complete lines are written to the terminal, after all preceding indicators in the group and all outer groups are also closed.

It is intended to visualize multiple parallel output streams without mixing the output.

text := ttyprogress.NewText().
		SetTitleLine("some output").
		SetFollowUpGap("> ").
		SetView(3).
		SetAuto()

Progress Bar Demo

This example can be found in examples/progress/text/main.go.

Text Output with Spinner Title Line

The Text progress indicator visualizes an output steam. During the progress it shows a configured number of trailing lines by providing an io.Writer, like a Text indicator. But instead an optional simple static title line a Spinner is used.

text := ttyprogress.NewTextSpinner().
          SetPredefined(5).
          SetView(3).
          SetFollowUpGap("> ").
	      PrependMessage(fmt.Sprintf("working on task %d...", s+1)).
          AppendElapsed()

Text Spinner Demo

This example can be found in examples/progress/textspinner/main.go.

Indicator Groups

The initial Context object holds a sequence of progress indicators. It is an initial indicator group. There other Group indicators, which act as indicator and can hold an arbitrary sequence of indicators, again. The group progress is indicated by another indicator configuration implementing the adapter API (GroupProgressElementDefinition). So farm this is supported by the Bar and Spinner archetype.

As long as the groups is not closed more indicators can be added, even if there are additional indicators in an outer group. The group indicator is finished, if the group is closed and all contained indicators are finished.


func text(g ttyprogress.Group) {
	for t := 0; t < 2; t++ {
		text, _ := ttyprogress.NewTextSpinner().
			SetPredefined(70).
			SetView(3).
			SetSpeed(1).
			SetFollowUpGap("> ").
			PrependFunc(ttyprogress.Message(fmt.Sprintf("working on task %d...", t+1))).
			AppendElapsed().
			Add(g)

		go func() {
			m := 3 + rand.Int()%8
			for i := 0; i <= m; i++ {
				fmt.Fprintf(text, "doing step %d of task %d\n", i+1, t+1)
				time.Sleep(time.Millisecond * 100 * time.Duration(1+rand.Int()%20))
			}
			text.Close()
		}()
	}
}

func main() {
	p := ttyprogress.For(os.Stdout)

	// use spinner to indicate group progress.
	s := ttyprogress.NewSpinner().
		SetSpeed(5).
		SetPredefined(86).
		PrependFunc(ttyprogress.Message(fmt.Sprintf("Grouped work"))).
		AppendElapsed()

	g, _ := ttyprogress.NewGroup[ttyprogress.Spinner](s).
		SetGap("- ").
		SetFollowUpGap("  ").Add(p)
	text(g)
	g.Close()
	p.Close()
	p.Wait(nil)
}

Group Demo

This example can be found in examples/progress/group/main.go.

A second group flavor AnonymousGroup acts as a sole indicator group without own indicator visualizing the group progress. It can be used for a common handling of a sequence of other indicators. It offers hiding and the gap handling as shown above.

g := ttyprogress.NewAnonymousGroup().
		HideOnClose().
		SetGap("- ").
		SetFollowUpGap("  ")

Anonymous Group Demo

This example can be found in examples/progress/anongroup/main.go.

Nested Steps

If the progress of steps for a Steps indicator should be visualized a NestedSteps archetype can be used. It is a group controlled by a Steps indicator. Here, steps are defined by a name and an indicator configuration. The indicators are added to the group sequentially after the previous step is finished.


func Step(n string) ttyprogress.NestedStep {
  return ttyprogress.NewNestedStep[ttyprogress.Bar](
    n, ttyprogress.NewBar().SetTotal(100).
         PrependElapsed().
         AppendCompleted())
}

steps := ttyprogress.NewNestedSteps(
		Step("downloading"),
		Step("unpacking"),
		Step("installing"),
		Step("verifying")).
		SetGap("  ").
		SetWidth(40).
		ShowStepTitle(false).
		PrependFunc(ttyprogress.Message("progressbar"), 0).
		PrependElapsed().
		AppendCompleted()

Nested Steps Demo

This example can be found in examples/progress/nestedsteps/main.go.

Bringing it all together

Using groups complex scenarios can be visualized as shown in the example examples/progress/complex/main.go.

Complex Orchestration Demo

Variables

Progress indicator decorations can be based on variables. This can be used for example to visualize an execution status in addition to the progress. Variable values can be dynamically set on the progress elements.

func main() {
	p := ttyprogress.For(os.Stdout)

	bars := []int{1000, specs.SpinnerType}

	def := ttyprogress.NewSpinner().
		SetSpeed(1).
		AppendElapsed().
		PrependMessage("working on").
		PrependVariable("name").
		PrependMessage("...")

	for i, b := range bars {
		bar, _ := def.SetPredefined(b).Add(p)
		bar.SetVariable("name", fmt.Sprintf("task %d", i+1))
		bar.Start()
		go func() {
			time.Sleep(time.Second * time.Duration(10+rand.Int()%20))
			bar.Close()
		}()
	}

	p.Close()
	p.Wait(nil)
}

With AppendVariable or PrependVariable variable values can be added to the progress line. The state passed to the decorators can access the variable values, which enabled to create more complex decorators using variable values of an arbitrary structure. While feeding the progress the variables can be modified on the progress element with SetVariable.

Using Variables

This example can be found in examples/progress/variables/main.go.

Colors

This library works together with the terminal color library github.com/mandelsoft/ttycolors.

The Context object is based on a ttycolors.TTYContext to control the output formatting colorized in terms of ANSI Escape Codes. By default, it is initialized by checking the writer for writing to a terminal. But it can be configured, explicitly, by using the EnableColors method.

For example

p := ttyprogress.New(os.StdOut).EnableColors(false)

disables the output formatting, even if the standard output is directed to a terminal.

Colorized Progress Bar Demo

Elements of the main progress line can be colorized separately.

This example can be found in examples/progress/colors/main.go.

Be careful using colors in text views. This only works, if a line contains a complete output format ANSI sequences. Text based indicators support the SetViewFormat method to configure the output format for the text view to set the format for the complete text independently of the Write operations.

Acknowledgment of Prior Work

This library is inspired by libraries provided by Greg Osuri: github.com/gosuri/uilive and github.com/gosuri/uiprogress

Documentation

Overview

Package ttyprogress contains utilities to visualize work progress on terminals. Context is the container covering some lines at the end of an output stream directed to a terminal. It can be used to add an arbitrary number of progress indicators.

Package github.com/mandelsoft/ttyprogress/ppi provides some support types, which can be used to provide own progress indicators to enrich the set of indicators provided by this package.

Index

Constants

This section is empty.

Variables

View Source
var (
	BarTypes     = specs.BarTypes
	BracketTypes = specs.BracketTypes

	// BarWidth is the default width of the progress bar
	BarWidth = specs.BarWidth

	// ErrMaxCurrentReached is error when trying to set current value that exceeds the total value
	ErrMaxCurrentReached = errors.New("errors: current value is greater total value")
)

Functions

func AddElement

func AddElement[T Element](p Container, definition types.ElementDefinition[T]) (T, error)

func GeneralizedRunner

func GeneralizedRunner[E Element](r func(E)) func(Element)

GeneralizedRunner converts a type specific runner to a general runner.

func New

func New[T Dupper[T]](d Dupper[T]) T

New provides a new independent element definition for a given predefined one.

func PercentTerminalSize

func PercentTerminalSize(p uint) uint

PercentTerminalSize return a width relative to to the terminal size.

func ReserveTerminalSize

func ReserveTerminalSize(r uint) uint

ReserveTerminalSize provide a reasonable width reserving an amount of characters for predefined fixed content.

func RunWith

func RunWith[E Element, D ElementDefinition[E], A Element](c Container, def D, runner func(e A)) (E, error)

RunWith asynchronously executes a function for progressing a progress indication given by its definition. If the function exists the indicator is closed The runner must accept an Element interface matching the created element type.

func RunWithS

func RunWithS[E Element, D ElementDefinition[E]](c Container, def D, runner func(e E)) (E, error)

func SimpleProgress

func SimpleProgress[T Element](w io.Writer, e ElementDefinition[T]) T

SimpleProgress creates and displays a single progress element according to the given specification.

func SpecializedRunner

func SpecializedRunner[E Element](r func(Element)) func(E)

SpecializedRunner converts a generic runner to a type specific runner.

Types

type AnonymousGroup

type AnonymousGroup interface {
	specs.GroupBaseInterface
	Gap() string
	Close() error
}

AnonymousGroup is a plain indicator group and itself no indicator. It can be used group indicator with common handling for gaps and hiding.

type AnonymousGroupDefinition

type AnonymousGroupDefinition struct {
	specs.GroupBaseDefinition[*AnonymousGroupDefinition]
}

func NewAnonymousGroup

func NewAnonymousGroup() *AnonymousGroupDefinition

func (*AnonymousGroupDefinition) Add

func (*AnonymousGroupDefinition) Dup

type Bar

type Bar interface {
	specs.BarInterface
}

Bar is a progress bar used to visualize the progress of an action in relation to a known maximum of required work.

type BarConfig

type BarConfig = specs.BarConfig

type BarDefinition

type BarDefinition struct {
	specs.BarDefinition[*BarDefinition]
}

func NewBar

func NewBar(set ...int) *BarDefinition

func (*BarDefinition) Add

func (d *BarDefinition) Add(c Container) (Bar, error)

func (*BarDefinition) AddWithTotal

func (d *BarDefinition) AddWithTotal(c Container, total int) (Bar, error)

func (*BarDefinition) Dup

func (d *BarDefinition) Dup() *BarDefinition

func (*BarDefinition) GetGroupNotifier

func (d *BarDefinition) GetGroupNotifier() specs.GroupNotifier

type Brackets

type Brackets = specs.Brackets

type Container

type Container = types.Container

type Context

type Context interface {
	Container

	// GetTTYContext returns the underlying ttycolors.TTYContext.
	GetTTYContext() ttycolors.TTYContext

	IsColorsEnabled() bool
	EnableColors(b ...bool) Context

	// Blocks returns the underlying
	// blocks.Blocks object used
	// to display the progress elements.
	// It can directly be used in combination
	// with progress elements.
	// But all active blocks will prohibit the
	// progress object to complete.
	Blocks() *blocks.Blocks

	// Done returns the done channel.
	// A Context is done, if it is closed and
	// all progress elements are finished.
	Done() <-chan struct{}

	// Close closes the Context. No more
	// progress elements can be added anymore.
	Close() error

	// Wait until the Context is Done.
	// If a context.Context is given, Wait
	// also returns if the context is canceled.
	Wait(ctx context.Context) error
}

Context is a set of lines on a terminal used to display some live progress information. It can be used to display an arbitrary number of progress elements, which are independently. Leading elements will leave the text window used once they are finished.

func For

func For(opt ...io.Writer) Context

For creates a new Context, which manages a terminal line range used to indicate progress of some actions. This line range is always at the end of the given writer, which must refer to a terminal device. Context indicators are added by explicitly calling the appropriate constructors. They take the Context they should be attached to as first argument.

type DecoratorFunc

type DecoratorFunc = types.DecoratorFunc

DecoratorFunc is a function that can be prepended and appended to the progress bar

func Amount

func Amount(unit ...units.Unit) DecoratorFunc

Amount is a decorator for Bar elements providing information about the current and total amount for the progress.

func Message

func Message(m ...any) DecoratorFunc

Message is a decorator for progress elements providing a static message.

func Processed

func Processed(unit ...units.Unit) DecoratorFunc

Processed is a decorator for Bar objects providing information about the current progress value (int).

type Dupper

type Dupper[T any] interface {
	Dup() T
}

func TypeFor

func TypeFor[T Dupper[T]](d T) Dupper[T]

TypeFor provides a new progress indicator for a preconfigured archetype, A new configuration can be created with New. It is preconfigured according to the initial configuration and can be refined, furthermore.

type Element

type Element = types.Element

type ElementDefinition

type ElementDefinition[T Element] interface {
	types.ElementDefinition[T]
}

func GenericDefinition

func GenericDefinition[T ElementDefinition[E], E Element](d T) ElementDefinition[Element]

GenericDefinition converts a specific progress indicator definition into a generic one (providing just an Element instead of the specific type).

type ElementSpecification

type ElementSpecification[T Element] interface {
	specs.ElementSpecification[T]
}

type ElementState

type ElementState = types.ElementState

type Estimated

type Estimated interface {
	specs.EstimatedInterface
}

type EstimatedDefinition

type EstimatedDefinition struct {
	specs.EstimatedDefinition[*EstimatedDefinition]
}

func NewEstimated

func NewEstimated(total time.Duration) *EstimatedDefinition

func (*EstimatedDefinition) Add

func (*EstimatedDefinition) Dup

type EstimatedInterface

type EstimatedInterface = specs.EstimatedInterface

type Group

type Group interface {
	Container

	Gap() string

	ppi.ProgressInterface
}

type GroupDefinition

type GroupDefinition[E specs.ProgressInterface] struct {
	specs.GroupDefinition[*GroupDefinition[E], E]
}

func (*GroupDefinition[E]) Add

func (d *GroupDefinition[E]) Add(c Container) (Group, error)

func (*GroupDefinition[E]) Dup

func (d *GroupDefinition[E]) Dup() *GroupDefinition[E]

type IntBarBase

type IntBarBase[T IntBarImpl] struct {
	*ppi.BarBase[T, int]
	// contains filtered or unexported fields
}

func (*IntBarBase[T]) CompletedPercent

func (b *IntBarBase[T]) CompletedPercent() float64

func (*IntBarBase[T]) Current

func (b *IntBarBase[T]) Current() int

func (*IntBarBase[T]) Incr

func (b *IntBarBase[T]) Incr() bool

func (*IntBarBase[T]) Set

func (b *IntBarBase[T]) Set(n int) bool

type IntBarBaseImpl

type IntBarBaseImpl[T IntBarImpl] struct {
	*ppi.BarBaseImpl[T, int]
	// contains filtered or unexported fields
}

func (*IntBarBaseImpl[T]) CompletedPercent

func (b *IntBarBaseImpl[T]) CompletedPercent() float64

CompletedPercent return the percent completed

func (*IntBarBaseImpl[T]) Current

func (b *IntBarBaseImpl[T]) Current() int

Current returns the current progress of the bar

func (*IntBarBaseImpl[T]) Incr

func (b *IntBarBaseImpl[T]) Incr() bool

Incr increments the current value by 1, time elapsed to current time and returns true. It returns false if the cursor has reached or exceeds total value.

func (*IntBarBaseImpl[T]) IsFinished

func (b *IntBarBaseImpl[T]) IsFinished() bool

func (*IntBarBaseImpl[T]) Set

func (b *IntBarBaseImpl[T]) Set(n int) bool

Set the current count of the bar. It returns ErrMaxCurrentReached when trying n exceeds the total value. This is atomic operation and concurrency safe.

type IntBarImpl

type IntBarImpl interface {
	ppi.BarImpl[int]
	IntBarInterface
}

type IntBarInterface

type IntBarInterface interface {
	ppi.BarInterface[int]
	Current() int
	CompletedPercent() float64
	Set(n int) bool
	Incr() bool
}

type LineBar

type LineBar interface {
	specs.BarInterface
}

LineBar is a progress bar used to visualize the progress of an action in relation to a known maximum of required work reversing the progress line according to the actual progress.

type LineBarDefinition

type LineBarDefinition struct {
	specs.LineBarDefinition[*LineBarDefinition, int]
}

func NewLineBar

func NewLineBar() *LineBarDefinition

func (*LineBarDefinition) Add

func (*LineBarDefinition) Dup

func (*LineBarDefinition) GetGroupNotifier

func (d *LineBarDefinition) GetGroupNotifier() specs.GroupNotifier

type NestedStep

type NestedStep = specs.NestedStep

func NewNestedStep

func NewNestedStep[T Element](name string, definition ElementDefinition[T]) NestedStep

type NestedSteps

type NestedSteps interface {
	specs.NestedStepsInterface
}

NestedSteps can be used to visualize a sequence of steps represented by own progress indicators.

type NestedStepsDefinition

type NestedStepsDefinition struct {
	specs.NestedStepsDefinition[*NestedStepsDefinition]
}

func NewNestedSteps

func NewNestedSteps(steps ...specs.NestedStep) *NestedStepsDefinition

func (*NestedStepsDefinition) Add

func (*NestedStepsDefinition) Dup

type ProgressElement

type ProgressElement = types.ProgressElement

type ScrollingSpinner

type ScrollingSpinner interface {
	specs.ScrollingSpinnerInterface
}

ScrollingScrollingSpinner is a progress indicator without information about the concrete progress using a scrolling text to indicate the progress.

type ScrollingSpinnerDefinition

type ScrollingSpinnerDefinition struct {
	specs.ScrollingSpinnerDefinition[*ScrollingSpinnerDefinition]
}

func NewScrollingSpinner

func NewScrollingSpinner(text string, length int) *ScrollingSpinnerDefinition

func (*ScrollingSpinnerDefinition) Add

func (*ScrollingSpinnerDefinition) Dup

func (*ScrollingSpinnerDefinition) GetGroupNotifier

func (d *ScrollingSpinnerDefinition) GetGroupNotifier() specs.GroupNotifier

type Spinner

type Spinner interface {
	specs.SpinnerInterface
}

Spinner is a progress indicator without information about the concrete progress.

type SpinnerDefinition

type SpinnerDefinition struct {
	specs.SpinnerDefinition[*SpinnerDefinition]
}

func NewSpinner

func NewSpinner(set ...int) *SpinnerDefinition

func (*SpinnerDefinition) Add

func (*SpinnerDefinition) Dup

func (*SpinnerDefinition) GetGroupNotifier

func (d *SpinnerDefinition) GetGroupNotifier() specs.GroupNotifier

type Steps

type Steps interface {
	specs.StepsInterface
}

Steps can be used to visualize a sequence of steps.

type StepsDefinition

type StepsDefinition struct {
	specs.StepsDefinition[*StepsDefinition]
}

func NewSteps

func NewSteps(steps ...string) *StepsDefinition

func (*StepsDefinition) Add

func (d *StepsDefinition) Add(c Container) (Steps, error)

func (*StepsDefinition) Dup

func (d *StepsDefinition) Dup() *StepsDefinition

type Text

type Text interface {
	specs.TextInterface
}

Text provides a range of lines of output until the action described by the element is calling Text.Close. The element can be used as writer to pass the intended output. After the writer is closed, the complete output is shown after earlier elements and outer containers are done.

type TextDefinition

type TextDefinition struct {
	specs.TextDefinition[*TextDefinition]
}

func NewText

func NewText(v ...int) *TextDefinition

func (*TextDefinition) Add

func (d *TextDefinition) Add(c Container) (Text, error)

func (*TextDefinition) Dup

func (d *TextDefinition) Dup() *TextDefinition

type TextSpinner

type TextSpinner interface {
	specs.TextSpinnerInterface
}

type TextSpinnerDefinition

type TextSpinnerDefinition struct {
	specs.TextSpinnerDefinition[*TextSpinnerDefinition]
}

func NewTextSpinner

func NewTextSpinner(set ...int) *TextSpinnerDefinition

func (*TextSpinnerDefinition) Add

func (*TextSpinnerDefinition) Dup

type Ticker

type Ticker = types.Ticker

Directories

Path Synopsis
examples
blocks/hide command
blocks/mixed command
blocks/scroll command
blocks/simple command
progress/bar command
progress/bar2 command
progress/colors command
progress/def command
progress/group command
progress/group2 command
progress/multi command
progress/steps command
progress/text command
progress/text0 command

Jump to

Keyboard shortcuts

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