specs

package
v0.0.0-...-1f3d1d0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const Tick = time.Millisecond * 20

Variables

View Source
var (
	BracketTypes = map[int]Brackets{
		0: {'[', ']'},
		1: {'〚', '〛'},
		2: {'【', '】'},
		3: {'〖', '〗'},

		10: {'{', '}'},
		11: {'⦃', '⦄'},

		20: {'(', ')'},
		21: {'⦅', '⦆'},
		22: {'⦅', '⦆'},

		30: {'<', '>'},
		31: {'❮', '❯'},
		32: {'〈', '〉'},
		33: {'《', '》'},

		40: {'〔', '〕'},
		41: {'〘', '〙'},
		42: {'﹝', '﹞'},
		43: {'⦗', '⦘'},

		50: {'|', '|'},
		51: {'▏', '▏'},
		52: {'▐', '▌'},
	}

	// BarTypes describes predefined Bar configurations identified
	// by an integer.
	BarTypes = map[int]BarConfig{
		0: {
			Fill:     '=',
			Head:     '>',
			Empty:    '-',
			LeftEnd:  '[',
			RightEnd: ']',
		},
		1: {
			Fill: '═',
			Head: '▷',

			Empty:    '·',
			LeftEnd:  '▕',
			RightEnd: '▏',
		},
		2: {
			Fill:     '▬',
			Head:     '▶',
			Empty:    '┄',
			LeftEnd:  '▐',
			RightEnd: '▌',
		},

		10: {
			Fill:     '▒',
			Head:     '░',
			Empty:    '░',
			LeftEnd:  '▕',
			RightEnd: '▏',
		},
		11: {
			Fill:     '▓',
			Head:     '▒',
			Empty:    '▒',
			LeftEnd:  '▕',
			RightEnd: '▏',
		},
		12: {
			Fill:     '█',
			Head:     '▒',
			Empty:    '▒',
			LeftEnd:  '▕',
			RightEnd: '▏',
		},
	}
)
View Source
var (
	Done             = "done"
	Pending          = "pending"
	BarWidth         = uint(10)
	BarType          = 0
	SpinnerSpeed     = 2
	SpinnerType      = 9
	TextView         = 3
	GroupGap         = "- "
	GroupFollowUpGap = "  "
)
View Source
var SpinnerTypes = maps.Clone(spinner.CharSets)

SpinnerTypes predefined spinner types. Most of them are taken from spinner.CharSets (github.com/briandowns/spinner).

Functions

func AppendFunc

func AppendFunc[T ElementInterface](d types.ElementDefinition[T], f DecoratorFunc, offset ...int) bool

func PercentString

func PercentString(p float64) string

PercentString returns the formatted string representation of the percent value.

func PrependFunc

func PrependFunc[T ElementInterface](d types.ElementDefinition[T], f DecoratorFunc, offset ...int) bool

func PrettyTime

func PrettyTime(t time.Duration) string

func String

func String(s string) ttycolors.String

func TransferBarBaseConfig

func TransferBarBaseConfig[D BarBaseSpecification[T], T any](d D, c BarBaseConfiguration) D

func TransferElementConfig

func TransferElementConfig[D ElementSpecification[T], T any](d D, c ElementConfiguration) D

func TransferProgressConfig

func TransferProgressConfig[D ProgressSpecification[T], T any](d D, c ProgressConfiguration) D

Types

type Appender

type Appender interface {
	AppendFunc2(f DecoratorFunc, offset ...int)
	AppendDecorator2(f DecoratorDefinition, offset ...int)
}

type BarBaseConfiguration

type BarBaseConfiguration interface {
	ProgressConfiguration
	GetConfig() BarConfig
	GetWidth() uint
	GetPending() string
}

type BarBaseDefinition

type BarBaseDefinition[T any] struct {
	ProgressDefinition[T]
	// contains filtered or unexported fields
}

func NewBarBaseDefinition

func NewBarBaseDefinition[T any](self Self[T]) BarBaseDefinition[T]

NewBarBaseDefinition can be used to create a nested definition for a derived bar definition.

func (*BarBaseDefinition[T]) AppendCompleted

func (d *BarBaseDefinition[T]) AppendCompleted(offset ...int) T

AppendCompleted appends the completion percent to the progress bar

func (*BarBaseDefinition[T]) Dup

func (d *BarBaseDefinition[T]) Dup(s Self[T]) BarBaseDefinition[T]

func (*BarBaseDefinition[T]) GetConfig

func (d *BarBaseDefinition[T]) GetConfig() BarConfig

func (*BarBaseDefinition[T]) GetPending

func (d *BarBaseDefinition[T]) GetPending() string

func (*BarBaseDefinition[T]) GetWidth

func (d *BarBaseDefinition[T]) GetWidth() uint

func (*BarBaseDefinition[T]) PrependCompleted

func (d *BarBaseDefinition[T]) PrependCompleted(offset ...int) T

PrependCompleted prepends the percent completed to the progress bar

func (*BarBaseDefinition[T]) SetBracketType

func (d *BarBaseDefinition[T]) SetBracketType(i int) T

func (*BarBaseDefinition[T]) SetBrackets

func (d *BarBaseDefinition[T]) SetBrackets(c Brackets) T

func (*BarBaseDefinition[T]) SetConfig

