cli

package module
v0.32.8 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 24 Imported by: 0

README

CLI

A Go lib to create CLI applications, inspired by symfony/console, illuminate/console, and spf13/cobra.

This was created as an exercise to learn Go, and for personal usage.

Work in progress.

Documentation

Index

Constants

View Source
const (
	ColorBlack   = "black"
	ColorRed     = "red"
	ColorGreen   = "green"
	ColorYellow  = "yellow"
	ColorBlue    = "blue"
	ColorMagenta = "magenta"
	ColorCyan    = "cyan"
	ColorWhite   = "white"
	ColorGray    = "gray"
	ColorDefault = "default"

	ColorBrightRed     = "bright-red"
	ColorBrightGreen   = "bright-green"
	ColorBrightYellow  = "bright-yellow"
	ColorBrightBlue    = "bright-blue"
	ColorBrightMagenta = "bright-magenta"
	ColorBrightCyan    = "bright-cyan"
	ColorBrightWhite   = "bright-white"
)
View Source
const (
	ColorOptionBold       = "bold"
	ColorOptionItalic     = "italic"
	ColorOptionUnderscore = "underscore"
	ColorOptionBlink      = "blink"
	ColorOptionReverse    = "reverse"
	ColorOptionConceal    = "conceal"
)
View Source
const (
	FormText = iota
	FormTextArea
	FormArray
	FormSelect
	FormMultiselect
	FormConfirm
	FormWait
	FormPause
)
View Source
const (
	LogLevelDebug = iota
	LogLevelInfo
	LogLevelNotice
	LogLevelWarn
	LogLevelError
	LogLevelCritical
	LogLevelAlert
	LogLevelFatal
)
View Source
const (
	LogTagDebug    = "debug"
	LogTagInfo     = "info"
	LogTagNotice   = "notice"
	LogTagWarn     = "warn"
	LogTagError    = "error"
	LogTagCritical = "critical"
	LogTagAlert    = "alert"
	LogTagFatal    = "fatal"
)
View Source
const (
	VerbosityQuiet       uint = 16
	VerbosityNormal      uint = 32
	VerbosityVerbose     uint = 64
	VerbosityVeryVerbose uint = 128
	VerbosityDebug       uint = 256
)
View Source
const (
	OutputNormal uint = 1
	OutputRaw    uint = 2
	OutputPlain  uint = 4
)
View Source
const (
	PromptStateInitial = iota
	PromptStateActive
	PromptStateSubmit
	PromptStateCancel
	PromptStateError
	PromptStateSearching
	PromptStateDeleting
)
View Source
const (
	CbarBell     = "\x07"
	CharNewline  = "\x0a"
	CharTab      = "\x09"
	CharSpace    = " "
	CharEllipsis = "…"
)
View Source
const (
	BoxTopLeft        = "┌"
	BoxTopRight       = "┐"
	BoxBottomLeft     = "└"
	BoxBottomRight    = "┘"
	BoxVertical       = "│"
	BoxVerticalRight  = "├"
	BoxVerticalLeft   = "┤"
	BoxHorizontal     = "─"
	BoxHorizontalDown = "┬"
	BoxHorizontalUp   = "┴"
	BoxCross          = "┼"
)
View Source
const (
	HeavyBoxTopLeft        = "┏"
	HeavyBoxTopRight       = "┓"
	HeavyBoxBottomLeft     = "┗"
	HeavyBoxBottomRight    = "┛"
	HeavyBoxVertical       = "┃"
	HeavyBoxVerticalRight  = "┣"
	HeavyBoxVerticalLeft   = "┫"
	HeavyBoxHorizontal     = "━"
	HeavyBoxHorizontalDown = "┳"
	HeavyBoxHorizontalUp   = "┻"
	HeavyBoxCross          = "╋"
)
View Source
const (
	DoubleBoxTopLeft        = "╔"
	DoubleBoxTopRight       = "╗"
	DoubleBoxBottomLeft     = "╚"
	DoubleBoxBottomRight    = "╝"
	DoubleBoxVertical       = "║"
	DoubleBoxVerticalRight  = "╠"
	DoubleBoxVerticalLeft   = "╣"
	DoubleBoxHorizontal     = "═"
	DoubleBoxHorizontalDown = "╦"
	DoubleBoxHorizontalUp   = "╩"
	DoubleBoxCross          = "╬"
)
View Source
const (
	RoundedBoxTopLeft        = "╭"
	RoundedBoxTopRight       = "╮"
	RoundedBoxBottomLeft     = "╰"
	RoundedBoxBottomRight    = "╯"
	RoundedBoxVertical       = "│"
	RoundedBoxVerticalRight  = "├"
	RoundedBoxVerticalLeft   = "┤"
	RoundedBoxHorizontal     = "─"
	RoundedBoxHorizontalDown = "┬"
	RoundedBoxHorizontalUp   = "┴"
	RoundedBoxCross          = "┼"
)
View Source
const (
	ArrowRight     = "→"
	ArrowLeft      = "←"
	ArrowUp        = "↑"
	ArrowDown      = "↓"
	ArrowLeftRight = "↔"
	ArrowUpDown    = "↕"
)
View Source
const (
	TriangleRight = "▶"
	TriangleLeft  = "◀"
	TriangleUp    = "▲"
	TriangleDown  = "▼"
)
View Source
const (
	SmallTriangleRight = "▸"
	SmallTriangleLeft  = "◂"
	SmallTriangleUp    = "▴"
	SmallTriangleDown  = "▾"
)
View Source
const (
	LineDiagonalCross         = "╳"
	LineDiagonalbackwards     = "╲"
	LineDiagonal              = "╱"
	LineVerticalDashed        = "┆"
	LineVerticalDashedHeavy   = "┇"
	LineVertical              = "│"
	LineVerticalHeavy         = "┃"
	LineHorizontalDashed      = "┄"
	LineHorizontalDashedHeavy = "┅"
	LineHorizontal            = "─"
	LineHorizontalHeavy       = "━"
)
View Source
const (
	CircleFilled        = "●"
	CircleOutline       = "◯"
	CircleOutlineFilled = "◉"
	CircleDotted        = "◌"
	CircleDoubled       = "◎"
	CircleSmall         = "•"
	CircleHalfLeft      = "◐"
	CircleHalfTop       = "◓"
	CircleHalfRight     = "◑"
	CircleHalfBottom    = "◒"
)
View Source
const (
	ChevronDefault = ""
	ChevronSmall   = "›"
	ChevronHeavy   = "❯"
)
View Source
const (
	DiamondDefault = "◆"
	DiamondOutline = "◇"
)
View Source
const (
	SquareDefault = "■"
	SquareOutline = "☐"
	SquareCrossed = "☒"
)
View Source
const (
	HeartDefault = "❤︎"
	HeartOutline = "♥"
)
View Source
const (
	IconTick        = "✓"
	IconTickSwoosh  = "✔"
	IconCross       = "✖"
	IconCrossSwoosh = "✘"
	IconHome        = "⌂"
	IconNote        = "♪"
	IconWarning     = "⚠"
	IconInfo        = "ℹ"
	IconStar        = "★"
)
View Source
const (
	ShadeLight  = "░"
	ShadeMedium = "▒"
	ShadeHeavy  = "▓"
)
View Source
const (
	SeparatorTop                 = 0
	SeparatorTopBottom           = 1
	SeparatorMid                 = 2
	SeparatorBottom              = 3
	BorderOutside                = 0
	BorderInside                 = 1
	DisplayOrientationDefault    = "default"
	DisplayOrientationHorizontal = "horizontal"
	DisplayOrientationVertical   = "vertical"
	TableCellAlignLeft           = "left"
	TableCellAlignRight          = "right"
	TableCellAlignCenter         = "center"
	DefaultTableCellAlign        = TableCellAlignLeft
)
View Source
const (
	Eol = "\n"
)
View Source
const (
	ShellCompRequestCmd = "__complete"
)

Variables

View Source
var CircleSpinner []string = []string{"◐", "◓", "◑", "◒"}
View Source
var DotSpinner []string = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
View Source
var ErrCancelledSpinner = errors.New("cancelled")

Functions

func AddTheme added in v0.13.0

func AddTheme(set string, tag string, theme *Theme)

func AddThemeSet added in v0.19.1

func AddThemeSet(name string, themeSet map[string]*Theme)

func ArgSetValue added in v0.18.0

func ArgSetValue(arg Arg, token string)

func BgBlack

func BgBlack(text string) string

func BgBlue

func BgBlue(text string) string

