cli

package module
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: MIT Imports: 17 Imported by: 0

README

CLI

A project that attempts to rewrite the PHP package symfony/console (with added features from the Laravel package illuminate/console), to Golang as an exercise, and for personal usage.

Work in progress.

Documentation

Index

Constants

View Source
const (
	InputArgumentRequired = 1
	InputArgumentOptional = 2
	InputArgumentIsArray  = 4
)
View Source
const (
	InputOptionBool      = 1
	InputOptionRequired  = 2
	InputOptionOptional  = 4
	InputOptionIsArray   = 8
	InputOptionNegatable = 16
)
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 ChoiceQuestionDefaultErrorMessage = `Value "%s" is invalid`
View Source
const ChoiceQuestionDefaultPrompt = " > "

Variables

View Source
var DefaultOutputTheme = map[string]*OutputFormatterStyle{
	"error":     NewOutputFormatterStyle("white", "red", nil),
	"info":      NewOutputFormatterStyle("white", "blue", nil),
	"success":   NewOutputFormatterStyle("white", "green", nil),
	"ok":        NewOutputFormatterStyle("white", "green", nil),
	"warn":      NewOutputFormatterStyle("black", "yellow", nil),
	"warning":   NewOutputFormatterStyle("black", "yellow", nil),
	"caution":   NewOutputFormatterStyle("black", "yellow", nil),
	"comment":   NewOutputFormatterStyle("yellow", "", nil),
	"alert":     NewOutputFormatterStyle("red", "", []string{"bold"}),
	"header":    NewOutputFormatterStyle("yellow", "", nil),
	"highlight": NewOutputFormatterStyle("green", "", nil),
	"question":  NewOutputFormatterStyle("black", "cyan", nil),
}
View Source
var TrueAnswerRegex = regexp.MustCompile("(?i)^y")

Functions

func Ask

func Ask[T any](i *Input, o *Output, question QuestionInterface) (T, error)

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 ColorMode

func ColorMode() uint8

func ConvertFromHexToAnsiColorCode

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

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 FormatBlock

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

func FormatSection

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

func Gray

func Gray(text string) string

func Green

func Green(text string) string

func HasColorSupport

func HasColorSupport() bool

func HasInt

func HasInt(c Collection[int], v int) bool

func HasString

func HasString(c Collection[string], v string) bool

func Hidden

func Hidden(text string) string

func InputTypeToArray

func InputTypeToArray(value InputType) []string

func InputTypeToString

func InputTypeToString(value InputType) string

func Inverse

func Inverse(text string) string

func Italic

func Italic(text string) string

func Magenta

func Magenta(text string) string

func Red

func Red(text string) string

func Reduce

func Reduce[T any, U any](c Collection[T], fn func(acc U, cur T, i int) U, initial U) U

func Reset

func Reset(text string) string

func Strikethrough

func Strikethrough(text string) string

func StringToInputArgs

func StringToInputArgs(cmd string) []string

func TerminalHeight

func TerminalHeight() (int, error)

func TerminalIsInteractive

func TerminalIsInteractive() bool

func TerminalSize

func TerminalSize() (int, int, error)

func TerminalWidth

func TerminalWidth() (int, error)

func Truncate

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

func Underline

func Underline(text string) string

func White

func White(text string) string

func Yellow

func Yellow(text string) string

Types

type Application

type Application struct {
	Name           string
	Version        string
	LongVersion    string
	DefaultCommand string

	CatchErrors   bool
	AutoExit      bool
	SingleCommand bool
	// contains filtered or unexported fields
}

func (*Application) Abbreviations

func (app *Application) Abbreviations(names []string) map[string][]string

func (*Application) Add

func (app *Application) Add(commands ...*Command)

func (*Application) AddCommands

func (app *Application) AddCommands(commands []*Command)

func (*Application) All

func (app *Application) All(namespace string) map[string]*Command

func (*Application) Definition

func (app *Application) Definition() *InputDefinition

func (*Application) ExtractNamespace

func (app *Application) ExtractNamespace(name string, limit int) string

func (*Application) Find

func (app *Application) Find(name string) (*Command, error)

func (*Application) FindNamespace

func (app *Application) FindNamespace(namespace string) (string, error)

func (*Application) Get

func (app *Application) Get(name string) (*Command, error)

func (*Application) Has

func (app *Application) Has(name string) bool

func (*Application) Help

func (app *Application) Help() string