func (d *BarBaseDefinition[T]) SetConfig(c BarConfig) T

func (*BarBaseDefinition[T]) SetEmpty

func (d *BarBaseDefinition[T]) SetEmpty(c rune) T

func (*BarBaseDefinition[T]) SetFill

func (d *BarBaseDefinition[T]) SetFill(c rune) T

func (*BarBaseDefinition[T]) SetHead

func (d *BarBaseDefinition[T]) SetHead(c rune) T

func (*BarBaseDefinition[T]) SetLeftEnd

func (d *BarBaseDefinition[T]) SetLeftEnd(c rune) T

func (*BarBaseDefinition[T]) SetPending

func (d *BarBaseDefinition[T]) SetPending(m string) T

func (*BarBaseDefinition[T]) SetPredefined

func (d *BarBaseDefinition[T]) SetPredefined(i int) T

func (*BarBaseDefinition[T]) SetRightEnd

func (d *BarBaseDefinition[T]) SetRightEnd(c rune) T

func (*BarBaseDefinition[T]) SetWidth

func (d *BarBaseDefinition[T]) SetWidth(w uint) T

type BarBaseInterface

type BarBaseInterface[V any] interface {
	ProgressInterface
	CompletedPercent
	Current() V
}

type BarBaseSpecification

type BarBaseSpecification[T any] interface {
	ProgressSpecification[T]
	AppendCompleted(offset ...int) T
	PrependCompleted(offset ...int) T

	SetPending(m string) T
	SetWidth(w uint) T
	SetConfig(c BarConfig) T
	SetPredefined(i int) T
	SetBrackets(c Brackets) T
	SetBracketType(i int) T
	SetHead(c rune) T
	SetEmpty(c rune) T
	SetFill(c rune) T
	SetLeftEnd(c rune) T
	SetRightEnd(c rune) T
}

type BarConfig

type BarConfig struct {
	// Fill is the default character representing completed progress
	Fill rune
	// Head is the default character that moves when progress is updated
	Head rune
	// Empty is the default character that represents the empty progress
	Empty rune
	// LeftEnd is the default character in the left most part of the progress indicator
	LeftEnd rune
	// RightEnd is the default character in the right most part of the progress indicator
	RightEnd rune
}

func (BarConfig) SetBracketType

func (c BarConfig) SetBracketType(i int) BarConfig

func (BarConfig) SetBrackets

func (c BarConfig) SetBrackets(b Brackets) BarConfig

type BarConfiguration

type BarConfiguration[T any] interface {
	BarBaseConfiguration
	GetTotal() int
}

type BarDefinition

type BarDefinition[T any] struct {
	BarBaseDefinition[T]
	// contains filtered or unexported fields
}

func NewBarDefinition

func NewBarDefinition[T any](s Self[T]) BarDefinition[T]

NewBarDefinition can be used to create a nested definition for a derived bar definition.

func (*BarDefinition[T]) Dup

func (d *BarDefinition[T]) Dup(s Self[T]) BarDefinition[T]

func (*BarDefinition[T]) GetTotal

func (d *BarDefinition[T]) GetTotal() int

func (*BarDefinition[T]) SetTotal

func (d *BarDefinition[T]) SetTotal(v int) T

type BarInterface

type BarInterface interface {
	BarBaseInterface[int]
	SetTotal(m int)

	Set(n int) bool
	Incr() bool
}

type BarSpecification

type BarSpecification[T any] interface {
	BarBaseSpecification[T]

	SetTotal(v int) T
}

type Brackets

type Brackets struct {
	// LeftEnd is the default character in the left most part of the progress indicator
	LeftEnd rune
	// RightEnd is the default character in the right most part of the progress indicator
	RightEnd rune
}

func (Brackets) Swap

func (b Brackets) Swap() Brackets

type CompletedPercent

type CompletedPercent interface {
	CompletedPercent() float64
}

type Container

type Container = types.Container

type Cycle

type Cycle[T any] struct {
	// contains filtered or unexported fields
}

func NewCycle

func NewCycle[T any](elems []T) *Cycle[T]

func (*Cycle[T]) Get

func (s *Cycle[T]) Get() T

func (*Cycle[T]) Incr

func (s *Cycle[T]) Incr()

type DecoratorDefinition

type DecoratorDefinition interface {
	CreateDecorator(e ElementState) types.Decorator
}

func ScrollingText

func ScrollingText(text string, length int) DecoratorDefinition

ScrollingText provides a scrolling text decorator. Scrolling is only done, if the text is longer than the specified text size. Otherwise, static padded text is shown.

type DecoratorFunc

type DecoratorFunc = types.DecoratorFunc

func Message

func Message(m string) DecoratorFunc

Message provides a DecoratorFunc for a simple text message.

func Variable

func Variable(name string) DecoratorFunc

Variable provides a DecoratorFunc for a variable of a progress indicator.

type ElementConfiguration

type ElementConfiguration interface {
	// GetFinal gets a text message shown instead of the
	// text window after the action has been finished.
	GetFinal() string
	GetHideOnClose() bool
	GetHide() bool
}

type ElementDefinition

type ElementDefinition[T any] struct {
	// contains filtered or unexported fields
}

func NewElementDefinition

func NewElementDefinition[T any](self Self[T]) ElementDefinition[T]

func (*ElementDefinition[T]) Dup

