say

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 9 Imported by: 44

README

Say

A collection of simple Go helpers for easily producing formatted CLI output

Documentation

Index

Constants

View Source
const COLS = 80
View Source
const SAY_VERSION = "1.1.0"

Variables

View Source
var SingletonFormatter = New(ColorModeTerminal)

Functions

func Ask

func Ask(f string, args ...any) string

func AskForBoolWithDefault

func AskForBoolWithDefault(text string, defaultResponse bool) bool

func AskForIntegerWithDefault

func AskForIntegerWithDefault(text string, defaultResponse int) int

func AskWithDefault

func AskWithDefault(text string, defaultResponse string) string

func AskWithValidation

func AskWithValidation(text string, validation func(string) error) string

func ExitIfError

func ExitIfError(context string, err error)

func ExitWith added in v1.1.0

func ExitWith(format string, args ...any)

func F added in v1.1.0

func F(format string, args ...interface{}) string

func Fi added in v1.1.0

func Fi(indentation uint, format string, args ...interface{}) string

func Fiw added in v1.1.0

func Fiw(indentation uint, maxWidth uint, format string, args ...interface{}) string

func Flniw added in v1.1.0

func Flniw(writer io.Writer, indentation uint, maxWidth uint, format string, args ...interface{})

func Fp added in v1.1.0

func Fp(writer io.Writer, format string, args ...interface{})

func Fpi added in v1.1.0

func Fpi(writer io.Writer, indentation uint, format string, args ...interface{})

func Fpiw added in v1.1.0

func Fpiw(writer io.Writer, indentation uint, maxWidth uint, format string, args ...interface{})

func Fpln added in v1.1.0

func Fpln(writer io.Writer, format string, args ...interface{})

func Fplni added in v1.1.0

func Fplni(writer io.Writer, indentation uint, format string, args ...interface{})

func Invoke

func Invoke(executable Executable)

func P added in v1.1.0

func P(format string, args ...interface{})

func Pi added in v1.1.0

func Pi(indentation uint, format string, args ...interface{})

func Pick

func Pick(text string, options []string) string

func Piw added in v1.1.0

func Piw(indentation uint, maxWidth uint, format string, args ...interface{})

func Pln added in v1.1.0

func Pln(format string, args ...interface{})

func Plni added in v1.1.0

func Plni(indentation uint, format string, args ...interface{})

func Plniw added in v1.1.0

func Plniw(indentation uint, maxWidth uint, format string, args ...interface{})

Types

type ColorMode added in v1.1.0

type ColorMode uint8
const (
	ColorModeNone ColorMode = iota
	ColorModeTerminal
	ColorModePassthrough
)

type Command

type Command struct {
	Name        string
	Description string
	FlagSet     *flag.FlagSet
	Run         func(args []string)
}

type CommandGroup

type CommandGroup struct {
	Name        string
	Description string
	Commands    []Command
}

type Executable

type Executable struct {
	Name          string
	Description   string
	CommandGroups []CommandGroup
}

type Formatter added in v1.1.0

type Formatter struct {
	ColorMode ColorMode
	// contains filtered or unexported fields
}

func New added in v1.1.0

func New(colorMode ColorMode) Formatter

func NewWithNoColorBool added in v1.1.0

func NewWithNoColorBool(noColor bool) Formatter

func (Formatter) CycleJoin added in v1.1.0

func (f Formatter) CycleJoin(elements []string, joiner string, cycle []string) string

func (Formatter) F added in v1.1.0

func (f Formatter) F(format string, args ...interface{}) string

func (Formatter) Fi added in v1.1.0

func (f Formatter) Fi(indentation uint, format string, args ...interface{}) string

func (Formatter) Fiw added in v1.1.0

func (f Formatter) Fiw(indentation uint, maxWidth uint, format string, args ...interface{}) string

Jump to

Keyboard shortcuts

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