func (*Application) Namespaces

func (app *Application) Namespaces() []string

func (*Application) RenderError

func (app *Application) RenderError(o *Output, err error)

func (*Application) Run

func (app *Application) Run(args ...string) (exitCode int, err error)

func (*Application) RunWith

func (app *Application) RunWith(i *Input, o *Output) (exitCode int, err error)

func (*Application) SetDefaultCommand

func (app *Application) SetDefaultCommand(commandName string, isSingleCommand bool) error

func (*Application) SetDefinition

func (app *Application) SetDefinition(definition *InputDefinition)

type ApplicationDescription

type ApplicationDescription struct {
	Application *Application
	Namespace   string
	ShowHidden  bool
	// contains filtered or unexported fields
}

func (*ApplicationDescription) Command

func (d *ApplicationDescription) Command(name string) (*Command, error)

func (*ApplicationDescription) Commands

func (d *ApplicationDescription) Commands() map[string]*Command

func (*ApplicationDescription) Namespaces

func (d *ApplicationDescription) Namespaces() map[string]*NamespaceCommands

type AvailableOption

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

type ChildProcess

type ChildProcess struct {
	Cmd     string
	Args    []string
	Shell   string
	Pipe    bool
	Inherit bool
	Stdin   *os.File
	Stdout  *os.File
	Stderr  *os.File
	// contains filtered or unexported fields
}

func (*ChildProcess) Run

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

func (*ChildProcess) Start

func (cp *ChildProcess) Start() error

func (*ChildProcess) Wait

func (cp *ChildProcess) Wait() error

type ChoiceQuestion

type ChoiceQuestion struct {
	*Question[string]
	Prompt string

	Choices map[string]string
	// contains filtered or unexported fields
}

func (*ChoiceQuestion) DefaultValidator

func (cq *ChoiceQuestion) DefaultValidator() QuestionValidator[string]

func (*ChoiceQuestion) SetErrorMessage

func (cq *ChoiceQuestion) SetErrorMessage(message string)

type Collection

type Collection[T any] []T

func Collect

func Collect[T any](data []T) Collection[T]

func Map

func Map[T any, U any](collection Collection[T], fn func(T) U) Collection[U]

func (Collection[T]) Every

func (c Collection[T]) Every(fn func(T) bool) bool

func (Collection[T]) Filter

func (c Collection[T]) Filter(predicate func(T) bool) Collection[T]

func (Collection[T]) FilterInPlace

func (c Collection[T]) FilterInPlace(predicate func(T) bool) Collection[T]

func (Collection[T]) FilterMapInPlace

func (c Collection[T]) FilterMapInPlace(predicate func(T) bool, mapper func(T) T) Collection[T]

func (Collection[T]) Find

func (c Collection[T]) Find(fn func(T) bool) (T, bool)

func (Collection[T]) Has

func (c Collection[T]) Has(value T, cmp func(T, T) bool) bool

func (Collection[T]) IndexOf

func (c Collection[T]) IndexOf(value T, cmp func(T, T) bool) int

func (Collection[T]) Len

func (c Collection[T]) Len() int

func (Collection[T]) Map

func (c Collection[T]) Map(fn func(T) T) Collection[T]

func (Collection[T]) MapInPlace

func (c Collection[T]) MapInPlace(fn func(T) T) Collection[T]

func (*Collection[T]) PopBack

func (c *Collection[T]) PopBack() T

func (*Collection[T]) PopFront

func (c *Collection[T]) PopFront() T

func (*Collection[T]) PushBack

func (c *Collection[T]) PushBack(v ...T)

func (*Collection[T]) PushFront

func (c *Collection[T]) PushFront(v ...T)

func (Collection[T]) Reverse

func (c Collection[T]) Reverse() Collection[T]

func (Collection[T]) ReverseInPlace

func (c Collection[T]) ReverseInPlace() Collection[T]

func (Collection[T]) Some

func (c Collection[T]) Some(fn func(T) bool) bool

func (Collection[T]) Splice

func (c Collection[T]) Splice(start int, end int) Collection[T]

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 {
	Handle      CommandHandle
	Initializer CommandInitializer
	Interacter  CommandInteracter

	Name        string
	Description string
	Aliases     []string
	Help        string

	Hidden bool

	IgnoreValidationErrors bool
	// contains filtered or unexported fields
}

func (*Command) AddArgument

func (c *Command) AddArgument(arg *InputArgument) *Command