func (d *ElementDefinition[T]) Dup(s Self[T]) ElementDefinition[T]

func (*ElementDefinition[T]) GetFinal

func (e *ElementDefinition[T]) GetFinal() string

func (*ElementDefinition[T]) GetHide

func (e *ElementDefinition[T]) GetHide() bool

func (*ElementDefinition[T]) GetHideOnClose

func (e *ElementDefinition[T]) GetHideOnClose() bool

func (*ElementDefinition[T]) Hide

func (e *ElementDefinition[T]) Hide(b ...bool) T

func (*ElementDefinition[T]) HideOnClose

func (e *ElementDefinition[T]) HideOnClose(b ...bool) T

func (*ElementDefinition[T]) Self

func (d *ElementDefinition[T]) Self() T

func (*ElementDefinition[T]) SetFinal

func (e *ElementDefinition[T]) SetFinal(m string) T

type ElementInterface

type ElementInterface = types.Element

ElementInterface is the common interface of all elements provided by the ttyprogress package

type ElementSpecification

type ElementSpecification[T any] interface {
	// SetFinal sets a text message shown instead of the
	// text window after the action has been finished.
	SetFinal(string) T
	// HideOnClose will request to hide the element
	// when it is closed.
	HideOnClose(...bool) T

	// Hide will request to initially hide the element.
	Hide(...bool) T
}

type ElementState

type ElementState = types.ElementState

type EstimatedConfiguration

type EstimatedConfiguration interface {
	BarBaseConfiguration
	GetTotal() time.Duration
}

type EstimatedDefinition

type EstimatedDefinition[T any] struct {
	BarBaseDefinition[T]
	// contains filtered or unexported fields
}

func NewEstimatedDefinition

func NewEstimatedDefinition[T any](self Self[T], total time.Duration) EstimatedDefinition[T]

NewEstimatedDefinition can be used to create a nested definition for a derived bar definition.

func (*EstimatedDefinition[T]) AppendEstimated

func (d *EstimatedDefinition[T]) AppendEstimated(offset ...int) T

AppendEstimated appends the time elapsed to the beginning of the bar

func (*EstimatedDefinition[T]) Dup

func (d *EstimatedDefinition[T]) Dup(s Self[T]) EstimatedDefinition[T]

func (*EstimatedDefinition[T]) GetTotal

func (d *EstimatedDefinition[T]) GetTotal() time.Duration

func (*EstimatedDefinition[T]) PrependEstimated

func (d *EstimatedDefinition[T]) PrependEstimated(offset ...int) T

PrependEstimated prepends the time elapsed to the beginning of the bar

func (*EstimatedDefinition[T]) SetTotal

func (d *EstimatedDefinition[T]) SetTotal(v time.Duration) T

type EstimatedInterface

type EstimatedInterface interface {
	BarBaseInterface[time.Duration]

	Total() time.Duration
	TimeEstimated() time.Duration

	IsFinished() bool
	Set(n time.Duration) bool
}

type EstimatedSpecification

type EstimatedSpecification[T any] interface {
	BarBaseSpecification[T]
	SetTotal(v time.Duration) T
}

type FollowupGapProvider

type FollowupGapProvider interface {
	GetFollowUpGap() string
}

FollowupGapProvider is the optional interface to provide an indent for additional lines enriching the element configuration.

type GapProvider

type GapProvider interface {
	GetGap() string
}

GapProvider is the optional interface to provide an indent enriching the element configuration.

type GroupBaseConfiguration

type GroupBaseConfiguration interface {
	GetFollowUpGap() string
	GetGap() string
	IsHideOnClose() bool
}

type GroupBaseDefinition

type GroupBaseDefinition[T any] struct {
	// contains filtered or unexported fields
}

func NewGroupBaseDefinition

func NewGroupBaseDefinition[T any](self Self[T]) GroupBaseDefinition[T]

NewGroupBaseDefinition can be used to create a nested definition for a derived group definition.

func (*GroupBaseDefinition[T]) Dup

func (d *GroupBaseDefinition[T]) Dup(s Self[T]) GroupBaseDefinition[T]

func (*GroupBaseDefinition[T]) GetFollowUpGap

func (d *GroupBaseDefinition[T]) GetFollowUpGap() string

func (*GroupBaseDefinition[T]) GetGap

func (d *GroupBaseDefinition[T]) GetGap() string

func (*GroupBaseDefinition[T]) HideOnClose

func (d *GroupBaseDefinition[T]) HideOnClose(b ...bool) T

func (*GroupBaseDefinition[T]) IsHideOnClose

func (d *GroupBaseDefinition[T]) IsHideOnClose() bool

func (*GroupBaseDefinition[T]) SetFollowUpGap

func (d *GroupBaseDefinition[T]) SetFollowUpGap(gap string) T

func (*GroupBaseDefinition[T]) SetGap

func (d *GroupBaseDefinition[T]) SetGap(gap string) T

type GroupBaseInterface

type GroupBaseInterface interface {
	Container
	HideOnClose(b ...bool)
	Hide(b ...bool)
}

type GroupBaseSpecification

type GroupBaseSpecification[T any] interface {
	SetGap(string) T
	SetFollowUpGap(string) T
	HideOnClose(b ...bool) T
}

type GroupConfiguration

