termstatus

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2020 License: BSD-2-Clause Imports: 11 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsProcessBackground added in v1.0.0

func IsProcessBackground() bool

IsProcessBackground reports whether the current process is running in the background.

Types

type Terminal

type Terminal struct {
	MaxFrameRate uint
	// contains filtered or unexported fields
}

Terminal is used to write messages and display status lines which can be updated. When the output is redirected to a file, the status lines are not printed.

func New

func New(wr io.Writer, errWriter io.Writer, disableStatus bool) *Terminal

New returns a new Terminal for wr. A goroutine is started to update the terminal. It is terminated when ctx is cancelled. When wr is redirected to a file (e.g. via shell output redirection) or is just an io.Writer (not the open *os.File for stdout), no status lines are printed. The status lines and normal output (via Print/Printf) are written to wr, error messages are written to errWriter. If disableStatus is set to true, no status messages are printed even if the terminal supports it.

func (*Terminal) Error added in v1.0.0

func (t *Terminal) Error(line string)

Error writes an error to the terminal.

func (*Terminal) Errorf added in v1.0.0

func (t *Terminal) Errorf(msg string, args ...interface{})

Errorf uses fmt.Sprintf to write an error line to the terminal.

func (*Terminal) Print

func (t *Terminal) Print(line string)

Print writes a line to the terminal.

func (*Terminal) Printf

func (t *Terminal) Printf(msg string, args ...interface{})

Printf uses fmt.Sprintf to write a line to the terminal.

func (*Terminal) Run added in v1.0.0

func (t *Terminal) Run(ctx context.Context)

Run updates the screen. It should be run in a separate goroutine. When ctx is cancelled, the status lines are cleanly removed.

func (*Terminal) SetStatus

func (t *Terminal) SetStatus(lines []string)

SetStatus updates the status lines.

Directories

Path Synopsis
examples
Package progress provides functions to inform the user about the status of an ongoing operation via a terminal.
Package progress provides functions to inform the user about the status of an ongoing operation via a terminal.

Jump to

Keyboard shortcuts

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