func BgCyan

func BgCyan(text string) string

func BgGreen

func BgGreen(text string) string

func BgMagenta

func BgMagenta(text string) string

func BgRed

func BgRed(text string) string

func BgWhite

func BgWhite(text string) string

func BgYellow

func BgYellow(text string) string

func Black

func Black(text string) string

func Blue

func Blue(text string) string

func Bold

func Bold(text string) string

func Box

func Box(title string, body string, footer string, color string, info string) string

func CheckErr added in v0.27.0

func CheckErr(msg any)

func ColorMode

func ColorMode() uint8

func CompError added in v0.27.0

func CompError(msg string)

func CompErrorln added in v0.27.0

func CompErrorln(msg string)

func ConvertFromHexToAnsiColorCode

func ConvertFromHexToAnsiColorCode(mode uint8, hexColor string) (string, error)

func CreateForm added in v0.18.0

func CreateForm(i *Input, o *Output, first *FormStep, steps ...*FormStep) form

func Cyan

func Cyan(text string) string

func Dim

func Dim(text string) string

func Escape

func Escape(s string) string

func EscapeTrailingBackslash

func EscapeTrailingBackslash(s string) string

func FlagAcceptsValue added in v0.18.0

func FlagAcceptsValue(f Flag) bool

func FlagEquals added in v0.18.0

func FlagEquals(f1 Flag, f2 Flag) bool

func FlagHasDefaultValue added in v0.18.0

func FlagHasDefaultValue(f Flag) bool

func FlagIsArray added in v0.18.0

func FlagIsArray(f Flag) bool

func FlagIsNegatable added in v0.18.0

func FlagIsNegatable(f Flag) bool

func FlagRequiresValue added in v0.18.0

func FlagRequiresValue(f Flag) bool

func FlagType added in v0.18.0

func FlagType(f Flag) uint

func FlagValueIsOptional added in v0.18.0

func FlagValueIsOptional(f Flag) bool

func FormatBlock

func FormatBlock(messages []string, style string, large bool) string

func FormatSection

func FormatSection(section string, message string, style string) string

func GetArgArrayValue added in v0.18.0

func GetArgArrayValue(arg Arg) []string

func GetArgStringValue added in v0.18.0

func GetArgStringValue(arg Arg) string

func GetFlagArrayValue added in v0.18.0

func GetFlagArrayValue(f any) []string

func GetFlagBoolValue added in v0.18.0

func GetFlagBoolValue(f any) bool

func GetFlagStringValue added in v0.18.0

func GetFlagStringValue(f any) string

func GetStyleTags added in v0.19.1

func GetStyleTags() []string

func Gray

func Gray(text string) string

func Green

func Green(text string) string

func HasColorSupport

func HasColorSupport() bool

func Hidden

func Hidden(text string) string

func Inverse

func Inverse(text string) string

func Italic

func Italic(text string) string

func Longest added in v0.19.1

func Longest(lines []string, minWidth int, padding int) int

func Magenta

func Magenta(text string) string

func MbSplit added in v0.19.1

func MbSplit(s string, length int) []string

func MbSubstr added in v0.19.1

func MbSubstr(s string, start int, length int) string

func Pad added in v0.19.1

func Pad(text string, length int, char string) string

Pads while ignoring escape sequences

func PadCenter added in v0.19.1

func PadCenter(text string, length int, char string) string

func PadEnd added in v0.19.1

func PadEnd(text string, length int, char string) string

func PadStart added in v0.19.1

func PadStart(text string, length int, char string) string

func Red

func Red(text string) string

func RegisterTableStyle added in v0.16.0

func RegisterTableStyle(name string, style *TableStyle)

func RenderSpinner added in v0.12.0

func RenderSpinner(s *Spinner) string

func Reset

func Reset(text string) string

func ScrollBar

func ScrollBar(visible []string, firstVisible int, height int, total int, width int, color string) []string

func SetBaseTheme added in v0.15.0

func SetBaseTheme(primary string, accent string)

func SetCurrentThemeSet added in v0.19.1

func SetCurrentThemeSet(name string)

func SetFlagValue added in v0.18.0

func SetFlagValue(f Flag, str string, boolean bool)

func Strikethrough

func Strikethrough(text string) string

func StrimWidth added in v0.19.1

func StrimWidth(str string, start int, width int, trimMarker string) string

func StringToInputArgs

func StringToInputArgs(cmd string) []string

func StripEscapeSequences added in v0.19.1

func StripEscapeSequences(text string) string

func TrimWidthBackwards added in v0.19.1

func TrimWidthBackwards(str string, start int, width int) string

func Truncate

func Truncate(message string, length int, suffix string) string

func TruncateStart added in v0.19.1

func TruncateStart(text string, width int) string

func Underline

func Underline(text string) string

func ValidateArg added in v0.18.0

func ValidateArg(arg Arg) error

func ValidateFlag added in v0.18.0

func ValidateFlag(f Flag) error

func White

func White(text string) string

func WriteStringAndCheck added in v0.27.0

func WriteStringAndCheck(b io.StringWriter, s string)

func Yellow

func Yellow(text string) string

Types

type AnyFunc added in v0.12.0

type AnyFunc func() any

type Arg added in v0.18.0

type Arg interface {
	GetName() string
	GetDescription() string
	IsRequired() bool
	HasValue() bool
	Opts() []string
}

type ArrayArg added in v0.18.0

type ArrayArg struct {
	Name        string
	Description string
	Value       []string
	Min         uint
	Options     []string
	Validator   func([]string) error
}

func (*ArrayArg) GetDescription added in v0.18.0

func (a *ArrayArg) GetDescription() string

func (*ArrayArg) GetName added in v0.18.0

func (a *ArrayArg) GetName() string

func (*ArrayArg) HasValue added in v0.18.0

func (a *ArrayArg) HasValue() bool

func (*ArrayArg) IsRequired added in v0.18.0

func (a *ArrayArg) IsRequired() bool

func (*ArrayArg) Opts added in v0.24.3

func (a *ArrayArg) Opts() []string

type ArrayFlag added in v0.18.0

type ArrayFlag struct {
	Name        string
	Shortcuts   []string
	Description string
	Value       []string
	Validator   func([]string) error
	Options     []string
	// contains filtered or unexported fields
}

func (*ArrayFlag) GetDescription added in v0.18.0

func (f *ArrayFlag) GetDescription() string

func (*ArrayFlag) GetName added in v0.18.0

func (f *ArrayFlag) GetName() string

func (*ArrayFlag) GetShortcutString added in v0.18.0

func (f *ArrayFlag) GetShortcutString() string

func (*ArrayFlag) GetShortcuts added in v0.18.0

func (f *ArrayFlag) GetShortcuts() []string

func (*ArrayFlag) HasValue added in v0.19.0

func (f *ArrayFlag) HasValue() bool

func (*ArrayFlag) Opts added in v0.28.0

func (f *ArrayFlag) Opts() []string

func (*ArrayFlag) WasGiven added in v0.22.0

func (f *ArrayFlag) WasGiven() bool

type ArrayPrompt added in v0.18.0

type ArrayPrompt struct {
	*TextPrompt
	Label        string
	Placeholder  string
	DefaultValue string
	Hint         string
	Values       []string
	// contains filtered or unexported fields
}

func NewArrayPrompt added in v0.18.0

func NewArrayPrompt(i *Input, o *Output, label string, defaultValue []string) *ArrayPrompt

func (*ArrayPrompt) Render added in v0.18.0

func (p *ArrayPrompt) Render() ([]string, error)

func (*ArrayPrompt) String added in v0.18.0

func (p *ArrayPrompt) String() string

type AvailableOption

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

type BoolFlag added in v0.18.0

type BoolFlag struct {
	Name        string
	Shortcuts   []string
	Description string
	Value       bool
	Negatable   bool
	Validator   func(bool) error
	// contains filtered or unexported fields
}

func (*BoolFlag) GetDescription added in v0.18.0

func (f *BoolFlag) GetDescription() string

func (*BoolFlag) GetName added in v0.18.0

func (f *BoolFlag) GetName() string

func (*BoolFlag) GetShortcutString added in v0.18.0

func (f *BoolFlag) GetShortcutString() string

func (*BoolFlag) GetShortcuts added in v0.18.0

func (f *BoolFlag) GetShortcuts() []string

func (*BoolFlag) HasValue added in v0.19.0

func (f *BoolFlag) HasValue() bool

func (*BoolFlag) WasGiven added in v0.22.0