type GroupConfiguration[E ProgressInterface] interface {
	GroupBaseConfiguration

	// GetProgress provides the main group progress indicator.
	GetProgress() GroupProgressElementDefinition[E]
}

type GroupDefinition

type GroupDefinition[T any, E ProgressInterface] struct {
	GroupBaseDefinition[T]
	// contains filtered or unexported fields
}

func NewGroupDefinition

func NewGroupDefinition[T any, E ProgressInterface](s Self[T], main GroupProgressElementDefinition[E]) *GroupDefinition[T, E]

func (*GroupDefinition[T, E]) Dup

func (d *GroupDefinition[T, E]) Dup(s Self[T]) GroupDefinition[T, E]

func (*GroupDefinition[T, E]) GetProgress

func (d *GroupDefinition[T, E]) GetProgress() GroupProgressElementDefinition[E]

type GroupInterface

type GroupInterface interface {
	Container
	ElementInterface
}

type GroupNotifier

type GroupNotifier interface {
	Add(e ProgressInterface, o any)
	Done(e ProgressInterface, o any)
}

GroupNotifier is used to propagate group changes to the main group progress indicator.

type GroupProgressElementDefinition

type GroupProgressElementDefinition[E ProgressInterface] interface {
	types.ElementDefinition[E]
	GetGroupNotifier() GroupNotifier
}

GroupProgressElementDefinition the interface for a progress indicator definition to be usable for a main group progress indicator.

type GroupSpecification

type GroupSpecification[T any] interface {
	GroupBaseSpecification[T]
}

type LineBarConfiguration

type LineBarConfiguration[T any] interface {
	ProgressConfiguration
	IsResetOnFinished() bool
	GetPending() string
	GetTotal() T
}

type LineBarDefinition

type LineBarDefinition[T, V any] struct {
	ProgressDefinition[T]
	// contains filtered or unexported fields
}

func NewLineBarDefinition

func NewLineBarDefinition[T, V any](s Self[T], total V) LineBarDefinition[T, V]

NewLineBarDefinition can be used to create a nested definition for a derived line bar definition.

func (*LineBarDefinition[T, V]) AppendCompleted

func (d *LineBarDefinition[T, V]) AppendCompleted(offset ...int) T

AppendCompleted appends the completion percent to the progress bar

func (*LineBarDefinition[T, V]) Dup

func (d *LineBarDefinition[T, V]) Dup(s Self[T]) LineBarDefinition[T, V]

func (*LineBarDefinition[T, V]) GetPending

func (d *LineBarDefinition[T, V]) GetPending() string

func (*LineBarDefinition[T, V]) GetTotal

func (d *LineBarDefinition[T, V]) GetTotal() V

func (*LineBarDefinition[T, V]) IsResetOnFinished

func (d *LineBarDefinition[T, V]) IsResetOnFinished() bool

func (*LineBarDefinition[T, V]) PrependCompleted

func (d *LineBarDefinition[T, V]) PrependCompleted(offset ...int) T

PrependCompleted prepends the percent completed to the progress bar

func (*LineBarDefinition[T, V]) ResetOnFinished

func (d *LineBarDefinition[T, V]) ResetOnFinished(b ...bool) T

func (*LineBarDefinition[T, V]) SetPending

func (d *LineBarDefinition[T, V]) SetPending(v string) T

func (*LineBarDefinition[T, V]) SetTotal

func (d *LineBarDefinition[T, V]) SetTotal(v V) T

type LineBarInterface

type LineBarInterface interface {
	BarBaseInterface[int]
	SetTotal(m int)

	Set(n int) bool
	Incr() bool
}

type LineBarSpecification

type LineBarSpecification[T, V any] interface {
	ProgressSpecification[T]
	AppendCompleted(offset ...int) T
	PrependCompleted(offset ...int) T
	ResetOnFinished(b ...bool) T
	SetPending(m string) T
	SetTotal(v V) T
}

type NestedStep

type NestedStep struct {
	// contains filtered or unexported fields
}

func NewNestedStep

func NewNestedStep[T ElementInterface](name string, def types.ElementDefinition[T]) NestedStep

func (*NestedStep) Definition

func (*NestedStep) Name

func (n *NestedStep) Name() string

type NestedStepsConfiguration

type NestedStepsConfiguration interface {
	GroupBaseConfiguration
	BarBaseConfiguration
	GetSteps() []NestedStep
	IsShowStepTitle() bool
}

type NestedStepsDefinition

type NestedStepsDefinition[T any] struct {
	BarBaseDefinition[T]
	GroupBaseDefinition[T]
	// contains filtered or unexported fields
}

func NewNestedStepsDefinition

func NewNestedStepsDefinition[T any](self Self[T], steps []NestedStep) NestedStepsDefinition[T]

NewNestedStepsDefinition can be used to create a nested definition for a derived steps definition.

func (*NestedStepsDefinition[T]) Dup

func (*NestedStepsDefinition[T]) GetSteps

func (d *NestedStepsDefinition[T]) GetSteps() []NestedStep

func (*NestedStepsDefinition[T]) GetTotal

func (d *NestedStepsDefinition[T]) GetTotal() int

func (*NestedStepsDefinition[T]) IsShowStepTitle

func (d *NestedStepsDefinition[T]) IsShowStepTitle() bool

func (*NestedStepsDefinition[T]) SetSteps

func (d *NestedStepsDefinition[T]) SetSteps(steps []NestedStep) T

