cli

package module
v0.0.0-...-98f10e0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2016 License: MIT Imports: 12 Imported by: 0

README

cli

Set of basic building blocks for outputing in CLI tools written in Go.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Input  Reader
	Output Writer
)

Functions

func Close

func Close() error

func Flush

func Flush() error

func ForEachByte

func ForEachByte(b []byte, do func(byte))

func ForEachByteInString

func ForEachByteInString(s string, do func(byte))

func ForEachRune

func ForEachRune(b []byte, do func(rune))

func ForEachRuneInString

func ForEachRuneInString(s string, do func(rune))

func Init

func Init() (err error)

func Print

func Print(args ...interface{}) (int, error)

func Printf

func Printf(format string, args ...interface{}) (int, error)

func Println

func Println(args ...interface{}) (int, error)

func ReadLine

func ReadLine(prompt string) (line string, err error)

func ReadPassowrd

func ReadPassowrd(prompt string) (line string, err error)

func RenderCell

func RenderCell(w io.Writer, cell string, width int, align CellAlign) (err error)

func RenderCellCentered

func RenderCellCentered(w io.Writer, cell string, width int) (err error)

func RenderCellLeftAlign

func RenderCellLeftAlign(w io.Writer, cell string, width int) (err error)

func RenderCellRightAlign

func RenderCellRightAlign(w io.Writer, cell string, width int) (err error)

func RenderColumn

func RenderColumn(w io.Writer, col string, width int) (err error)

func RenderTableView

func RenderTableView(w io.Writer, t TableView) (err error)

func RenderTableViewColumns

func RenderTableViewColumns(w io.Writer, t TableView) (err error)

func RenderTableViewRows

func RenderTableViewRows(w io.Writer, t TableView) (err error)

func RenderTreeView

func RenderTreeView(w io.Writer, t TreeView) (err error)

func RuneCount

func RuneCount(b []byte) (n int)

func RuneCountInString

func RuneCountInString(s string) int

func StripStyles

func StripStyles(b []byte) []byte

func StripStylesInString

func StripStylesInString(s string) string

Types

type CellAlign

type CellAlign int
const (
	LeftAlign  CellAlign = -1
	RightAlign CellAlign = 1
	Centered   CellAlign = 0
)

type ReadWriter

type ReadWriter interface {
	io.Closer

	io.Writer

	Flush() error

	ReadLine(prompt string) (line string, err error)

	ReadPassword(prompt string) (line string, err error)
}

func New

func New(input *os.File, output *os.File) (rw ReadWriter, err error)

type Reader

type Reader interface {
	io.Closer

	ReadLine(prompt string) (line string, err error)

	ReadPassword(prompt string) (line string, err error)
}

type StyleSet

type StyleSet []int
var (
	Normal    StyleSet = StyleSet{0}
	Bold      StyleSet = StyleSet{1}
	Dim       StyleSet = StyleSet{2}
	Standout  StyleSet = StyleSet{3}
	Underline StyleSet = StyleSet{4}
	Blink     StyleSet = StyleSet{5}
	Reverse   StyleSet = StyleSet{7}
	Hidden    StyleSet = StyleSet{8}

	Black   StyleSet = StyleSet{30}
	Red     StyleSet = StyleSet{31}
	Green   StyleSet = StyleSet{32}
	Yellow  StyleSet = StyleSet{33}
	Blue    StyleSet = StyleSet{34}
	Magenta StyleSet = StyleSet{35}
	Cyan    StyleSet = StyleSet{36}
	White   StyleSet = StyleSet{37}
	Default StyleSet = StyleSet{38}

	BlackBG   StyleSet = StyleSet{40}
	RedBG     StyleSet = StyleSet{41}
	GreenBG   StyleSet = StyleSet{42}
	YellowBG  StyleSet = StyleSet{43}
	BlueBG    StyleSet = StyleSet{44}
	MagentaBG StyleSet = StyleSet{45}
	CyanBG    StyleSet = StyleSet{46}
	WhiteBG   StyleSet = StyleSet{47}
	DefaultBG StyleSet = StyleSet{48}
)

func Style

func Style(styles ...StyleSet) StyleSet

func (StyleSet) Append

func (s StyleSet) Append(b []byte) []byte

func (StyleSet) B

func (s StyleSet) B(b []byte) []byte

func (StyleSet) Bytes

func (s StyleSet) Bytes() []byte

func (StyleSet) Format

func (s StyleSet) Format(f fmt.State, _ rune)

func (StyleSet) S

func (s StyleSet) S(v string) string

func (StyleSet) String

func (s StyleSet) String() string

func (StyleSet) WriteTo

func (s StyleSet) WriteTo(w io.Writer) (int, error)

type Table

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

func NewTable

func NewTable(columns ...string) *Table

func NewTableFromView

func NewTableFromView(view TableView) *Table

func (*Table) Append

func (t *Table) Append(row ...string) *Table

func (*Table) Cell

func (t *Table) Cell(col int, row int) string

func (*Table) Column

func (t *Table) Column(col int) string

func (*Table) Size

func (t *Table) Size() (cols int, rows int)

type TableView

type TableView interface {
	Column(col int) string

	Cell(col int, row int) string

	Size() (cols int, rows int)
}

func NewTableView

func NewTableView(v interface{}) TableView

func StyledTableView

func StyledTableView(t TableView, style StyleSet) TableView

type Tree

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

func NewTree

func NewTree(cell string, nodes ...TreeView) *Tree

func (*Tree) Cell

func (t *Tree) Cell() string

func (*Tree) Nodes

func (t *Tree) Nodes() []TreeView

type TreeIndent

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

func NewTreeIndent

func NewTreeIndent() *TreeIndent

func (*TreeIndent) Clear

func (ti *TreeIndent) Clear(index int, depth int)

func (*TreeIndent) Depth

func (ti *TreeIndent) Depth() int

func (*TreeIndent) Next

func (ti *TreeIndent) Next(index int, count int, depth int)

func (*TreeIndent) Pop

func (ti *TreeIndent) Pop()

func (*TreeIndent) Push

func (ti *TreeIndent) Push() int

func (*TreeIndent) String

func (ti *TreeIndent) String() string

type TreeView

type TreeView interface {
	Cell() string

	Nodes() []TreeView
}

type Writer

type Writer interface {
	io.Closer

	io.Writer

	Flush() error
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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