func (f *BoolFlag) WasGiven() bool

type ChildProcess

type ChildProcess struct {
	Cmd    string
	Args   []string
	Shell  string
	Pipe   bool
	Stdin  *os.File
	Stdout *os.File
	Stderr *os.File

	Env []string
	// contains filtered or unexported fields
}

func (*ChildProcess) AddEnv added in v0.14.0

func (cp *ChildProcess) AddEnv(name string, value string)

func (*ChildProcess) Run

func (cp *ChildProcess) Run() (string, error)

func (*ChildProcess) Start

func (cp *ChildProcess) Start() error

func (*ChildProcess) String added in v0.14.1

func (cp *ChildProcess) String() string

func (*ChildProcess) Wait

func (cp *ChildProcess) Wait() error

type Color

type Color struct {
	Foreground string
	Background string
	Options    []string
	// contains filtered or unexported fields
}

func (*Color) Apply

func (c *Color) Apply(text string) string

func (*Color) Set

func (c *Color) Set() string

func (*Color) Unset

func (c *Color) Unset() string

type Command

type Command struct {
	Name                   string
	Description            string
	Version                string
	LongVersion            string
	Aliases                []string
	Help                   string
	Commands               []*Command
	Flags                  []Flag
	Arguments              []Arg
	Run                    CommandHandle
	RunE                   CommandHandleE
	AutoExit               bool
	CatchErrors            bool
	Strict                 bool
	IgnoreValidationErrors bool
	Hidden                 bool
	PromptForInput         bool
	PrintHelpFunc          func(o *Output, command *Command)
	NativeFlags            []string
	CascadeNativeFlags     bool
	// contains filtered or unexported fields
}

func (*Command) AddCommand added in v0.22.0

func (c *Command) AddCommand(command *Command) error

func (*Command) AddUsage

func (c *Command) AddUsage(usage string)

func (*Command) All added in v0.22.0

func (c *Command) All() map[string]*Command

func (*Command) Arg added in v0.27.0

func (c *Command) Arg(name string) (Arg, error)

func (*Command) Definition

func (c *Command) Definition() (*InputDefinition, error)

func (*Command) Execute added in v0.18.0

func (c *Command) Execute(args ...string) (err error)

func (*Command) Exit added in v0.23.0

func (c *Command) Exit(err error)

func (*Command) Flag added in v0.27.0

func (c *Command) Flag(name string) (Flag, error)

func (*Command) FullName added in v0.22.0

func (c *Command) FullName() string

func (*Command) GenZshCompletion added in v0.27.0

func (c *Command) GenZshCompletion(w io.Writer) error

func (*Command) GetHelp added in v0.22.0

func (c *Command) GetHelp() string

func (*Command) HasSubcommands added in v0.22.0

func (c *Command) HasSubcommands() bool

func (*Command) InitDefaultCompletionCmd added in v0.27.0

func (c *Command) InitDefaultCompletionCmd(out *os.File)

func (*Command) Namespace added in v0.22.0

func (c *Command) Namespace() string

func (*Command) Parent added in v0.22.0

func (c *Command) Parent() *Command

func (*Command) ProcessedHelp

func (c *Command) ProcessedHelp() string

func (*Command) RenderError added in v0.22.0

func (c *Command) RenderError(o *Output, err error)

func (*Command) Root added in v0.26.0

func (c *Command) Root() *Command

func (*Command) SetParent added in v0.22.0

func (c *Command) SetParent(parent *Command)

func (*Command) Subcommand added in v0.22.0

func (c *Command) Subcommand(name string) *Command

func (*Command) Subcommands added in v0.27.0

func (c *Command) Subcommands() map[string]*Command

func (*Command) Synopsis

func (c *Command) Synopsis(short bool) string

func (*Command) Usages

func (c *Command) Usages() []string

func (*Command) VisibleSubcommandsCount added in v0.32.2

func (c *Command) VisibleSubcommandsCount() int

type CommandHandle

type CommandHandle func(io *IO)

type CommandHandleE added in v0.18.0

type CommandHandleE func(io *IO) error

type CommandNotFoundError

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

func (*CommandNotFoundError) Alternatives

func (e *CommandNotFoundError) Alternatives() []string

func (*CommandNotFoundError) Error

func (e *CommandNotFoundError) Error() string

type ConfirmPrompt added in v0.18.0

type ConfirmPrompt struct {
	*Prompt
	Label        string
	DefaultValue bool
	Yes          string
	No           string
	Hint         string
	Prefix       string
	Confirmed    bool
}

func NewConfirmPrompt added in v0.18.0

func NewConfirmPrompt(i *Input, o *Output, label string, defaultValue bool) *ConfirmPrompt

func (*ConfirmPrompt) Render added in v0.18.0

func (cp *ConfirmPrompt) Render() (bool, error)

func (*ConfirmPrompt) String added in v0.18.0

func (cp *ConfirmPrompt) String() string

type ConsoleSectionOutput added in v0.16.0

type ConsoleSectionOutput struct {
	*Output
	// contains filtered or unexported fields
}

func NewConsoleSectionOutput added in v0.16.0

func NewConsoleSectionOutput(o *Output, sections []*ConsoleSectionOutput) *ConsoleSectionOutput

func (*ConsoleSectionOutput) AddContent added in v0.16.0

func (c *ConsoleSectionOutput) AddContent(input string, newLine bool) int

func (*ConsoleSectionOutput) AddNewLineOfInputSubmit added in v0.16.0

func (c *ConsoleSectionOutput) AddNewLineOfInputSubmit()

func (*ConsoleSectionOutput) Clear added in v0.16.0

func (c *ConsoleSectionOutput) Clear(lines int)

func (*ConsoleSectionOutput) Content added in v0.16.0

func (c *ConsoleSectionOutput) Content() string

func (*ConsoleSectionOutput) DoWrite added in v0.16.0

func (c *ConsoleSectionOutput) DoWrite(message string, newLine bool)

func (*ConsoleSectionOutput) Overwrite added in v0.16.0

func (c *ConsoleSectionOutput) Overwrite(message string)

func (*ConsoleSectionOutput) OverwriteMany added in v0.16.0

func (c *ConsoleSectionOutput) OverwriteMany(message []string)

func (*ConsoleSectionOutput) SetMaxHeight added in v0.16.0

func (c *ConsoleSectionOutput) SetMaxHeight(maxHeight int)

func (*ConsoleSectionOutput) VisibleContent added in v0.16.0

func (c *ConsoleSectionOutput) VisibleContent() string

type Cursor

type Cursor struct {
	Output *Output
	Input  *os.File
	// contains filtered or unexported fields
}

func (*Cursor) ClearLine

func (c *Cursor) ClearLine() *Cursor

func (*Cursor) ClearLineAfter

func (c *Cursor) ClearLineAfter() *Cursor

func (*Cursor) ClearOutput

func (c *Cursor) ClearOutput() *Cursor

func (*Cursor) ClearScreen

func (c *Cursor) ClearScreen() *Cursor

func (*Cursor) CurrentPosition

func (c *Cursor) CurrentPosition() (int, int)

func (*Cursor) Hide

func (c *Cursor) Hide() *Cursor

func (*Cursor) Move

func (c *Cursor) Move(x int, y int) *Cursor

func (*Cursor) MoveDown

func (c *Cursor) MoveDown(lines int) *Cursor

func (*Cursor) MoveLeft

func (c *Cursor) MoveLeft(columns int) *Cursor

func (*Cursor) MoveRight

func (c *Cursor) MoveRight(columns int) *Cursor

func (*Cursor) MoveToColumn

func (c *Cursor) MoveToColumn(column int) *Cursor

func (*Cursor) MoveToPosition

func (c *Cursor) MoveToPosition(column int, row int) *Cursor

func (*Cursor) MoveUp

func (c *Cursor) MoveUp(lines int) *Cursor

func (*Cursor) RestorePosition

func (c *Cursor) RestorePosition() *Cursor

func (*Cursor) SavePosition

func (c *Cursor) SavePosition() *Cursor

func (*Cursor) Show

func (c *Cursor) Show() *Cursor

type DescriptorOptions

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

type ErrMissingArguments added in v0.21.0

type ErrMissingArguments interface {
	error
	MissingArguments() []string
}

type ErrorWithAlternatives

type ErrorWithAlternatives interface {
	error
	Alternatives() []string
}

func CommandNotFound

func CommandNotFound(message string, alternatives []string) ErrorWithAlternatives

type Flag added in v0.18.0