func (*NestedStepsDefinition[T]) ShowStepTitle

func (d *NestedStepsDefinition[T]) ShowStepTitle(b ...bool) T

type NestedStepsInterface

type NestedStepsInterface interface {
	ProgressInterface
	Incr() (ElementInterface, error)
	Current() ElementInterface
}

type NestedStepsSpecification

type NestedStepsSpecification[T any] interface {
	BarBaseSpecification[T]
	GroupBaseSpecification[T]
	SetSteps(steps []NestedStep) T
	ShowStepTitle(b ...bool) T
}

type Phases

type Phases interface {
	Incr()
	Get() ttycolors.String
}

func NewFormatPhases

func NewFormatPhases(s string, fmts ...ttycolors.FormatProvider) Phases

NewFormatPhases creates Phases using the same text with a sequence of formats.

func NewNestedFormatPhases

func NewNestedFormatPhases(p Phases, fmts ...ttycolors.FormatProvider) Phases

NewNestedFormatPhases creates phases based on a combination of bases phases formatted by a sequence of output formats. The number of phases for both parts may be different.

func NewStaticFormattedPhases

func NewStaticFormattedPhases(phases ...ttycolors.String) Phases

func NewStaticPhases

func NewStaticPhases(phases ...string) Phases

type Prepender

type Prepender interface {
	PrependFunc2(f DecoratorFunc, offset ...int)
	PrependDecorator2(f DecoratorDefinition, offset ...int)
}

type ProgressConfiguration

type ProgressConfiguration interface {
	ElementConfiguration
	GetTick() bool
	IsAutoClose() bool

	GetColor() ttycolors.Format
	GetProgressColor() ttycolors.Format
	GetPrependDecorators() []DecoratorDefinition
	GetAppendDecorators() []DecoratorDefinition
	GetMinVisualizationColumn() int
}

ProgressConfiguration provides access to the generic Progress configuration

type ProgressDefinition

type ProgressDefinition[T any] struct {
	ElementDefinition[T]
	// contains filtered or unexported fields
}

func NewProgressDefinition

func NewProgressDefinition[T any](self Self[T]) ProgressDefinition[T]

func (*ProgressDefinition[T]) AppendDecorator

func (d *ProgressDefinition[T]) AppendDecorator(def DecoratorDefinition, offset ...int) T

AppendDecorator runs the decorator and renders the output on the right of the progress indicator

func (*ProgressDefinition[T]) AppendDecorator2

func (d *ProgressDefinition[T]) AppendDecorator2(def DecoratorDefinition, offset ...int)

AppendDecorator2 runs the decorator and renders the output on the right of the progress indicator

func (*ProgressDefinition[T]) AppendElapsed

func (d *ProgressDefinition[T]) AppendElapsed(offset ...int) T

AppendElapsed appends the time elapsed to the progress indicator

func (*ProgressDefinition[T]) AppendFunc

func (d *ProgressDefinition[T]) AppendFunc(f DecoratorFunc, offset ...int) T

AppendFunc runs the decorator function and renders the output on the right of the progress indicator

func (*ProgressDefinition[T]) AppendFunc2

func (d *ProgressDefinition[T]) AppendFunc2(f DecoratorFunc, offset ...int)

AppendFunc2 runs the decorator function and renders the output on the right of the progress indicator

func (*ProgressDefinition[T]) AppendMessage

func (d *ProgressDefinition[T]) AppendMessage(m string, offset ...int) T

AppendMessage appends text to the progress indicator

func (*ProgressDefinition[T]) AppendVariable

func (d *ProgressDefinition[T]) AppendVariable(m string, offset ...int) T

AppendMVariable appends text to the progress indicator

func (*ProgressDefinition[T]) Dup

func (d *ProgressDefinition[T]) Dup(s Self[T]) ProgressDefinition[T]

func (*ProgressDefinition[T]) GetAppendDecorators

func (d *ProgressDefinition[T]) GetAppendDecorators() []DecoratorDefinition

func (*ProgressDefinition[T]) GetColor

func (d *ProgressDefinition[T]) GetColor() ttycolors.Format

func (*ProgressDefinition[T]) GetMinVisualizationColumn

func (d *ProgressDefinition[T]) GetMinVisualizationColumn() int

func (*ProgressDefinition[T]) GetPrependDecorators

func (d *ProgressDefinition[T]) GetPrependDecorators() []DecoratorDefinition

func (*ProgressDefinition[T]) GetProgressColor

func (d *ProgressDefinition[T]) GetProgressColor() ttycolors.Format

func (*ProgressDefinition[T]) GetTick

func (d *ProgressDefinition[T]) GetTick() bool

GetTick returns whether a tick is required.

func (*ProgressDefinition[T]) IsAutoClose

func (d *ProgressDefinition[T]) IsAutoClose() bool

func (*ProgressDefinition[T]) PrependDecorator

func (d *ProgressDefinition[T]) PrependDecorator(def DecoratorDefinition, offset ...int) T

PrependDefinition runs the decorator and renders the output on the right of the progress indicator

func (*ProgressDefinition[T]) PrependDecorator2

func (d *ProgressDefinition[T]) PrependDecorator2(def DecoratorDefinition, offset ...int)

PrependDefinition2 runs the decorator and renders the output on the right of the progress indicator

