cli

package
v0.0.0-...-d3cc92b Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CancelProgressBars

func CancelProgressBars()

func Clear

func Clear()

func Error

func Error(format string, a ...any)

func Input

func Input(prompt string, required bool, defaultValue string, validators ...Validator) string

Input ask the user to input a line of text.

func MultiSelect

func MultiSelect(msg string, options []string, selected []int) []bool

MultiSelect asks the user to select an arbitrary amount of options. It returns a boolean slice of length options with the chosen indices set to true.

func Output

func Output() io.Writer

func Print

func Print(format string, a ...any)

func PrintColor

func PrintColor(color Color, format string, a ...any)

func Progress

func Progress(key, message string, current, total int64, unit Unit)

func ResetColor

func ResetColor()

func Select

func Select(msg string, options []string) int

Select asks the user to select on option. It returns the index of the chosen option.

func SelectString

func SelectString(msg string, options map[string]string) string

SelectString asks the user to select on option. It returns the value in options of the chosen key. It panics if the length of displayOptions differs from the length of options.

func SetColor

func SetColor(color Color)

func Success

func Success(format string, a ...any)

func Warn

func Warn(format string, a ...any)

func YesNo

func YesNo(question string, defaultValue bool) (yes bool)

YesNo asks the user a yes/no question.

Types

type Color

type Color string
const (
	Reset       Color = "\x1b[0m"
	Black       Color = "\x1b[30m"
	Red         Color = "\x1b[31m"
	Green       Color = "\x1b[32m"
	Yellow      Color = "\x1b[33m"
	Blue        Color = "\x1b[34m"
	Magenta     Color = "\x1b[35m"
	Cyan        Color = "\x1b[36m"
	White       Color = "\x1b[37m"
	BlackBold   Color = "\x1b[1;30m"
	RedBold     Color = "\x1b[1;31m"
	GreenBold   Color = "\x1b[1;32m"
	YellowBold  Color = "\x1b[1;33m"
	BlueBold    Color = "\x1b[1;34m"
	MagentaBold Color = "\x1b[1;35m"
	CyanBold    Color = "\x1b[1;36m"
	WhiteBold   Color = "\x1b[1;37m"
	WhiteDim    Color = "\x1b[2;37m"
)

type Unit

type Unit int
const (
	UnitNone Unit = iota
	UnitFileSize
)

type Validator

type Validator func(input interface{}) error

func MaxLength

func MaxLength(n int) Validator

func MinLength

func MinLength(n int) Validator

func Regexp

func Regexp(regexp *regexp.Regexp, errorMsg string) Validator

Jump to

Keyboard shortcuts

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