type Flag interface {
	GetName() string
	GetShortcuts() []string
	GetShortcutString() string
	GetDescription() string
	HasValue() bool
	WasGiven() bool
}

type FormStep added in v0.18.0

type FormStep struct {
	Type        uint
	Label       string
	Placeholder string
	String      *string
	Required    bool
	Bool        *bool
	Array       *[]string
	Values      []string
	Labels      []string
	WaitFunc    func()
	// contains filtered or unexported fields
}

type HasOptions added in v0.28.0

type HasOptions interface {
	Opts() []string
}

type IO added in v0.22.0

type IO struct {
	Command *Command
	Input   *Input
	Output  *Output
	Args    []string
	// contains filtered or unexported fields
}

func (*IO) Alert added in v0.22.0

func (io *IO) Alert(messages ...string)

func (*IO) Array added in v0.22.0

func (io *IO) Array(name string) []string

func (*IO) Ask added in v0.22.0

func (io *IO) Ask(question string, defaultValue string) (string, error)

func (*IO) Bool added in v0.22.0

func (io *IO) Bool(name string) bool

func (*IO) ChildProcess added in v0.22.0

func (io *IO) ChildProcess(cmd string) *ChildProcess

func (*IO) Choice added in v0.22.0

func (io *IO) Choice(question string, choices map[string]string, defaultValue string) (string, error)

func (*IO) Comment added in v0.22.0

func (io *IO) Comment(messages ...string)

func (*IO) Confirm added in v0.22.0

func (io *IO) Confirm(question string, defaultValue bool) (bool, error)

func (*IO) Err added in v0.22.0

func (io *IO) Err(err error)

func (*IO) Error added in v0.22.0

func (io *IO) Error(messages ...string)

func (*IO) Exec added in v0.22.0

func (io *IO) Exec(cmd string, shell string, inherit bool) (string, error)

func (*IO) Info added in v0.22.0

func (io *IO) Info(messages ...string)

func (*IO) IsDebug added in v0.22.0

func (io *IO) IsDebug() bool

func (*IO) IsDecorated added in v0.22.0

func (io *IO) IsDecorated() bool

func (*IO) IsQuiet added in v0.22.0

func (io *IO) IsQuiet() bool

func (*IO) IsVerbose added in v0.22.0

func (io *IO) IsVerbose() bool

func (*IO) IsVeryVerbose added in v0.22.0

func (io *IO) IsVeryVerbose() bool

func (*IO) MultiSelect added in v0.24.0

func (io *IO) MultiSelect(label string, options MultiSelectOptions, defaultValues []string) ([]string, error)

func (*IO) NewLine added in v0.22.0

func (io *IO) NewLine(count uint)

func (*IO) Note added in v0.22.0

func (io *IO) Note(messages ...string)

func (*IO) Ok added in v0.22.0

func (io *IO) Ok(messages ...string)

func (*IO) Search added in v0.23.0

func (io *IO) Search(label string, options func(string) SearchResult, placeholder string) (string, error)

func (*IO) Sh added in v0.22.0

func (io *IO) Sh(cmd string) error

func (*IO) ShPipe added in v0.22.0

func (io *IO) ShPipe(cmd string) (string, error)

func (*IO) Spawn added in v0.22.0

func (io *IO) Spawn(cmd string, shell string, inherit bool) *ChildProcess

func (*IO) Spinner added in v0.22.0

func (io *IO) Spinner(fn func(), message string)

func (*IO) String added in v0.22.0

func (io *IO) String(name string) string

func (*IO) Success added in v0.22.0

func (io *IO) Success(messages ...string)

func (*IO) Table added in v0.27.0

func (io *IO) Table(headers []string, rows [][]*TableCell, options *TableOptions)

func (*IO) TableFromMap added in v0.27.0

func (io *IO) TableFromMap(headers []string, rows []map[string]any, options *TableOptions)

func (*IO) TableFromSlices added in v0.27.0

func (io *IO) TableFromSlices(headers []string, rows [][]any, options *TableOptions)

func (*IO) Tmux added in v0.32.0

func (io *IO) Tmux() Tmux

func (*IO) View added in v0.22.0

func (io *IO) View() *View

func (*IO) Warn added in v0.22.0

func (io *IO) Warn(messages ...string)

func (*IO) WithGracefulExit added in v0.22.0

func (io *IO) WithGracefulExit(fn func(done <-chan bool)) bool

func (*IO) Write added in v0.22.0

func (io *IO) Write(message string)

func (*IO) Writef added in v0.22.0

func (io *IO) Writef(format string, a ...any)

func (*IO) Writeln added in v0.22.0

func (io *IO) Writeln(message string)

func (*IO) Writelnf added in v0.22.0

func (io *IO) Writelnf(format string, a ...any)

func (*IO) Writelns added in v0.22.0

func (io *IO) Writelns(messages []string)

func (*IO) Zsh added in v0.22.0

func (io *IO) Zsh(cmd string) error

func (*IO) ZshPipe added in v0.22.0

func (io *IO) ZshPipe(cmd string) (string, error)

type Input

type Input struct {
	Stream *os.File

	Args []string

	Strict bool
	// contains filtered or unexported fields
}

func NewInput

func NewInput(args ...string) *Input

func (*Input) Arguments

func (i *Input) Arguments() map[string]Arg

func (*Input) Array added in v0.18.0

func (i *Input) Array(name string) ([]string, error)

func (*Input) Bind

func (i *Input) Bind(definition *InputDefinition) error

func (*Input) Bool added in v0.18.0

func (i *Input) Bool(name string) (bool, error)

func (*Input) EscapeToken

func (i *Input) EscapeToken(token string) string

func (*Input) FirstArgument

func (i *Input) FirstArgument() string

func (*Input) FlagProvided added in v0.29.1

func (i *Input) FlagProvided(name string) bool

func (*Input) GivenArguments added in v0.22.0

func (i *Input) GivenArguments() []string

TODO: refactor, use Inspect()

func (*Input) HasArgument

func (i *Input) HasArgument(name string) bool

func (*Input) HasFlag added in v0.18.0

func (i *Input) HasFlag(name string) bool

func (*Input) HasParameterFlag added in v0.18.0

func (i *Input) HasParameterFlag(value string, onlyParams bool) bool

func (*Input) Inspect added in v0.27.0

func (i *Input) Inspect(tokens []string) (InputInspector, error)

func (*Input) IsInteractive

func (i *Input) IsInteractive() bool

func (*Input) ParameterFlag added in v0.18.0

func (i *Input) ParameterFlag(value string, defaultValue InputType, onlyParams bool) InputType

func (*Input) RestoreTty added in v0.21.0

func (i *Input) RestoreTty() error

func (*Input) SetArgument

func (i *Input) SetArgument(name string, token string) error

func (*Input) SetDefinition

func (i *Input) SetDefinition(definition *InputDefinition) error

func (*Input) SetFlag added in v0.18.0

func (i *Input) SetFlag(name string, str string, boolean bool) error

func (*Input) SetInteractive

func (i *Input) SetInteractive(interactive bool)

func (*Input) SetTty added in v0.21.0

func (i *Input) SetTty(mode string) (string, error)

func (*Input) String

func (i *Input) String(name string) (string, error)

func (*Input) Validate

func (i *Input) Validate() error

type InputDefinition

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

func (*InputDefinition) AddArgument

func (d *InputDefinition) AddArgument(argument Arg) error

func (*InputDefinition) AddArguments

func (d *InputDefinition) AddArguments(arguments []Arg) error

func (*InputDefinition) AddFlag added in v0.18.0

func (d *InputDefinition) AddFlag(flag Flag) error

func (*InputDefinition) AddFlags added in v0.18.0

func (d *InputDefinition) AddFlags(flags []Flag) error

func (*InputDefinition) Argument

func (d *InputDefinition) Argument(name string) (Arg, error)

func (*InputDefinition) ArgumentByIndex

func (d *InputDefinition) ArgumentByIndex(index uint) (Arg, error)

func (*InputDefinition) ArgumentCount

func (d *InputDefinition) ArgumentCount() int

func (*InputDefinition) ArgumentRequiredCount

func (d *InputDefinition) ArgumentRequiredCount() int

func (*InputDefinition) Flag added in v0.18.0

func (d *InputDefinition) Flag(name string) (Flag, error)

func (*InputDefinition) FlagForShortcut added in v0.18.0

func (d *InputDefinition) FlagForShortcut(shortcut string) (Flag, error)

func (*InputDefinition) GetArguments

func (d *InputDefinition) GetArguments() []Arg

func (*InputDefinition) GetFlags added in v0.18.0

func (d *InputDefinition) GetFlags() []Flag

func (*InputDefinition) HasArgument

func (d *InputDefinition) HasArgument(name string) bool

func (*InputDefinition) HasFlag added in v0.18.0

func (d *InputDefinition) HasFlag(name string) bool

func (*InputDefinition) HasNegation

func (d *InputDefinition) HasNegation(name string) bool

func (*InputDefinition) HasShortcut

func (d *InputDefinition) HasShortcut(name string) bool

func (*InputDefinition) NegationToName

func (d *InputDefinition) NegationToName(negation string) string

func (*InputDefinition) SetArguments

func (d *InputDefinition) SetArguments(arguments []Arg) error

func (*InputDefinition) SetDefinition

func (d *InputDefinition) SetDefinition(arguments []Arg, flags []Flag) error

func (*InputDefinition) SetFlags added in v0.18.0

func (d *InputDefinition) SetFlags(flags []Flag) error

func (*InputDefinition) ShortcutToName

func (d *InputDefinition) ShortcutToName(shortcut string) string

func (*InputDefinition) Synopsis

func (d *InputDefinition) Synopsis(short bool) string

type InputInspector added in v0.27.0

type InputInspector struct {
	Args  []string
	Flags map[string][]string
	// contains filtered or unexported fields
}

func (*InputInspector) AddArg added in v0.27.0

func (i *InputInspector) AddArg(value string)

func (*InputInspector) AddFlag added in v0.27.0

func (i *InputInspector) AddFlag(name string, value string)

func (InputInspector) ArgsCount added in v0.27.0

func (i InputInspector) ArgsCount() int

func (InputInspector) FlagIsGiven added in v0.28.0

func (i InputInspector) FlagIsGiven(flag Flag) bool

func (InputInspector) FlagsCount added in v0.27.0

func (i InputInspector) FlagsCount() int

func (InputInspector) String added in v0.28.0

func (i InputInspector) String() string

type InputParser

type InputParser func(self any) error

type InputType

type InputType any

type InputValidator

type InputValidator func(value InputType) error

type Listener added in v0.12.0

type Listener func(key string)

type Logger added in v0.21.0

type Logger interface {
	Debug(message string)
	Debugc(message string, ctx any)
	Debugf(format string, args ...any)
	Info(message string)
	Infoc(message string, ctx any)
	Infof(format string, args ...any)
	Notice(message string)
	Noticec(message string, ctx any)
	Noticef(format string, args ...any)
	Warn(message string)
	Warnc(message string, ctx any)
	Warnf(format string, args ...any)
	Error(message string)
	Errorc(message string, ctx any)
	Errorf(format string, args ...any)
	Critical(message string)
	Criticalc(message string, ctx any)
	Criticalf(format string, args ...any)
	Alert(message string)
	Alertc(message string, ctx any)
	Alertf(format string, args ...any)
	Fatal(message string)
	Fatalc(message string, ctx any)
	Fatalf(format string, args ...any)
	EnableDebug()
	SetLogLevel(level int)
}

func NewLogger added in v0.21.0

func NewLogger(o *Output, level int) Logger

type MultiSelectOptions added in v0.24.1

type MultiSelectOptions interface{}

[]string or map[string]string

type MultiSelectPrompt added in v0.24.1

type MultiSelectPrompt struct {
	*Prompt
	Label string
	Hint  string
	// contains filtered or unexported fields
}

func NewMultiSelectPrompt added in v0.24.1

func NewMultiSelectPrompt(i *Input, o *Output, label string, options MultiSelectOptions, defaultValues []string) *MultiSelectPrompt

func (*MultiSelectPrompt) IsHighlighted added in v0.24.1

func (p *MultiSelectPrompt) IsHighlighted(value string) bool

func (*MultiSelectPrompt) IsSelected added in v0.24.1

func (p *MultiSelectPrompt) IsSelected(value string) bool

func (*MultiSelectPrompt) Render added in v0.24.1

func (p *MultiSelectPrompt) Render() ([]string, error)

func (*MultiSelectPrompt) SelectedLabels added in v0.24.1

func (p *MultiSelectPrompt) SelectedLabels() []string

func (*MultiSelectPrompt) SetRequired added in v0.24.1

func (p *MultiSelectPrompt) SetRequired()

func (*MultiSelectPrompt) View added in v0.24.1

func (p *MultiSelectPrompt) View() string

func (*MultiSelectPrompt) Visible added in v0.24.1

func (p *MultiSelectPrompt) Visible() []string

type OptionalArrayFlag added in v0.18.0

type OptionalArrayFlag struct {
	Name        string
	Shortcuts   []string
	Description string
	Boolean     bool
	Value       []string
	Validator   func(bool, []string) error
	Options     []string
	// contains filtered or unexported fields
}

func (*OptionalArrayFlag) GetDescription added in v0.18.0

func (f *OptionalArrayFlag) GetDescription() string

func (*OptionalArrayFlag) GetName added in v0.18.0

func (f *OptionalArrayFlag) GetName() string

func (*OptionalArrayFlag) GetShortcutString added in v0.18.0

func (f *OptionalArrayFlag) GetShortcutString() string

func (*OptionalArrayFlag) GetShortcuts added in v0.18.0

func (f *OptionalArrayFlag) GetShortcuts() []string

func (*OptionalArrayFlag) HasValue added in v0.19.0

func (f *OptionalArrayFlag) HasValue() bool

func (*OptionalArrayFlag) Opts added in v0.28.0

func (f *OptionalArrayFlag) Opts() []string

func (*OptionalArrayFlag) WasGiven added in v0.22.0

func (f *OptionalArrayFlag) WasGiven() bool

type OptionalStringFlag added in v0.18.0

type OptionalStringFlag struct {
	Name        string
	Shortcuts   []string
	Description string
	Boolean     bool
	Value       string
	Validator   func(bool, string) error
	Options     []string
	// contains filtered or unexported fields
}

func (*OptionalStringFlag) GetDescription added in v0.18.0

func (f *OptionalStringFlag) GetDescription() string

func (*OptionalStringFlag) GetName added in v0.18.0

func (f *OptionalStringFlag) GetName() string

func (*OptionalStringFlag) GetShortcutString added in v0.18.0

func (f *OptionalStringFlag) GetShortcutString() string

func (*OptionalStringFlag) GetShortcuts added in v0.18.0

func (f *OptionalStringFlag) GetShortcuts() []string

func (*OptionalStringFlag) HasValue added in v0.19.0

func (f *OptionalStringFlag) HasValue() bool

func (*OptionalStringFlag) Opts added in v0.28.0

func (f *OptionalStringFlag) Opts() []string

func (*OptionalStringFlag) WasGiven added in v0.22.0

func (f *OptionalStringFlag) WasGiven() bool

type Output

type Output struct {
	Stream *os.File
	Stderr *Output

	Logger
	// contains filtered or unexported fields
}

func NewOutput

func NewOutput(input *Input) *Output

func (*Output) Ask

func (o *Output) Ask(question string, defaultValue string) (string, error)

func (*Output) Block added in v0.11.0

func (o *Output) Block(messages []string, tag string, escape bool)

func (*Output) Box

func (o *Output) Box(title string, body string, footer string, color string, info string)

func (*Output) Caution

func (o *Output) Caution(messages ...string)

func (*Output) Choice

func (o *Output) Choice(question string, choices map[string]string, defaultValue string) (string, error)

func (*Output) Comment added in v0.11.0

func (o *Output) Comment(messages ...string)

func (*Output) Confirm

func (o *Output) Confirm(q string, defaultValue bool) (bool, error)

func (*Output) CreateBlock added in v0.21.0

func (o *Output) CreateBlock(messages []string, tag string, theme *Theme, escape bool) []string

func (*Output) CreateTable added in v0.16.0

func (o *Output) CreateTable(headers []string, rows [][]*TableCell, options *TableOptions) *Table

func (*Output) CreateTableRowsFromMaps added in v0.16.0

func (o *Output) CreateTableRowsFromMaps(headers []string, rows []map[string]any) [][]*TableCell

func (*Output) CreateTableRowsFromSlices added in v0.16.0

func (o *Output) CreateTableRowsFromSlices(rows [][]any) [][]*TableCell

func (*Output) DoWrite

func (o *Output) DoWrite(message string, newLine bool)

func (*Output) Err

func (o *Output) Err(err error)

func (*Output) Error added in v0.19.0

func (o *Output) Error(messages ...string)

