ui

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBytes added in v0.15.0

func FormatBytes(c uint64) string

func FormatDuration added in v0.15.0

func FormatDuration(d time.Duration) string

FormatDuration formats d as FormatSeconds would.

func FormatPercent added in v0.15.0

func FormatPercent(numerator uint64, denominator uint64) string

FormatPercent formats numerator/denominator as a percentage.

func FormatSeconds added in v0.15.0

func FormatSeconds(sec uint64) string

FormatSeconds formats sec as MM:SS, or HH:MM:SS if sec seconds is at least an hour.

func ParseBytes added in v0.16.0

func ParseBytes(s string) (int64, error)

ParseBytes parses a size in bytes from s. It understands the suffixes B, K, M, G and T for powers of 1024.

func TerminalDisplayWidth added in v0.17.0

func TerminalDisplayWidth(s string) int

TerminalDisplayWidth returns the number of terminal cells needed to display s

func ToJSONString added in v0.16.0

func ToJSONString(status interface{}) string

Types

type Message

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

Message reports progress with messages of different verbosity.

func NewMessage

func NewMessage(term Terminal, verbosity uint) *Message

NewMessage returns a message progress reporter with underlying terminal term.

func (*Message) E

func (m *Message) E(msg string, args ...interface{})

E reports an error

func (*Message) P

func (m *Message) P(msg string, args ...interface{})

P prints a message if verbosity >= 1, this is used for normal messages which are not errors.

func (*Message) V

func (m *Message) V(msg string, args ...interface{})

V prints a message if verbosity >= 2, this is used for verbose messages.

func (*Message) VV

func (m *Message) VV(msg string, args ...interface{})

VV prints a message if verbosity >= 3, this is used for debug messages.

type MockTerminal added in v0.17.1

type MockTerminal struct {
	Output []string
	Errors []string
}

func (*MockTerminal) CanUpdateStatus added in v0.17.1

func (m *MockTerminal) CanUpdateStatus() bool

func (*MockTerminal) Error added in v0.17.1

func (m *MockTerminal) Error(line string)

func (*MockTerminal) Print added in v0.17.1

func (m *MockTerminal) Print(line string)

func (*MockTerminal) SetStatus added in v0.17.1

func (m *MockTerminal) SetStatus(lines []string)

type Terminal added in v0.17.1

type Terminal interface {
	Print(line string)
	Error(line string)
	SetStatus(lines []string)
	CanUpdateStatus() bool
}

Terminal is used to write messages and display status lines which can be updated. See termstatus.Terminal for a concrete implementation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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