func (*ProgressDefinition[T]) PrependElapsed

func (d *ProgressDefinition[T]) PrependElapsed(offset ...int) T

PrependElapsed prepends the time elapsed to the beginning of the indicator

func (*ProgressDefinition[T]) PrependFunc

func (d *ProgressDefinition[T]) PrependFunc(f DecoratorFunc, offset ...int) T

PrependFunc runs decorator function and render the output left the progress indicator

func (*ProgressDefinition[T]) PrependFunc2

func (d *ProgressDefinition[T]) PrependFunc2(f DecoratorFunc, offset ...int)

PrependFunc2 runs decorator function and render the output left the progress indicator

func (*ProgressDefinition[T]) PrependMessage

func (d *ProgressDefinition[T]) PrependMessage(m string, offset ...int) T

PrependMessage prepends text to the beginning of the indicator

func (*ProgressDefinition[T]) PrependVariable

func (d *ProgressDefinition[T]) PrependVariable(m string, offset ...int) T

PrependVariable prepends text to the beginning of the indicator

func (*ProgressDefinition[T]) SetAutoClose

func (d *ProgressDefinition[T]) SetAutoClose(b ...bool) T

func (*ProgressDefinition[T]) SetColor

func (d *ProgressDefinition[T]) SetColor(f ...ttycolors.FormatProvider) T

SetColor sets the output format for the progress indicator line

func (*ProgressDefinition[T]) SetDecoratorFormat

func (d *ProgressDefinition[T]) SetDecoratorFormat(f ...ttycolors.FormatProvider) T

SetDecoratorFormat sets the output format for the next decorator.

func (*ProgressDefinition[T]) SetMinVisualizationColumn

func (d *ProgressDefinition[T]) SetMinVisualizationColumn(c int) T

func (*ProgressDefinition[T]) SetProgressColor

func (d *ProgressDefinition[T]) SetProgressColor(f ...ttycolors.FormatProvider) T

SetProgressColor sets the output format for the progress indicator.

type ProgressInterface

type ProgressInterface = types.ProgressElement

type ProgressSpecification

type ProgressSpecification[T any] interface {
	ElementSpecification[T]

	// SetAutoClose enables/disabled automatic closeing
	// the element when Update indicates finished.
	SetAutoClose(b ...bool) T

	// SetColor set the color used for the progress line.
	SetColor(col ...ttycolors.FormatProvider) T

	// SetProgressColor set the color used for the progress visualization.
	SetProgressColor(col ...ttycolors.FormatProvider) T

	// SetDecoratorFormat set the output format for the next decorator.
	SetDecoratorFormat(col ...ttycolors.FormatProvider) T

	// SetMinVisualizationColumn sets the minimal column for the visualization,
	SetMinVisualizationColumn(int) T

	// AppendFunc adds a function providing some text appended
	// to the basic progress indicator.
	// If there are implicit settings, the offset can be used to
	// specify the index in the list of functions.
	AppendFunc(f DecoratorFunc, offset ...int) T

	// PrependFunc adds a function providing some text prepended
	// to the basic progress indicator.
	// If there are implicit settings, the offset can be used to
	// specify the index in the list of functions.
	PrependFunc(f DecoratorFunc, offset ...int) T

	// AppendDecorator adds a definition providing some text appended
	// to the basic progress indicator.
	// If there are implicit settings, the offset can be used to
	// specify the index in the list of functions.
	AppendDecorator(f DecoratorDefinition, offset ...int) T

	// PrependDecorator adds a definition providing some text prepended
	// to the basic progress indicator.
	// If there are implicit settings, the offset can be used to
	// specify the index in the list of functions.
	PrependDecorator(f DecoratorDefinition, offset ...int) T

	// AppendElapsed appends the elapsed time of the action
	// or the duration of the action if the element is already closed.
	AppendElapsed(offset ...int) T

	// PrependElapsed appends the elapsed time of the action
	// or the duration of the action if the element is already closed.
	PrependElapsed(offset ...int) T

	// AppendMessage appends text to the progress indicator.
	AppendMessage(m string, offset ...int) T

	// PrependMessage prepends text to the beginning of the indicator
	PrependMessage(m string, offset ...int) T
	// contains filtered or unexported methods
}

ProgressSpecification is the configuration interface for progress indicators.

type ScrollingSpinnerConfiguration

type ScrollingSpinnerConfiguration = SpinnerConfiguration

type ScrollingSpinnerDefinition

type ScrollingSpinnerDefinition[T any] struct {
	ProgressDefinition[T]
	// contains filtered or unexported fields
}

func NewScrollingSpinnerDefinition

func NewScrollingSpinnerDefinition[T any](self Self[T], text string, length int) ScrollingSpinnerDefinition[T]

NewScrollingSpinnerDef can be used to create a nested definition for a derived scrolling spinner definition.

func (*ScrollingSpinnerDefinition[T]) Dup

func (*ScrollingSpinnerDefinition[T]) GetDone

func (d *ScrollingSpinnerDefinition[T]) GetDone() string

func (*ScrollingSpinnerDefinition[T]) GetPending

func (d *ScrollingSpinnerDefinition[T]) GetPending() string

func (*ScrollingSpinnerDefinition[T]) GetPhases

func (d *ScrollingSpinnerDefinition[T]) GetPhases() Phases

