ui

package
v0.0.0-...-5072f25 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ColorBlack Black text style
	ColorBlack = "30"

	// ColorRed red text style
	ColorRed = "31"

	// ColorGreen green text style
	ColorGreen = "32"

	// ColorYello yellow text style
	ColorYellow = "33"

	// ColorBlue blue text style
	ColorBlue = "34"

	// ColorMagenta magenta text style
	ColorMagenta = "35"

	// ColorCyan cyan text style
	ColorCyan = "36"

	// ColorWhite white text style
	ColorWhite = "37"

	// ColorGrey grey text style
	ColorGrey = "90"

	// ColorBlackBg black background style
	ColorBlackBg = "40"

	// ColorRedBg red background style
	ColorRedBg = "41"

	// ColorGreenBg green background style
	ColorGreenBg = "42"

	// ColorYellowBg yellow background style
	ColorYellowBg = "43"

	// ColorBlueBg blue background style
	ColorBlueBg = "44"

	// ColorMagentaBg magenta background style
	ColorMagentaBg = "45"

	// ColorCyanBg cyan background style
	ColorCyanBg = "46"

	// WhtBg white background style
	ColorWhiteBg = "47"

	// StyleReset reset emphasis style
	StyleReset = "0"

	// StyleBold bold emphasis style
	StyleBold = "1"

	// StyleDim dim emphasis style
	StyleDim = "2"

	// StyleItalic italic emphasis style
	StyleItalic = "3"

	// StyleUnderline underline emphasis style
	StyleUnderline = "4"

	// StyleInverse inverse emphasis style
	StyleInverse = "7"

	// StyleHidden hidden emphasis style
	StyleHidden = "8"

	// StyleStrikeout strikeout emphasis style
	StyleStrikeout = "9"
)

Variables

View Source
var DefaultUI = New()

DefaultUI is the default UI for the package

View Source
var TitleUnderliner = "="

TitleUnderliner is the underline character for the title

Functions

func Color

func Color() *color.Color

Color returns an instance of color from the Default UI

Types

type BufferedPrinter

type BufferedPrinter struct {
	// Writer is where the output should writer to
	Writer io.Writer
	// contains filtered or unexported fields
}

Printer represents the output printer for the ui

func NewPrinter

func NewPrinter() *BufferedPrinter

NewPrinter returns a pointer to a new printer object

func Printer

func Printer() *BufferedPrinter

Printer returns the object that prints from the Default UI

func (*BufferedPrinter) Add

Add adds the components to the printer

func (*BufferedPrinter) Flush

func (p *BufferedPrinter) Flush()

Print prints the output to the writer

func (*BufferedPrinter) String

func (p *BufferedPrinter) String() string

String returns the formmated string of the output

type Title

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

Title is a UI component that renders a title

func NewTitle

func NewTitle(title string) *Title

func (*Title) String

func (t *Title) String() string

Format returns the formated string of the title

type UI

type UI struct {
	Writer io.Writer
	Reader io.Reader
	// contains filtered or unexported fields
}

UI implements UserInterface and uses standard i/o

func New

func New() *UI

NewStdUI returns an instance of the StdUI

func (*UI) Color

func (u *UI) Color() *color.Color

Color returns an instance of color

func (*UI) Printer

func (u *UI) Printer() *BufferedPrinter

Printer returns the printer for the UI

func (*UI) Prompt

func (u *UI) Prompt() *prompt.Prompter

Prompter returns the user prompter for the UI

func (*UI) SetNoColor

func (u *UI) SetNoColor(nocolor bool)

SetNoColor sets if the output should have color

func (*UI) SetNoInteractive

func (u *UI) SetNoInteractive(noint bool)

SetNoInteractive sets the interactive mode for the UI

type UserInterface

type UserInterface interface {
	// Printer must return the object that prints to the UI
	Printer() *BufferedPrinter

	// Prompter must return the object that prompts the user for input
	Prompt() *prompt.Prompter

	// Color returns an instance of color
	Color() *color.Color

	// SetNoInteractive must set the interactive mode for the UI
	SetNoInteractive(bool)

	// SetNoColor must set the color mode for output
	SetNoColor(nocolor bool)
}

UserInterface is the interface that defines UI interation functionality to the CLI

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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