func (*Output) Format added in v0.21.0

func (o *Output) Format(message string) string

func (*Output) Formatf added in v0.21.0

func (o *Output) Formatf(format string, args ...any) string

func (*Output) Formatter

func (o *Output) Formatter() *OutputFormatter

func (*Output) Info

func (o *Output) Info(messages ...string)

func (*Output) IsDebug

func (o *Output) IsDebug() bool

func (*Output) IsDecorated

func (o *Output) IsDecorated() bool

func (*Output) IsQuiet

func (o *Output) IsQuiet() bool

func (*Output) IsVerbose

func (o *Output) IsVerbose() bool

func (*Output) IsVeryVerbose

func (o *Output) IsVeryVerbose() bool

func (*Output) Listing

func (o *Output) Listing(elements []string, prefix string)

func (*Output) MultiSelect added in v0.24.0

func (o *Output) MultiSelect(label string, options MultiSelectOptions, defaultValues []string) ([]string, error)

func (*Output) NewLine

func (o *Output) NewLine(count int)

func (*Output) Note

func (o *Output) Note(messages ...string)

func (*Output) Ok added in v0.19.0

func (o *Output) Ok(messages ...string)

func (*Output) ProgressAdvance

func (o *Output) ProgressAdvance(step uint)

TODO: impl

func (*Output) ProgressFinish

func (o *Output) ProgressFinish()

TODO: impl

func (*Output) ProgressStart

func (o *Output) ProgressStart(max uint)

TODO: impl

func (*Output) Search added in v0.23.0

func (o *Output) Search(label string, options func(string) SearchResult, placeholder string) (string, error)

func (*Output) Section

func (o *Output) Section(message string)

func (*Output) SetDecorated

func (o *Output) SetDecorated(decorated bool)

func (*Output) SetFormatter

func (o *Output) SetFormatter(formatter *OutputFormatter)

func (*Output) SetVerbosity

func (o *Output) SetVerbosity(verbose uint)

func (*Output) Success

func (o *Output) Success(messages ...string)

func (*Output) Table

func (o *Output) Table(headers []string, rows [][]*TableCell, options *TableOptions)

func (*Output) TableFromMap added in v0.16.0

func (o *Output) TableFromMap(headers []string, rows []map[string]any, options *TableOptions)

func (*Output) TableFromSlices added in v0.16.0

func (o *Output) TableFromSlices(headers []string, rows [][]any, options *TableOptions)

func (*Output) Text

func (o *Output) Text(messages ...string)

func (*Output) Title

func (o *Output) Title(message string)

func (*Output) Verbosity

func (o *Output) Verbosity() uint

func (*Output) Warning

func (o *Output) Warning(messages ...string)

func (*Output) Write

func (o *Output) Write(message string, newLine bool, options uint)

func (*Output) WriteMany

func (o *Output) WriteMany(messages []string, newLine bool, options uint)

func (*Output) Writeln

func (o *Output) Writeln(s string, options uint)

func (*Output) Writelnf added in v0.12.0

func (o *Output) Writelnf(f string, options uint, args ...any)

func (*Output) Writelns

func (o *Output) Writelns(s []string, options uint)

type OutputFormatter

type OutputFormatter struct {
	Decorated  bool
	Styles     map[string]*OutputFormatterStyle
	StyleStack *OutputFormatterStyleStack
}

func (*OutputFormatter) Clone

func (o *OutputFormatter) Clone() *OutputFormatter

func (*OutputFormatter) Format

func (o *OutputFormatter) Format(message string) string

func (*OutputFormatter) FormatAndWrap

func (o *OutputFormatter) FormatAndWrap(message string, width int) string

func (*OutputFormatter) HasStyle

func (o *OutputFormatter) HasStyle(name string) bool

func (*OutputFormatter) RemoveDecoration

func (o *OutputFormatter) RemoveDecoration(str string) string

func (*OutputFormatter) SetStyle

func (o *OutputFormatter) SetStyle(name string, style *OutputFormatterStyle)

func (*OutputFormatter) Style

func (o *OutputFormatter) Style(name string) (*OutputFormatterStyle, error)

type OutputFormatterStyle

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

func NewOutputFormatterStyle

func NewOutputFormatterStyle(foreground string, background string, options []string) *OutputFormatterStyle

func (*OutputFormatterStyle) Apply

func (s *OutputFormatterStyle) Apply(text string) string

func (*OutputFormatterStyle) Clone

func (*OutputFormatterStyle) SetBackground

func (s *OutputFormatterStyle) SetBackground(c string)

func (*OutputFormatterStyle) SetForeground

func (s *OutputFormatterStyle) SetForeground(c string)

func (*OutputFormatterStyle) SetHref

func (s *OutputFormatterStyle) SetHref(href string)

func (*OutputFormatterStyle) SetOption

func (s *OutputFormatterStyle) SetOption(option string)

func (*OutputFormatterStyle) SetOptions

func (s *OutputFormatterStyle) SetOptions(options []string)

func (*OutputFormatterStyle) UnsetOption

func (s *OutputFormatterStyle) UnsetOption(option string)

type OutputFormatterStyleStack

type OutputFormatterStyleStack struct {
	Styles     []*OutputFormatterStyle
	EmptyStyle *OutputFormatterStyle
}

func (*OutputFormatterStyleStack) Clone

func (*OutputFormatterStyleStack) Current

func (*OutputFormatterStyleStack) Pop

func (*OutputFormatterStyleStack) Push

func (*OutputFormatterStyleStack) Reset

func (s *OutputFormatterStyleStack) Reset()

type OutputTheme

type OutputTheme map[string]*OutputFormatterStyle

type PausePrompt added in v0.18.0

type PausePrompt struct {
	*Prompt
	Message string
}

func NewPausePrompt added in v0.18.0

func NewPausePrompt(i *Input, o *Output, message string) *PausePrompt

func (*PausePrompt) Render added in v0.18.0

func (p *PausePrompt) Render() (bool, error)

func (*PausePrompt) String added in v0.18.0

func (p *PausePrompt) String() string

type Prompt added in v0.12.0

type Prompt struct {
	*View
	State         uint
	Error         string
	CancelMessage string
	Validator     func(string) string
	GetValue      func() string

	CancelUsingFn   AnyFunc
	ValidateUsingFn func(any) string
	RevertUsingFn   AnyFunc

	// Value tracking
	AllowNewLine bool
	Submit       bool
	Ignore       func(key string) bool

	// Scrolling
	Highlighted  int
	Scroll       int
	FirstVisible int
	Required     bool
	// contains filtered or unexported fields
}

func NewPrompt added in v0.12.0

func NewPrompt(i *Input, o *Output) *Prompt

func (*Prompt) AddCursor added in v0.21.0

func (p *Prompt) AddCursor(value string, cursorPosition int, maxWidth int) string

func (*Prompt) ClearListeners added in v0.18.0

func (p *Prompt) ClearListeners()

func (*Prompt) CursorPosition added in v0.21.0

func (p *Prompt) CursorPosition() int

func (*Prompt) Highlight added in v0.21.0

func (p *Prompt) Highlight(index int)

func (*Prompt) HighlightNext added in v0.21.0

func (p *Prompt) HighlightNext(total int)

func (*Prompt) HighlightPrevious added in v0.21.0

func (p *Prompt) HighlightPrevious(total int)

func (*Prompt) InitializeScrolling added in v0.21.0

func (p *Prompt) InitializeScrolling(highlighted int, reservedLines int)

func (*Prompt) ReduceScrollingToFitTerminal added in v0.21.0

func (p *Prompt) ReduceScrollingToFitTerminal(reservedLines int)

func (*Prompt) Reset added in v0.21.0

func (p *Prompt) Reset()

func (*Prompt) Resetvalue added in v0.21.0

func (p *Prompt) Resetvalue()

func (*Prompt) Restore added in v0.12.0

func (p *Prompt) Restore(force bool)

func (*Prompt) ScrollToHighlighted added in v0.21.0

func (p *Prompt) ScrollToHighlighted(total int)

func (*Prompt) SetValue added in v0.21.0

func (p *Prompt) SetValue(value string)

func (*Prompt) Submitted added in v0.21.0

func (p *Prompt) Submitted() bool

func (*Prompt) Track added in v0.21.0

func (p *Prompt) Track(key string)

func (*Prompt) TypedValue added in v0.21.0

func (p *Prompt) TypedValue() string

type Renderer added in v0.12.0

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

func NewRenderer added in v0.12.0

func NewRenderer() *Renderer

func (*Renderer) Err added in v0.12.0

func (r *Renderer) Err(message string)

func (*Renderer) Hint added in v0.12.0

func (r *Renderer) Hint(message string)

func (*Renderer) Line added in v0.12.0

func (r *Renderer) Line(message string, newLine bool)

func (*Renderer) NewLine added in v0.12.0

func (r *Renderer) NewLine(count int)

func (*Renderer) ToString added in v0.12.0

func (r *Renderer) ToString(state uint) string

func (*Renderer) Warning added in v0.12.0

func (r *Renderer) Warning(message string)

func (*Renderer) When added in v0.12.0

func (r *Renderer) When(condition bool, cb func(*Renderer), defaultCb func(*Renderer))

type RendererInterface added in v0.12.0

type RendererInterface interface {
	Render(prompt any)
	String() string
}

func NewSpinnerRenderer added in v0.12.0

func NewSpinnerRenderer(s *Spinner) RendererInterface

type SearchPrompt added in v0.23.0

type SearchPrompt struct {
	*Prompt
	Label       string
	Options     func(string) SearchResult
	Placeholder string
	Hint        string
	// contains filtered or unexported fields
}

func NewSearchPrompt added in v0.23.0

func NewSearchPrompt(i *Input, o *Output, label string, options func(string) SearchResult, placeholder string) *SearchPrompt

func (*SearchPrompt) Matches added in v0.23.0

func (p *SearchPrompt) Matches() []string

func (*SearchPrompt) Render added in v0.23.0

func (p *SearchPrompt) Render() (string, error)

func (*SearchPrompt) SearchValue added in v0.23.0

func (p *SearchPrompt) SearchValue() string

func (*SearchPrompt) SelectedLabel added in v0.23.0

func (p *SearchPrompt) SelectedLabel() string

func (*SearchPrompt) ValueWithCursor added in v0.23.0

func (p *SearchPrompt) ValueWithCursor(maxWidth int) string

func (*SearchPrompt) ValueWithCursorAndSearchcon added in v0.23.0

func (p *SearchPrompt) ValueWithCursorAndSearchcon(maxWidth int) string

func (*SearchPrompt) View added in v0.23.0

func (p *SearchPrompt) View() string

func (*SearchPrompt) Visible added in v0.23.0

func (p *SearchPrompt) Visible() []string

type SearchResult added in v0.23.0

type SearchResult interface{}

May be a map[string]string or []string

type SelectPrompt added in v0.18.0

type SelectPrompt struct {
	*Prompt
	Label        string
	Values       []string
	Labels       []string
	DefaultValue string
	Scroll       int
	Hint         string
}

func NewSelectPrompt added in v0.18.0

func NewSelectPrompt(i *Input, o *Output, label string, values []string, labels []string, defaultValue string) *SelectPrompt

func (*SelectPrompt) GetLabel added in v0.18.0

func (p *SelectPrompt) GetLabel() string

func (*SelectPrompt) Render added in v0.18.0

func (p *SelectPrompt) Render() (string, error)

func (*SelectPrompt) String added in v0.18.0

func (p *SelectPrompt) String() string

func (*SelectPrompt) Visible added in v0.18.0

func (p *SelectPrompt) Visible() []string

type ShellCompDirective added in v0.27.0

type ShellCompDirective int
const (
	// ShellCompDirectiveError indicates an error occurred and completions should be ignored.
	ShellCompDirectiveError ShellCompDirective = 1 << iota

	// ShellCompDirectiveNoSpace indicates that the shell should not add a space
	// after the completion even if there is a single completion provided.
	ShellCompDirectiveNoSpace

	// ShellCompDirectiveNoFileComp indicates that the shell should not provide
	// file completion even when no completion is provided.
	ShellCompDirectiveNoFileComp

	// ShellCompDirectiveFilterFileExt indicates that the provided completions
	// should be used as file extension filters.
	// For flags, using Command.MarkFlagFilename() and Command.MarkPersistentFlagFilename()
	// is a shortcut to using this directive explicitly.  The BashCompFilenameExt
	// annotation can also be used to obtain the same behavior for flags.
	ShellCompDirectiveFilterFileExt

	// ShellCompDirectiveFilterDirs indicates that only directory names should
	// be provided in file completion.  To request directory names within another
	// directory, the returned completions should specify the directory within
	// which to search.  The BashCompSubdirsInDir annotation can be used to
	// obtain the same behavior but only for flags.
	ShellCompDirectiveFilterDirs

	// ShellCompDirectiveKeepOrder indicates that the shell should preserve the order
	// in which the completions are provided
	ShellCompDirectiveKeepOrder

	// ShellCompDirectiveDefault indicates to let the shell perform its default
	// behavior after completions have been provided.
	// This one must be last to avoid messing up the iota count.
	ShellCompDirectiveDefault ShellCompDirective = 0
)

type Spinner added in v0.12.0

type Spinner struct {
	*Prompt
	Interval          int
	Count             int
	Message           string
	Frames            []string
	Color             string
	KeepRenderedLines bool
}

func NewSpinner added in v0.12.0

func NewSpinner(i *Input, o *Output, message string, frames []string, color string) *Spinner

func (*Spinner) Spin added in v0.12.0

func (s *Spinner) Spin(fn func())

type SpinnerFrame added in v0.20.0

type SpinnerFrame struct {
	Frames []string
	// contains filtered or unexported fields
}

func (*SpinnerFrame) Next added in v0.20.0

func (s *SpinnerFrame) Next() string

type StringArg added in v0.18.0

type StringArg struct {
	Name        string
	Description string
	Value       string
	Required    bool
	Options     []string
	Validator   func(string) error
}

func (*StringArg) GetDescription added in v0.18.0

func (a *StringArg) GetDescription() string

func (*StringArg) GetName added in v0.18.0

func (a *StringArg) GetName() string

func (*StringArg) HasValue added in v0.18.0

func (a *StringArg) HasValue() bool

func (*StringArg) IsRequired added in v0.18.0

func (a *StringArg) IsRequired() bool

func (*StringArg) Opts added in v0.24.3

func (a *StringArg) Opts() []string

type StringFlag added in v0.18.0

type StringFlag struct {
	Name        string
	Shortcuts   []string
	Description string
	Value       string
	Validator   func(string) error
	Options     []string
	// contains filtered or unexported fields
}

func (*StringFlag) GetDescription added in v0.18.0

func (f *StringFlag) GetDescription() string

func (*StringFlag) GetName added in v0.18.0

func (f *StringFlag) GetName() string

func (*StringFlag) GetShortcutString added in v0.18.0

func (f *StringFlag) GetShortcutString() string

func (*StringFlag) GetShortcuts added in v0.18.0

func (f *StringFlag) GetShortcuts() []string

func (*StringFlag) HasValue added in v0.19.0

func (f *StringFlag) HasValue() bool

func (*StringFlag) Opts added in v0.28.0

func (f *StringFlag) Opts() []string

func (*StringFlag) WasGiven added in v0.22.0

func (f *StringFlag) WasGiven() bool

type Table added in v0.16.0

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

func NewTable added in v0.16.0

func NewTable(o *Output) *Table

func (*Table) AddRow added in v0.16.0

func (t *Table) AddRow(rows []*TableCell)

func (*Table) AddRows added in v0.16.0

func (t *Table) AddRows(rows [][]*TableCell)

func (*Table) AppendRow added in v0.16.0

func (t *Table) AppendRow(row []*TableCell)

func (*Table) ColumnStyle added in v0.16.0

func (t *Table) ColumnStyle(columnIndex int) *TableStyle

func (*Table) Render added in v0.16.0

func (t *Table) Render()

func (*Table) SetColumnMaxWidth added in v0.16.0

func (t *Table) SetColumnMaxWidth(columnIndex int, maxWidth int)

func (*Table) SetColumnStyle added in v0.16.0

func (t *Table) SetColumnStyle(i uint, style *TableStyle)

func (*Table) SetColumnStyleByName added in v0.16.0

func (t *Table) SetColumnStyleByName(i uint, name string)

func (*Table) SetColumnWidth added in v0.16.0

func (t *Table) SetColumnWidth(columnIndex int, width int)

func (*Table) SetColumnWidths added in v0.16.0

func (t *Table) SetColumnWidths(widths []int)

func (*Table) SetFooterTitle added in v0.16.0

func (t *Table) SetFooterTitle(title string)

func (*Table) SetHeaderTitle added in v0.16.0

func (t *Table) SetHeaderTitle(title string)