func (*ScrollingSpinnerDefinition[T]) GetSpeed

func (d *ScrollingSpinnerDefinition[T]) GetSpeed() int

func (*ScrollingSpinnerDefinition[T]) SetDone

func (d *ScrollingSpinnerDefinition[T]) SetDone(m string) T

func (*ScrollingSpinnerDefinition[T]) SetPending

func (d *ScrollingSpinnerDefinition[T]) SetPending(m string) T

type ScrollingSpinnerInterface

type ScrollingSpinnerInterface interface {
	ProgressInterface
}

type ScrollingSpinnerSpecification

type ScrollingSpinnerSpecification[T any] interface {
	ProgressSpecification[T]
	SetDone(string) T
}

type Self

type Self[T any] interface {
	Self() T
}

func NewSelf

func NewSelf[T any](s T) Self[T]

type Speed

type Speed struct {
	// contains filtered or unexported fields
}

func NewSpeed

func NewSpeed(n int) *Speed

func (*Speed) SetSpeed

func (t *Speed) SetSpeed(n int)

func (*Speed) Tick

func (t *Speed) Tick() bool

func (*Speed) Tick1

func (t *Speed) Tick1() bool

type SpinnerConfiguration

type SpinnerConfiguration interface {
	ProgressConfiguration
	GetPending() string
	GetDone() string
	GetSpeed() int
	GetPhases() Phases
}

type SpinnerDefinition

type SpinnerDefinition[T any] struct {
	ProgressDefinition[T]
	// contains filtered or unexported fields
}

func NewSpinnerDefinition

func NewSpinnerDefinition[T any](self Self[T]) SpinnerDefinition[T]

NewSpinnerDefinition can be used to create a nested definition for a derived spinner definition.

func (*SpinnerDefinition[T]) Dup

func (d *SpinnerDefinition[T]) Dup(s Self[T]) SpinnerDefinition[T]

func (*SpinnerDefinition[T]) GetDone

func (d *SpinnerDefinition[T]) GetDone() string

func (*SpinnerDefinition[T]) GetPending

func (d *SpinnerDefinition[T]) GetPending() string

func (*SpinnerDefinition[T]) GetPhases

func (d *SpinnerDefinition[T]) GetPhases() Phases

func (*SpinnerDefinition[T]) GetSpeed

func (d *SpinnerDefinition[T]) GetSpeed() int

func (*SpinnerDefinition[T]) SetDone

func (d *SpinnerDefinition[T]) SetDone(m string) T

func (*SpinnerDefinition[T]) SetFormattedPhases

func (d *SpinnerDefinition[T]) SetFormattedPhases(p ...ttycolors.String) T

func (*SpinnerDefinition[T]) SetPending

func (d *SpinnerDefinition[T]) SetPending(m string) T

func (*SpinnerDefinition[T]) SetPhases

func (d *SpinnerDefinition[T]) SetPhases(p Phases) T

func (*SpinnerDefinition[T]) SetPredefined

func (d *SpinnerDefinition[T]) SetPredefined(i int) T

func (*SpinnerDefinition[T]) SetSimplePhases

func (d *SpinnerDefinition[T]) SetSimplePhases(p ...string) T

func (*SpinnerDefinition[T]) SetSpeed

func (d *SpinnerDefinition[T]) SetSpeed(v int) T

type SpinnerInterface

type SpinnerInterface interface {
	ProgressInterface
}

type SpinnerSpecification

type SpinnerSpecification[T any] interface {
	ProgressSpecification[T]
	SetPredefined(i int) T
	SetSpeed(v int) T
	SetSimplePhases(p ...string) T
	SetFormattedPhases(p ...ttycolors.String) T
	SetPhases(p Phases) T
	SetDone(string) T
}

type StepsConfiguration

type StepsConfiguration interface {
	BarConfiguration[time.Duration]
	GetSteps() []string
}

type StepsDefinition

type StepsDefinition[T any] struct {
	BarBaseDefinition[T]
	// contains filtered or unexported fields
}

func NewStepsDefinition

func NewStepsDefinition[T any](self Self[T], steps []string) StepsDefinition[T]

NewStepsDefinition can be used to create a nested definition for a derived steps definition.

func (*StepsDefinition[T]) AppendStep

func (d *StepsDefinition[T]) AppendStep() T

func (*StepsDefinition[T]) Dup

func (d *StepsDefinition[T]) Dup(s Self[T]) StepsDefinition[T]

func (*StepsDefinition[T]) GetSteps

func (d *StepsDefinition[T]) GetSteps() []string

func (*StepsDefinition[T]) GetTotal

func (d *StepsDefinition[T]) GetTotal() int

func (*StepsDefinition[T]) PrependStep

func (d *StepsDefinition[T]) PrependStep() T

func (*StepsDefinition[T]) SetSteps

func (d *StepsDefinition[T]) SetSteps(steps []string) T

type StepsInterface

type StepsInterface interface {
	BarInterface
	GetCurrentStep() string
}

type StepsSpecification

type StepsSpecification[T any] interface {
	BarBaseSpecification[T]
	SetSteps(steps []string) T
	AppendStep() T
	PrependStep() T
}

type TextDefinition

type TextDefinition[T any] struct {
	ElementDefinition[T]
	// contains filtered or unexported fields
}

func NewTextDefinition

