console

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset     = "\033[0m"
	Bold      = "\u001B[1m"
	Italic    = "\u001B[3m"
	Underline = "\u001B[4m"
)

Variables

This section is empty.

Functions

func Ask

func Ask[T optConstraint](writer Writer, question string, opts ...T) (res T, err error)

func Confirm

func Confirm(writer Writer, question string) bool

func Password

func Password(writer Writer, prompt string, valid func(string) error) (string, error)

Types

type Color

type Color int
const (
	Black Color = iota + 30
	Red
	Green
	Yellow
	Blue
	Magenta
	Cyan
	White

	Background Color = 10
	Bright     Color = 60
)

type Column

type Column struct {
	Index int
	Name  string
	Width int
}

type Displayable

type Displayable interface {
	Columns() []string
	Values() map[string]interface{}
}

type Progress

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

func NewProgress

func NewProgress(message string) *Progress

func (*Progress) Display

func (p *Progress) Display(out Writer)

func (*Progress) Done

func (p *Progress) Done()

type Table

type Table struct {
	Columns []*Column
	Rows    [][]string
}

func (*Table) FindColumn

func (t *Table) FindColumn(name string) *Column

func (*Table) Format

func (t *Table) Format(out Writer, separator string, pretty bool)

func (*Table) Insert

func (t *Table) Insert(val interface{}) error

type Writer

type Writer interface {
	io.Writer

	Color(color Color) Writer
	Bold() Writer
	Reset() Writer

	Printf(format string, a ...interface{}) Writer
	Print(a ...interface{}) Writer
	Println(a ...interface{}) Writer

	Errorf(format string, a ...interface{}) Writer
}

func NewConsoleOutput

func NewConsoleOutput(file *os.File) Writer

Jump to

Keyboard shortcuts

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