func (*Table) SetHeaders added in v0.16.0

func (t *Table) SetHeaders(headers []string)

func (*Table) SetHorizontal added in v0.16.0

func (t *Table) SetHorizontal(horizontal bool)

func (*Table) SetRow added in v0.16.0

func (t *Table) SetRow(columnIndex int, row []*TableCell)

func (*Table) SetRows added in v0.16.0

func (t *Table) SetRows(rows [][]*TableCell)

func (*Table) SetStyle added in v0.16.0

func (t *Table) SetStyle(style *TableStyle)

func (*Table) SetStyleByName added in v0.16.0

func (t *Table) SetStyleByName(style string)

func (*Table) SetVertical added in v0.16.0

func (t *Table) SetVertical(vertical bool)

func (*Table) Style added in v0.16.0

func (t *Table) Style() *TableStyle

type TableCell added in v0.16.0

type TableCell struct {
	Value       string
	RowSpan     int
	ColSpan     int
	Style       *TableCellStyle
	IsSeparator bool
}

func NewTableCell added in v0.16.0

func NewTableCell(value string) *TableCell

func NewTableSeparator added in v0.16.0

func NewTableSeparator() *TableCell

func (*TableCell) String added in v0.16.0

func (c *TableCell) String() string

type TableCellStyle added in v0.16.0

type TableCellStyle struct {
	Foreground string
	Background string
	Options    []string
	// left, center or right
	Align      string
	CellFormat string
}

type TableOptions added in v0.16.0

type TableOptions struct {
	DisplayOrientation string
	HeaderTitle        string
	FooterTitle        string
	Style              string
	Align              string
}

type TableStyle added in v0.16.0

type TableStyle struct {
	PaddingChar                 string
	HorizontalOutsideBorderChar string
	HorizontalInsideBorderChar  string
	VerticalOutsideBorderChar   string
	VerticalInsideBorderChar    string
	CrossingChar                string
	CrossingTopRightChar        string
	CrossingTopMidChar          string
	CrossingTopLeftChar         string
	CrossingMidRightChar        string
	CrossingBottomRightChar     string
	CrossingBottomMidChar       string
	CrossingBottomLeftChar      string
	CrossingMidLeftChar         string
	CrossingTopLeftBottomChar   string
	CrossingTopMidBottomChar    string
	CrossingTopRightBottomChar  string
	HeaderTitleFormat           string
	FooterTitleFormat           string
	CellHeaderFormat            string
	CellRowFormat               string
	CellRowContentFormat        string
	BorderFormat                string
	PadType                     string
}

func NewTableStyle added in v0.16.0

func NewTableStyle(name string) *TableStyle

func (*TableStyle) Clone added in v0.16.0

func (ts *TableStyle) Clone() *TableStyle

func (*TableStyle) SetDefaultCrossingChar added in v0.16.0

func (ts *TableStyle) SetDefaultCrossingChar(char string)

type TextDescriptor

type TextDescriptor struct {
	Output *Output
}

func (*TextDescriptor) DescribeArgument added in v0.18.0

func (d *TextDescriptor) DescribeArgument(argument Arg, options *DescriptorOptions)

func (*TextDescriptor) DescribeCommand

func (d *TextDescriptor) DescribeCommand(command *Command, options *DescriptorOptions)

func (*TextDescriptor) DescribeFlag added in v0.18.0

func (d *TextDescriptor) DescribeFlag(flag Flag, options *DescriptorOptions)

func (*TextDescriptor) DescribeInputDefinition

func (d *TextDescriptor) DescribeInputDefinition(definition *InputDefinition, options *DescriptorOptions)

func (*TextDescriptor) Write

func (d *TextDescriptor) Write(content string, decorated bool)

type TextPrompt added in v0.18.0

type TextPrompt struct {
	*Prompt
	Label        string
	Placeholder  string
	DefaultValue string
	Hint         string
}

func NewTextPrompt added in v0.18.0

func NewTextPrompt(i *Input, o *Output, label string, defaultValue string) *TextPrompt

func (*TextPrompt) Render added in v0.18.0

func (p *TextPrompt) Render() (string, error)

func (*TextPrompt) ValueWithCursor added in v0.18.0

func (p *TextPrompt) ValueWithCursor(maxWidth int) string

func (*TextPrompt) View added in v0.21.0

func (p *TextPrompt) View() string

type Theme added in v0.13.0

type Theme struct {
	Foreground   string
	Background   string
	Options      []string
	Icon         string
	Label        string
	FullyColored bool
	Padding      bool
	LogFormatter logFormatter
	// contains filtered or unexported fields
}

func GetTheme added in v0.19.1

func GetTheme(tag string) (*Theme, error)

func (*Theme) GetStyle added in v0.19.1

func (t *Theme) GetStyle() *OutputFormatterStyle

type Tmux added in v0.32.0

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

func (Tmux) AttachSessionCommand added in v0.32.0

func (t Tmux) AttachSessionCommand(session string) string

func (Tmux) CreateSplitWindowCommand added in v0.32.1

func (t Tmux) CreateSplitWindowCommand(session string, window string, keys []string) string

func (Tmux) Exec added in v0.32.0

func (t Tmux) Exec(cmd string) error

func (Tmux) ExecMultiple added in v0.32.0

func (t Tmux) ExecMultiple(cmds []string) error

func (Tmux) KillSessionCommand added in v0.32.0

func (t Tmux) KillSessionCommand(session string) string

func (Tmux) KillWindowCommand added in v0.32.0

func (t Tmux) KillWindowCommand(session string, window string) string

func (Tmux) NewDetachedSessionCommand added in v0.32.3

func (t Tmux) NewDetachedSessionCommand(session string) string

func (Tmux) NewSessionCommand added in v0.32.0

func (t Tmux) NewSessionCommand(session string) string

func (Tmux) NewWindowCommand added in v0.32.0

func (t Tmux) NewWindowCommand(session string, window string) string

func (Tmux) RenameWindowCommand added in v0.32.0

func (t Tmux) RenameWindowCommand(session string, window string, name string) string

func (Tmux) SelectPaneCommand added in v0.32.0

func (t Tmux) SelectPaneCommand(session string, window string, pane int) string

func (Tmux) SelectWindowCommand added in v0.32.0

func (t Tmux) SelectWindowCommand(session string, window string) string

func (Tmux) SendKeysCommand added in v0.32.0

func (t Tmux) SendKeysCommand(session string, window string, keys string) string

func (Tmux) SendKeysToPaneCommand added in v0.32.0

func (t Tmux) SendKeysToPaneCommand(session string, window string, pane int, keys string) string

func (Tmux) SessionExists added in v0.32.0

func (t Tmux) SessionExists(session string) bool

func (Tmux) SplitWindowHorizontallyCommand added in v0.32.0

func (t Tmux) SplitWindowHorizontallyCommand(session string, window string) string

func (Tmux) SplitWindowVerticallyCommand added in v0.32.0

func (t Tmux) SplitWindowVerticallyCommand(session string, window string) string

type TrimmedBufferOutput

type TrimmedBufferOutput struct {
	*Output
	// contains filtered or unexported fields
}

func (*TrimmedBufferOutput) DoWrite

func (o *TrimmedBufferOutput) DoWrite(message string, newLine bool)

func (*TrimmedBufferOutput) Fetch

func (o *TrimmedBufferOutput) Fetch() string

type View added in v0.21.0

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

func NewView added in v0.21.0

func NewView(o *Output) *View

func (*View) Clear added in v0.21.0

func (v *View) Clear()

func (*View) HideCursor added in v0.21.0

func (v *View) HideCursor()

func (*View) Render added in v0.21.0

func (v *View) Render(frame string)

func (*View) RenderLine added in v0.21.0

func (v *View) RenderLine(frame string)

func (*View) RenderLinef added in v0.21.0

func (v *View) RenderLinef(format string, args ...any)

func (*View) ShowCursor added in v0.21.0

func (v *View) ShowCursor()

func (*View) Write added in v0.21.0

func (v *View) Write(frame string)

type WaitPrompt added in v0.18.0

type WaitPrompt struct {
	*Spinner
	WaitFunc func() bool
	// contains filtered or unexported fields
}

func NewWaitPrompt added in v0.18.0

func NewWaitPrompt(i *Input, o *Output, waitFunc func() bool, message string) *WaitPrompt

func (*WaitPrompt) Render added in v0.18.0

func (p *WaitPrompt) Render() error

func (*WaitPrompt) String added in v0.18.0

func (p *WaitPrompt) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