func NewTextDefinition[T any](self Self[T]) TextDefinition[T]

NewTextDefinition can be used to create a nested definition for a derived text definition.

func (*TextDefinition[T]) Dup

func (d *TextDefinition[T]) Dup(s Self[T]) TextDefinition[T]

func (*TextDefinition[T]) GetAuto

func (d *TextDefinition[T]) GetAuto() bool

func (*TextDefinition[T]) GetFollowUpGap

func (d *TextDefinition[T]) GetFollowUpGap() string

func (*TextDefinition[T]) GetGap

func (d *TextDefinition[T]) GetGap() string

func (*TextDefinition[T]) GetTitleFormat

func (d *TextDefinition[T]) GetTitleFormat() ttycolors.Format

func (*TextDefinition[T]) GetTitleLine

func (d *TextDefinition[T]) GetTitleLine() string

func (*TextDefinition[T]) GetView

func (d *TextDefinition[T]) GetView() int

func (*TextDefinition[T]) GetViewFormat

func (d *TextDefinition[T]) GetViewFormat() ttycolors.Format

func (*TextDefinition[T]) SetAuto

func (d *TextDefinition[T]) SetAuto(b ...bool) T

func (*TextDefinition[T]) SetFollowUpGap

func (d *TextDefinition[T]) SetFollowUpGap(v string) T

func (*TextDefinition[T]) SetGap

func (d *TextDefinition[T]) SetGap(v string) T

func (*TextDefinition[T]) SetTitleFormat

func (d *TextDefinition[T]) SetTitleFormat(f ...ttycolors.FormatProvider) T

func (*TextDefinition[T]) SetTitleLine

func (d *TextDefinition[T]) SetTitleLine(v string) T

func (*TextDefinition[T]) SetView

func (d *TextDefinition[T]) SetView(v int) T

func (*TextDefinition[T]) SetViewFormat

func (d *TextDefinition[T]) SetViewFormat(f ...ttycolors.FormatProvider) T

type TextInterface

type TextInterface interface {
	ElementInterface
	io.Writer
}

type TextSpecification

type TextSpecification[T any] interface {
	ElementSpecification[T]
	SetGap(v string) T

	// SetFollowUpGap provides a prefix for the second and following lines.
	// It could be used together with SetTitleLine.
	SetFollowUpGap(v string) T
	SetTitleLine(v string) T
	SetViewFormat(f ...ttycolors.FormatProvider) T
	SetTitleFormat(f ...ttycolors.FormatProvider) T
	SetAuto(b ...bool) T
	SetView(int) T
}

type TextSpinnerConfiguration

type TextSpinnerConfiguration interface {
	SpinnerConfiguration
	FollowupGapProvider
	ViewFormatProvider
	GetView() int
}

type TextSpinnerDefinition

type TextSpinnerDefinition[T any] struct {
	SpinnerDefinition[T]
	// contains filtered or unexported fields
}

func NewTextSpinnerDefinition

func NewTextSpinnerDefinition[T any](self Self[T]) TextSpinnerDefinition[T]

NewTextSpinnerDefinition can be used to create a nested definition for a derived text spinner definition.

func (*TextSpinnerDefinition[T]) Dup

func (*TextSpinnerDefinition[T]) GetFollowUpGap

func (d *TextSpinnerDefinition[T]) GetFollowUpGap() string

func (*TextSpinnerDefinition[T]) GetView

func (d *TextSpinnerDefinition[T]) GetView() int

func (*TextSpinnerDefinition[T]) GetViewFormat

func (d *TextSpinnerDefinition[T]) GetViewFormat() ttycolors.Format

func (*TextSpinnerDefinition[T]) SetFollowUpGap

func (d *TextSpinnerDefinition[T]) SetFollowUpGap(gap string) T

func (*TextSpinnerDefinition[T]) SetView

func (d *TextSpinnerDefinition[T]) SetView(view int) T

func (*TextSpinnerDefinition[T]) SetViewFormat

func (d *TextSpinnerDefinition[T]) SetViewFormat(f ...ttycolors.FormatProvider) T

type TextSpinnerInterface

type TextSpinnerInterface interface {
	SpinnerInterface
	TextInterface
}

type TextSpinnerSpecification

type TextSpinnerSpecification[T any] interface {
	SpinnerSpecification[T]
	SetView(view int) T
	SetFollowUpGap(gap string) T
	SetViewFormat(f ...ttycolors.FormatProvider) T
}

type TitleFormatProvider

type TitleFormatProvider interface {
	GetTitleFormat() ttycolors.Format
}

TitleFormatProvider is the optional interface to provide a title format.

type TitleLineProvider

type TitleLineProvider interface {
	GetTitleLine() string
}

TitleLineProvider is the optional interface to provide a title line configuration enriching the element configuration.

type VariableProvider

type VariableProvider interface {
	GetVariable(name string) any
}

VariableProvider is the optional interface to provide a variable value.

type ViewFormatProvider

type ViewFormatProvider interface {
	GetViewFormat() ttycolors.Format
}

ViewFormatProvider is the optional interface to provide a view format.

type VoidGroupNotifier

type VoidGroupNotifier struct{}

func (*VoidGroupNotifier) Add

func (*VoidGroupNotifier) Done

func (d *VoidGroupNotifier) Done(e ProgressInterface, o any)

Jump to

Keyboard shortcuts

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