printer

package
Version: v0.0.0-...-24c8d34 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArrowLeft  = rune(KeyCtrlB)
	ArrowRight = rune(KeyCtrlF)
	ArrowUp    = rune(KeyCtrlP)
	ArrowDown  = rune(KeyCtrlN)
	Space      = ' '
	Enter      = '\r'
	NewLine    = '\n'
	Backspace  = rune(KeyCtrlH)
	Backspace2 = rune(KeyDEL)
)

These are the key that aliases

View Source
const (
	FormatPlain = "plain"
	FormatJSON  = "json"
)

Variables

This section is empty.

Functions

func Clean

func Clean()

Clean resets the printer's accumulated lines

func Flush

func Flush() error

Flush writes the elements accumulated in the printer

func GetErrorLines

func GetErrorLines() []interface{}

GetErrorLines returns the printer's accumulated error lines

func GetLines

func GetLines() []interface{}

GetLines returns the printer's accumulated lines

func OverrideEnablePager

func OverrideEnablePager(enable bool)

func Print

func Print(v interface{})

Print an element. If the format requires a template, the element will be printed as a structure with field names using the print verb %+v

func PrintError

func PrintError(msg string)

PrintError prints to the stderr.

func PrintT

func PrintT(templateString string, v interface{})

PrintT prints an element. Depending on the format, the element can be formatted and printed as a structure or used to populate the template

func PrintWarning

func PrintWarning(msg string)

PrintWarning prints warning message to the error output, unlike Print and PrintError functions, PrintWarning writes the output immediately instead of waiting command to finish.

func SetCommand

func SetCommand(cmd *cobra.Command)

func SetFormat

func SetFormat(t string)

SetFormat sets the format for the final output of the printer

func SetQuiet

func SetQuiet(q bool)

SetFormat sets the format for the final output of the printer

func SetServerAddres

func SetServerAddres(addr string)

func SetSingle

func SetSingle(single bool)

SetSingle sets the single flag on the printer. If this flag is set, the printer will check the size of stored elements before printing, and if there is only one, it will be printed on its own instead of inside a list

Types

type Key

type Key int16

Key is the ascii codes of a keys

const (
	KeyCtrlSpace      Key = iota
	KeyCtrlA              // KeySOH
	KeyCtrlB              // KeySTX
	KeyCtrlC              // KeyETX
	KeyCtrlD              // KeyEOT
	KeyCtrlE              // KeyENQ
	KeyCtrlF              // KeyACK
	KeyCtrlG              // KeyBEL
	KeyCtrlH              // KeyBS
	KeyCtrlI              // KeyTAB
	KeyCtrlJ              // KeyLF
	KeyCtrlK              // KeyVT
	KeyCtrlL              // KeyFF
	KeyCtrlM              // KeyCR
	KeyCtrlN              // KeySO
	KeyCtrlO              // KeySI
	KeyCtrlP              // KeyDLE
	KeyCtrlQ              // KeyDC1
	KeyCtrlR              // KeyDC2
	KeyCtrlS              // KeyDC3
	KeyCtrlT              // KeyDC4
	KeyCtrlU              // KeyNAK
	KeyCtrlV              // KeySYN
	KeyCtrlW              // KeyETB
	KeyCtrlX              // KeyCAN
	KeyCtrlY              // KeyEM
	KeyCtrlZ              // KeySUB
	KeyESC                // KeyESC
	KeyCtrlBackslash      // KeyFS
	KeyCtrlRightSq        // KeyGS
	KeyCtrlCarat          // KeyRS
	KeyCtrlUnderscore     // KeyUS
	KeyDEL            = 0x7F
)

These are the control keys. Note that they overlap with other keys.

type Printer

type Printer struct {
	Format string
	Single bool

	Quiet      bool
	Lines      []interface{}
	ErrorLines []interface{}
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL