status

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2021 License: MIT Imports: 4 Imported by: 1

Documentation

Overview

Package status provides basic facility to print status line to the terminal.

Typical usage:

line := new(status.Line)
defer line.Done()
for i := 0; i < total; i++ {
    line.Printf("step %d out of %d", i, total)
    ...
}

This package outputs VT100 escape sequences, so its output may break if your terminal does not support them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Line

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

Line can be used to print a single status line, overwriting it on each Print/Printf call. Finish with Done call to move cursor to the new line.

By default Line writes to os.Stdout, use SetOutput method to override.

If Line's output is not connected to a terminal (for example, if program's output is redirected to a file), Print/Printf calls do nothing.

func (*Line) Done

func (l *Line) Done()

Done writes a single newline.

func (*Line) Print

func (l *Line) Print(a ...interface{}) (n int, err error)

Print works like fmt.Print. Because Line is expected to write over a single line, including any newlines will break output.

func (*Line) Printf

func (l *Line) Printf(format string, a ...interface{}) (n int, err error)

Printf works like fmt.Printf. Because Line is expected to write over a single line, including any newlines will break output.

func (*Line) SetOutput

func (l *Line) SetOutput(f *os.File)

SetOutput overrides the default os.Stdout output. Can only be called before any other methods.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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