func (*Command) AddOption

func (c *Command) AddOption(option *InputOption) *Command

func (*Command) AddUsage

func (c *Command) AddUsage(usage string) *Command

func (*Command) ApplicationDefinition

func (c *Command) ApplicationDefinition() *InputDefinition

func (*Command) Arguments

func (c *Command) Arguments() map[string]InputType

func (*Command) ArrayArgument

func (c *Command) ArrayArgument(name string) ([]string, error)

func (*Command) ArrayOption

func (c *Command) ArrayOption(name string) ([]string, error)

func (*Command) BoolOption

func (c *Command) BoolOption(name string) (bool, error)

func (*Command) DefineArgument

func (c *Command) DefineArgument(name string, mode InputArgumentMode, description string, defaultValue InputType, validator InputValidator) *Command

func (*Command) DefineOption

func (c *Command) DefineOption(name string, shortcut string, mode InputOptionMode, description string, defaultValue InputType, validator InputValidator) *Command

func (*Command) Definition

func (c *Command) Definition() *InputDefinition

func (*Command) Describe

func (c *Command) Describe(output *Output, options uint)

func (*Command) Exec

func (c *Command) Exec(cmd string, shell string, inherit bool) (string, error)

func (*Command) Fail

func (c *Command) Fail(e string) (int, error)

func (*Command) Input

func (c *Command) Input() *Input

func (*Command) IsEnabled

func (c *Command) IsEnabled() bool

func (*Command) MergeApplication

func (c *Command) MergeApplication(mergeArgs bool)

func (*Command) Meta

func (c *Command) Meta() any

func (*Command) NativeDefinition

func (c *Command) NativeDefinition() *InputDefinition

func (*Command) Options

func (c *Command) Options() map[string]InputType

func (*Command) Output

func (c *Command) Output() *Output

func (*Command) ProcessedHelp

func (c *Command) ProcessedHelp() string

func (*Command) Run

func (c *Command) Run(i *Input, o *Output) (int, error)

func (*Command) SetAliases

func (c *Command) SetAliases(aliases []string) *Command

func (*Command) SetApplicationDefinition

func (c *Command) SetApplicationDefinition(definition *InputDefinition)

func (*Command) SetDefinition

func (c *Command) SetDefinition(definition *InputDefinition)

func (*Command) SetDescription

func (c *Command) SetDescription(description string) *Command

func (*Command) SetHelp

func (c *Command) SetHelp(help string) *Command

func (*Command) SetHidden

func (c *Command) SetHidden(hidden bool) *Command

func (*Command) SetMeta

func (c *Command) SetMeta(meta any)

func (*Command) SetName

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

func (*Command) StringArgument

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

func (*Command) StringOption

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

func (*Command) Synopsis

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

func (*Command) Usages

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

type CommandHandle

type CommandHandle func(self *Command) (int, error)

type CommandInitializer

type CommandInitializer func(input *Input, output *Output)

type CommandInteracter

type CommandInteracter func(input *Input, output *Output)

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 ConfirmationQuestion

type ConfirmationQuestion struct {
	*Question[bool]
	// contains filtered or unexported fields
}

func (*ConfirmationQuestion) DefaultNormalizer

func (q *ConfirmationQuestion) DefaultNormalizer() QuestionNormalizer[bool]

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 ErrorWithAlternatives

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

func CommandNotFound

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

func NamespaceNotFound

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

type Input

type Input struct {
	Tokens []string
	// contains filtered or unexported fields
}

func NewInput

func NewInput(args ...string) *Input

func (*Input) Arguments

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

func (*Input) ArrayArgument

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

func (*Input) ArrayOption

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

func (*Input) Bind

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

func (*Input) BoolOption

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

func (*Input) EscapeToken

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

func (*Input) FirstArgument

func (i *Input) FirstArgument() InputType

func (*Input) HasArgument

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

func (*Input) HasOption

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

func (*Input) HasParameterOption

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

func (*Input) IsInteractive

func (i *Input) IsInteractive() bool

func (*Input) Options

func (i *Input) Options() map[string]InputType

func (*Input) ParameterOption

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

func (*Input) Parse

func (i *Input) Parse() error

func (*Input) SetArgument

func (i *Input) SetArgument(name string, value InputType) error

func (*Input) SetDefinition

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

func (*Input) SetInteractive

func (i *Input) SetInteractive(interactive bool)

