tux

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

TUX: Terminal UX

This package contains utilities that we used to render messages in our CLI app. For now, starting it within envsec, but if it grows, and we use it beyond envsec, it could become a top-level module, that we open source as well.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FTable added in v0.0.14

func FTable(w io.Writer, rows [][]string)

func Plural

func Plural[T any](items []T, singular string, plural string) string

func QuotedTerms

func QuotedTerms(terms []string) []string

QuotedTerms will wrap each term in single-quotation marks

func Render

func Render(styleSheet StyleSheet, class string, text string) string

func StyleFunc

func StyleFunc(styleSheet StyleSheet) func(class string, text string) string

func WriteHeader

func WriteHeader(w io.Writer, format string, a ...any) error

TODO: Migrate to style sheets

Types

type StyleRenderer

type StyleRenderer interface {
	Render(str ...string) string
}

func Renderer

func Renderer(styleRule StyleRule, tokens map[string]string) StyleRenderer

type StyleRule

type StyleRule struct {
	Bold               bool
	Italic             bool
	Underline          bool
	Strikethrough      bool
	Blink              bool
	Faint              bool
	Foreground         string
	ForegroundInverted string
	Background         string
	BackgroundInverted string
	PaddingTop         int
	PaddingRight       int
	PaddingBottom      int
	PaddingLeft        int
	MarginTop          int
	MarginRight        int
	MarginBottom       int
	MarginLeft         int
}

type StyleSheet

type StyleSheet struct {
	Styles map[string]StyleRule
	Tokens map[string]string
}

type Tux

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

func New

func New() *Tux

func (*Tux) MustPrintErr

func (tux *Tux) MustPrintErr(a ...any)

func (*Tux) PrintT

func (tux *Tux) PrintT(text string, data any)

func (*Tux) SetErr

func (tux *Tux) SetErr(w io.Writer)

func (*Tux) SetIn

func (tux *Tux) SetIn(r io.Reader)

func (*Tux) SetOut

func (tux *Tux) SetOut(w io.Writer)

func (*Tux) SetStyleSheet

func (tux *Tux) SetStyleSheet(styleSheet StyleSheet)

Jump to

Keyboard shortcuts

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