ui

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatBytes

func FormatBytes(c uint64) string

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats d as FormatSeconds would.

func FormatPercent

func FormatPercent(numerator uint64, denominator uint64) string

FormatPercent formats numerator/denominator as a percentage.

func FormatSeconds

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

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 ToJSONString

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 *termstatus.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 StdioWrapper

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

StdioWrapper provides stdout and stderr integration with termstatus.

func NewStdioWrapper

func NewStdioWrapper(term *termstatus.Terminal) *StdioWrapper

NewStdioWrapper initializes a new stdio wrapper that can be used in place of os.Stdout or os.Stderr.

func (*StdioWrapper) Stderr

func (w *StdioWrapper) Stderr() io.WriteCloser

Stderr returns a writer that is line buffered and can be used in place of os.Stderr. On Close(), the remaining bytes are written, followed by a line break.

func (*StdioWrapper) Stdout

func (w *StdioWrapper) Stdout() io.WriteCloser

Stdout returns a writer that is line buffered and can be used in place of os.Stdout. On Close(), the remaining bytes are written, followed by a line break.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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