func (*Input) SetOption

func (i *Input) SetOption(name string, value InputType) error

func (*Input) SetStream

func (i *Input) SetStream(stream *os.File)

func (*Input) Stream

func (i *Input) Stream() *os.File

func (*Input) String

func (i *Input) String() string

func (*Input) StringArgument

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

func (*Input) StringOption

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

func (*Input) Validate

func (i *Input) Validate() error

type InputArgument

type InputArgument struct {
	Name         string
	Description  string
	Mode         InputArgumentMode
	DefaultValue InputType
	Validator    InputValidator
	// contains filtered or unexported fields
}

func (*InputArgument) Clone

func (a *InputArgument) Clone() *InputArgument

func (*InputArgument) IsArray

func (a *InputArgument) IsArray() bool

func (*InputArgument) IsRequired

func (a *InputArgument) IsRequired() bool

func (*InputArgument) SetDefaultValue

func (a *InputArgument) SetDefaultValue(value InputType) *InputArgument

func (*InputArgument) SetValidator

func (a *InputArgument) SetValidator(validator InputValidator) *InputArgument

type InputArgumentMode

type InputArgumentMode uint8

type InputDefinition

type InputDefinition struct {
	Arguments []*InputArgument
	Options   []*InputOption
	// contains filtered or unexported fields
}

func (*InputDefinition) AddArgument

func (d *InputDefinition) AddArgument(argument *InputArgument)

func (*InputDefinition) AddArguments

func (d *InputDefinition) AddArguments(arguments []*InputArgument)

func (*InputDefinition) AddOption

func (d *InputDefinition) AddOption(option *InputOption)

func (*InputDefinition) AddOptions

func (d *InputDefinition) AddOptions(options []*InputOption)

func (*InputDefinition) Argument

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

func (*InputDefinition) ArgumentByIndex

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

func (*InputDefinition) ArgumentCount

func (d *InputDefinition) ArgumentCount() uint

func (*InputDefinition) ArgumentDefaults

func (d *InputDefinition) ArgumentDefaults() map[string]InputType

func (*InputDefinition) ArgumentRequiredCount

func (d *InputDefinition) ArgumentRequiredCount() uint

func (*InputDefinition) GetArguments

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

func (*InputDefinition) GetOptions

func (d *InputDefinition) GetOptions() []*InputOption

func (*InputDefinition) HasArgument

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

func (*InputDefinition) HasNegation

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

func (*InputDefinition) HasOption

func (d *InputDefinition) HasOption(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) Option

func (d *InputDefinition) Option(name string) (*InputOption, error)

func (*InputDefinition) OptionDefaults

func (d *InputDefinition) OptionDefaults() map[string]InputType

func (*InputDefinition) OptionForShortcut

func (d *InputDefinition) OptionForShortcut(shortcut string) (*InputOption, error)

func (*InputDefinition) SetArguments

func (d *InputDefinition) SetArguments(arguments []*InputArgument)

func (*InputDefinition) SetDefinition

func (d *InputDefinition) SetDefinition(arguments []*InputArgument, options []*InputOption)

func (*InputDefinition) SetOptions

func (d *InputDefinition) SetOptions(options []*InputOption)

func (*InputDefinition) ShortcutToName

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

func (*InputDefinition) Synopsis

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

type InputOption

type InputOption struct {
	// Should not be prefixed with dashes (e.g. "foo" is ok, "--foo" is not)
	Name string
	// Pipe separated string of shortcuts (e.g. "f|F")
	Shortcut     string
	Description  string
	Mode         InputOptionMode
	DefaultValue InputType
	Validator    InputValidator
	// contains filtered or unexported fields
}

func (*InputOption) AcceptValue

func (o *InputOption) AcceptValue() bool

func (*InputOption) Clone

func (o *InputOption) Clone() *InputOption

func (*InputOption) Equals

func (o *InputOption) Equals(opt *InputOption) bool

func (*InputOption) IsArray

func (o *InputOption) IsArray() bool

func (*InputOption) IsNegatable

func (o *InputOption) IsNegatable() bool

func (*InputOption) IsValueOptional

func (o *InputOption) IsValueOptional() bool

func (*InputOption) IsValueRequired

func (o *InputOption) IsValueRequired() bool

func (*InputOption) SetDefaultValue

func (o *InputOption) SetDefaultValue(value InputType) *InputOption

func (*InputOption) SetValidator

