termui

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DotProgress

type DotProgress struct {
	Delay time.Duration // Delay is the speed of the indicator
	// contains filtered or unexported fields
}

func NewDotProgress

func NewDotProgress(ui *UI, message string) *DotProgress

func (*DotProgress) ChangeMessage

func (p *DotProgress) ChangeMessage(message string)

ChangeMessage extends the dot-based progress with the ability to change the message mid-flight

func (*DotProgress) ChangeMessagef

func (p *DotProgress) ChangeMessagef(message string, a ...interface{})

ChangeMessagef extends the dot-based progress with the ability to change the message mid-flight

func (*DotProgress) Start

func (p *DotProgress) Start()

func (*DotProgress) Stop

func (p *DotProgress) Stop()

type Message

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

Message represents a piece of information we want displayed to the user

func (*Message) Compact

func (u *Message) Compact() *Message

Compact disables the printing of a newline before starting output

func (*Message) KeepLine

func (u *Message) KeepLine() *Message

KeepLine disables the printing of a newline after a message output

func (*Message) KeeplineUnder

func (u *Message) KeeplineUnder(level int) *Message

KeeplineUnder disables the printing of a newline after a message output, if the verbosity level is below the specified.

func (*Message) Msg

func (u *Message) Msg(message string)

Msg prints a message on the CLI, resolving emoji as it goes

func (*Message) Msgf

func (u *Message) Msgf(message string, a ...interface{})

Msgf prints a formatted message on the CLI

func (*Message) Timeout

func (u *Message) Timeout(wait time.Duration) *Message

Timeout sets a timeout for the message to wait after printing before continuing. This disables any previous `WithEnd`.

func (*Message) V

func (u *Message) V(delta int) *Message

V incrementally modifies the message level.

func (*Message) WithAskBool

func (u *Message) WithAskBool(name string, result *bool) *Message

WithAskBool waits for the user's input for a boolean value

func (*Message) WithAskInt

func (u *Message) WithAskInt(name string, result *int) *Message

WithAskInt waits for the user's input for an int value

func (*Message) WithAskString

func (u *Message) WithAskString(name string, result *string) *Message

WithAskString waits for the user's input for a string value

func (*Message) WithBoolValue

func (u *Message) WithBoolValue(name string, value bool) *Message

WithBoolValue adds a bool value to be printed in the message

func (*Message) WithEnd

func (u *Message) WithEnd(code int) *Message

WithEnd ends the entire process after printing the message. This also disables any previous `Timeout`.

func (*Message) WithIntValue

func (u *Message) WithIntValue(name string, value int) *Message

WithIntValue adds an int value to be printed in the message

func (*Message) WithStringValue

func (u *Message) WithStringValue(name string, value string) *Message

WithStringValue adds a string value to be printed in the message

func (*Message) WithTable

func (u *Message) WithTable(headers ...string) *Message

WithTable prints a new table

func (*Message) WithTableRow

func (u *Message) WithTableRow(values ...string) *Message

WithTableRow adds a row in the latest table

type Progress

type Progress interface {
	Start()
	Stop()
	ChangeMessage(message string)
	ChangeMessagef(message string, a ...interface{})
}

Progress abstracts the operations for a progress meter and/or spinner used to indicate the cli waiting for some background operation to complete.

type SpinProgress

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

func NewSpinProgress

func NewSpinProgress(message string) *SpinProgress

func (*SpinProgress) ChangeMessage

func (p *SpinProgress) ChangeMessage(message string)

ChangeMessage extends the spinner-based progress with the ability to change the message mid-flight

func (*SpinProgress) ChangeMessagef

func (p *SpinProgress) ChangeMessagef(message string, a ...interface{})

ChangeMessagef extends the spinner-based progress with the ability to change the message mid-flight

func (*SpinProgress) Start

func (p *SpinProgress) Start()

func (*SpinProgress) Stop

func (p *SpinProgress) Stop()

type UI

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

UI contains functionality for dealing with the user on the CLI

func NewUI

func NewUI() *UI

NewUI creates a new UI

func (*UI) DisableJSON

func (u *UI) DisableJSON()

func (*UI) EnableJSON

func (u *UI) EnableJSON()

func (*UI) Exclamation

func (u *UI) Exclamation() *Message

Exclamation returns a UIMessage that prints an exclamation message

func (*UI) JSON

func (u *UI) JSON(value any) error

func (*UI) JSONEnabled

func (u *UI) JSONEnabled() bool

func (*UI) Normal

func (u *UI) Normal() *Message

Normal returns a UIMessage that prints a normal message

func (*UI) Note

func (u *UI) Note() *Message

Note returns a UIMessage that prints a note message

func (*UI) Problem

func (u *UI) Problem() *Message

Problem returns a Message that prints a message that describes a problem

func (*UI) Progress

func (u *UI) Progress(message string) Progress

Progress creates, configures, and returns an active progress meter. It accepts a fixed message.

func (*UI) ProgressNote

func (u *UI) ProgressNote() *Message

ProgressNote returns a UIMessage that prints a progress-related message

func (*UI) Progressf

func (u *UI) Progressf(message string, a ...interface{}) Progress

Progress creates, configures, and returns an active progress meter. It accepts a formatted message.

func (*UI) Question

func (u *UI) Question() *Message

Question returns a UIMessage that prints a question. Best used with `WithAsk...` modifiers.

func (*UI) Raw

func (u *UI) Raw(message string)

func (*UI) SetOutput

func (u *UI) SetOutput(output io.Writer)

func (*UI) Success

func (u *UI) Success() *Message

Success returns a UIMessage that prints a success message

Jump to

Keyboard shortcuts

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