func (o *InputOption) SetValidator(validator InputValidator) *InputOption

type InputOptionMode

type InputOptionMode uint8

type InputParser

type InputParser func(self any) error

type InputType

type InputType any

type InputValidator

type InputValidator func(value InputType) error

type NamespaceCommands

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

type NamespaceNotFoundError

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

func (*NamespaceNotFoundError) Alternatives

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

func (*NamespaceNotFoundError) Error

func (e *NamespaceNotFoundError) Error() string

type Output

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

func NewOutput

func NewOutput(input *Input) *Output

func (*Output) Ask

func (o *Output) Ask(questions string, defaultValue string, validator func(string) bool) string

TODO: implement

func (*Output) AskHidden

func (o *Output) AskHidden(question string, validator func(string) bool) string

TODO: implement

func (*Output) Box

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

TODO: implement

func (*Output) Caution

func (o *Output) Caution(messages []string)

TODO: implement

func (*Output) Choice

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

TODO: implement

func (*Output) Confirm

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

func (*Output) DoWrite

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

func (*Output) Err

func (o *Output) Err(messages []string)

TODO: implement

func (*Output) ErrorOutput

func (o *Output) ErrorOutput() *Output

func (*Output) Formatter

func (o *Output) Formatter() *OutputFormatter

func (*Output) Info

func (o *Output) Info(messages []string)

TODO: implement

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)

TODO: implement

func (*Output) NewLine

func (o *Output) NewLine(count int)

func (*Output) Note

func (o *Output) Note(messages []string)

TODO: implement

func (*Output) ProgressAdvance

func (o *Output) ProgressAdvance(step uint)

TODO: implement

func (*Output) ProgressFinish

func (o *Output) ProgressFinish()

TODO: implement

func (*Output) ProgressStart

func (o *Output) ProgressStart(max uint)

TODO: implement

func (*Output) Section

func (o *Output) Section(message string)

TODO: implement

func (*Output) SetDecorated

func (o *Output) SetDecorated(decorated bool)

func (*Output) SetErrorOutput

func (o *Output) SetErrorOutput(output *Output)

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)

TODO: implement

func (*Output) Table

func (o *Output) Table(headers []string, rows map[string]string)

TODO: implement

func (*Output) Text

func (o *Output) Text(messages []string)

TODO: implement

func (*Output) Title

func (o *Output) Title(message string)

TODO: implement

func (*Output) Verbosity

func (o *Output) Verbosity() uint

func (*Output) Warning

func (o *Output) Warning(messages []string)

TODO: implement

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) 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 Question

type Question[T any] struct {
	Query           string
	Attempts        int
	Hidden          bool
	HiddenFallback  bool
	Validator       QuestionValidator[T]
	Normalizer      QuestionNormalizer[T]
	PreventTrimming bool
	Multiline       bool
	DefaultValue    T
}

func (*Question[any]) DefaultNormalizer

func (q *Question[any]) DefaultNormalizer() QuestionNormalizer[any]

func (*Question[any]) DefaultValidator

func (q *Question[any]) DefaultValidator() QuestionValidator[any]

func (*Question[any]) IsQuestion

func (q *Question[any]) IsQuestion() bool

type QuestionInterface

type QuestionInterface interface {
	IsQuestion() bool
}

type QuestionMeta

type QuestionMeta[T any] struct {
	Query        string
	Multiline    bool
	DefaultValue T
	Normalizer   QuestionNormalizer[any]
	Validator    QuestionValidator[any]
}

type QuestionNormalizer

type QuestionNormalizer[T any] func(string) T

type QuestionValidator

type QuestionValidator[T any] func(T) (T, error)

type ScrollBar

type ScrollBar struct{}

func (ScrollBar) Draw

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

TODO: implement

type TextDescriptor

type TextDescriptor struct {
	Output *Output
}

func (*TextDescriptor) DescribeApplication

func (d *TextDescriptor) DescribeApplication(app *Application, options *DescriptorOptions)

func (*TextDescriptor) DescribeCommand

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

func (*TextDescriptor) DescribeInputArgument

func (d *TextDescriptor) DescribeInputArgument(argument *InputArgument, options *DescriptorOptions)

func (*TextDescriptor) DescribeInputDefinition

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

func (*TextDescriptor) DescribeInputOption

func (d *TextDescriptor) DescribeInputOption(option *InputOption, options *DescriptorOptions)

func (*TextDescriptor) Write

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

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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