Documentation
¶
Index ¶
- Constants
- Variables
- func AddTheme(tag string, theme Theme)
- func Ask[T any](i *Input, o *Output, question QuestionInterface) (T, error)
- func BgBlack(text string) string
- func BgBlue(text string) string
- func BgCyan(text string) string
- func BgGreen(text string) string
- func BgMagenta(text string) string
- func BgRed(text string) string
- func BgWhite(text string) string
- func BgYellow(text string) string
- func Black(text string) string
- func Blue(text string) string
- func Bold(text string) string
- func ColorMode() uint8
- func ConvertFromHexToAnsiColorCode(mode uint8, hexColor string) (string, error)
- func Cyan(text string) string
- func Dim(text string) string
- func Escape(s string) string
- func EscapeTrailingBackslash(s string) string
- func FormatBlock(messages []string, style string, large bool) string
- func FormatSection(section string, message string, style string) string
- func Gray(text string) string
- func Green(text string) string
- func HasColorSupport() bool
- func Hidden(text string) string
- func InputTypeToArray(value InputType) []string
- func InputTypeToString(value InputType) string
- func Inverse(text string) string
- func Italic(text string) string
- func Magenta(text string) string
- func Red(text string) string
- func RegisterTableStyle(name string, style *TableStyle)
- func RenderSpinner(s *Spinner) string
- func Reset(text string) string
- func SetBaseTheme(primary string, accent string)
- func Strikethrough(text string) string
- func StringToInputArgs(cmd string) []string
- func TerminalHeight() (int, error)
- func TerminalIsInteractive() bool
- func TerminalSize() (int, int, error)
- func TerminalWidth() (int, error)
- func Truncate(message string, length int, suffix string) string
- func Underline(text string) string
- func White(text string) string
- func Yellow(text string) string
- type AnyFunc
- type Application
- func (app *Application) Abbreviations(names []string) map[string][]string
- func (app *Application) Add(commands ...*Command)
- func (app *Application) AddCommands(commands []*Command)
- func (app *Application) All(namespace string) map[string]*Command
- func (app *Application) Definition() *InputDefinition
- func (app *Application) ExtractNamespace(name string, limit int) string
- func (app *Application) Find(name string) (*Command, error)
- func (app *Application) FindNamespace(namespace string) (string, error)
- func (app *Application) Get(name string) (*Command, error)
- func (app *Application) Has(name string) bool
- func (app *Application) Help() string
- func (app *Application) Namespaces() []string
- func (app *Application) RenderError(o *Output, err error)
- func (app *Application) Run(args ...string) (exitCode int, err error)
- func (app *Application) RunWith(i *Input, o *Output) (exitCode int, err error)
- func (app *Application) SetDefaultCommand(commandName string, isSingleCommand bool) error
- func (app *Application) SetDefinition(definition *InputDefinition)
- type ApplicationDescription
- type AvailableOption
- type ChildProcess
- type ChoiceQuestion
- type Color
- type Command
- func (c *Command) AddArgument(arg *InputArgument) *Command
- func (c *Command) AddOption(option *InputOption) *Command
- func (c *Command) AddUsage(usage string) *Command
- func (c *Command) Alert(messages ...string)
- func (c *Command) ApplicationDefinition() *InputDefinition
- func (c *Command) Arguments() map[string]InputType
- func (c *Command) ArrayArgument(name string) ([]string, error)
- func (c *Command) ArrayOption(name string) ([]string, error)
- func (c *Command) BoolOption(name string) (bool, error)
- func (c *Command) Comment(messages ...string)
- func (c *Command) DefineArgument(name string, mode InputArgumentMode, description string, ...) *Command
- func (c *Command) DefineOption(name string, shortcut string, mode InputOptionMode, description string, ...) *Command
- func (c *Command) Definition() *InputDefinition
- func (c *Command) Describe(output *Output, options uint)
- func (c *Command) Err(err error)
- func (c *Command) Error(messages ...string)
- func (c *Command) Exec(cmd string, shell string, inherit bool) (string, error)
- func (c *Command) Fail(e string) (int, error)
- func (c *Command) Info(messages ...string)
- func (c *Command) Input() *Input
- func (c *Command) IsDebug() bool
- func (c *Command) IsDecorated() bool
- func (c *Command) IsEnabled() bool
- func (c *Command) IsQuiet() bool
- func (c *Command) IsVerbose() bool
- func (c *Command) IsVeryVerbose() bool
- func (c *Command) MergeApplication(mergeArgs bool)
- func (c *Command) Meta() any
- func (c *Command) NativeDefinition() *InputDefinition
- func (c *Command) NewLine(count uint)
- func (c *Command) Ok(messages ...string)
- func (c *Command) Options() map[string]InputType
- func (c *Command) Output() *Output
- func (c *Command) ProcessedHelp() string
- func (c *Command) Run(i *Input, o *Output) (int, error)
- func (c *Command) SetAliases(aliases []string) *Command
- func (c *Command) SetApplicationDefinition(definition *InputDefinition)
- func (c *Command) SetDefinition(definition *InputDefinition)
- func (c *Command) SetDescription(description string) *Command
- func (c *Command) SetHelp(help string) *Command
- func (c *Command) SetHidden(hidden bool) *Command
- func (c *Command) SetMeta(meta any)
- func (c *Command) SetName(name string) *Command
- func (c *Command) Spawn(cmd string, shell string, inherit bool) *ChildProcess
- func (c *Command) Spinner(fn func(), message string)
- func (c *Command) StringArgument(name string) (string, error)
- func (c *Command) StringOption(name string) (string, error)
- func (c *Command) Synopsis(short bool) string
- func (c *Command) Usages() []string
- func (c *Command) Warn(messages ...string)
- func (c *Command) Write(message string)
- func (c *Command) Writeln(message string)
- func (c *Command) Writelns(messages []string)
- type CommandHandle
- type CommandInitializer
- type CommandInteracter
- type CommandNotFoundError
- type ConfirmationQuestion
- type ConsoleSectionOutput
- func (c *ConsoleSectionOutput) AddContent(input string, newLine bool) int
- func (c *ConsoleSectionOutput) AddNewLineOfInputSubmit()
- func (c *ConsoleSectionOutput) Clear(lines int)
- func (c *ConsoleSectionOutput) Content() string
- func (c *ConsoleSectionOutput) DoWrite(message string, newLine bool)
- func (c *ConsoleSectionOutput) Overwrite(message string)
- func (c *ConsoleSectionOutput) OverwriteMany(message []string)
- func (c *ConsoleSectionOutput) SetMaxHeight(maxHeight int)
- func (c *ConsoleSectionOutput) VisibleContent() string
- type Cursor
- func (c *Cursor) ClearLine() *Cursor
- func (c *Cursor) ClearLineAfter() *Cursor
- func (c *Cursor) ClearOutput() *Cursor
- func (c *Cursor) ClearScreen() *Cursor
- func (c *Cursor) CurrentPosition() (int, int)
- func (c *Cursor) Hide() *Cursor
- func (c *Cursor) Move(x int, y int) *Cursor
- func (c *Cursor) MoveDown(lines int) *Cursor
- func (c *Cursor) MoveLeft(columns int) *Cursor
- func (c *Cursor) MoveRight(columns int) *Cursor
- func (c *Cursor) MoveToColumn(column int) *Cursor
- func (c *Cursor) MoveToPosition(column int, row int) *Cursor
- func (c *Cursor) MoveUp(lines int) *Cursor
- func (c *Cursor) RestorePosition() *Cursor
- func (c *Cursor) SavePosition() *Cursor
- func (c *Cursor) Show() *Cursor
- type DescriptorOptions
- type ErrorWithAlternatives
- type Input
- func (i *Input) Arguments() map[string]InputType
- func (i *Input) ArrayArgument(name string) ([]string, error)
- func (i *Input) ArrayOption(name string) ([]string, error)
- func (i *Input) Bind(definition *InputDefinition) error
- func (i *Input) BoolOption(name string) (bool, error)
- func (i *Input) EscapeToken(token string) string
- func (i *Input) FirstArgument() InputType
- func (i *Input) HasArgument(name string) bool
- func (i *Input) HasOption(name string) bool
- func (i *Input) HasParameterOption(value string, onlyParams bool) bool
- func (i *Input) IsInteractive() bool
- func (i *Input) Options() map[string]InputType
- func (i *Input) ParameterOption(value string, defaultValue InputType, onlyParams bool) InputType
- func (i *Input) Parse() error
- func (i *Input) SetArgument(name string, value InputType) error
- func (i *Input) SetDefinition(definition *InputDefinition) error
- func (i *Input) SetInteractive(interactive bool)
- func (i *Input) SetOption(name string, value InputType) error
- func (i *Input) String() string
- func (i *Input) StringArgument(name string) (string, error)
- func (i *Input) StringOption(name string) (string, error)
- func (i *Input) Validate() error
- type InputArgument
- type InputArgumentMode
- type InputDefinition
- func (d *InputDefinition) AddArgument(argument *InputArgument)
- func (d *InputDefinition) AddArguments(arguments []*InputArgument)
- func (d *InputDefinition) AddOption(option *InputOption)
- func (d *InputDefinition) AddOptions(options []*InputOption)
- func (d *InputDefinition) Argument(name string) (*InputArgument, error)
- func (d *InputDefinition) ArgumentByIndex(index uint) (*InputArgument, error)
- func (d *InputDefinition) ArgumentCount() uint
- func (d *InputDefinition) ArgumentDefaults() map[string]InputType
- func (d *InputDefinition) ArgumentRequiredCount() uint
- func (d *InputDefinition) GetArguments() []*InputArgument
- func (d *InputDefinition) GetOptions() []*InputOption
- func (d *InputDefinition) HasArgument(name string) bool
- func (d *InputDefinition) HasNegation(name string) bool
- func (d *InputDefinition) HasOption(name string) bool
- func (d *InputDefinition) HasShortcut(name string) bool
- func (d *InputDefinition) NegationToName(negation string) string
- func (d *InputDefinition) Option(name string) (*InputOption, error)
- func (d *InputDefinition) OptionDefaults() map[string]InputType
- func (d *InputDefinition) OptionForShortcut(shortcut string) (*InputOption, error)
- func (d *InputDefinition) SetArguments(arguments []*InputArgument)
- func (d *InputDefinition) SetDefinition(arguments []*InputArgument, options []*InputOption)
- func (d *InputDefinition) SetOptions(options []*InputOption)
- func (d *InputDefinition) ShortcutToName(shortcut string) string
- func (d *InputDefinition) Synopsis(short bool) string
- type InputOption
- func (o *InputOption) AcceptValue() bool
- func (o *InputOption) Clone() *InputOption
- func (o *InputOption) Equals(opt *InputOption) bool
- func (o *InputOption) IsArray() bool
- func (o *InputOption) IsNegatable() bool
- func (o *InputOption) IsValueOptional() bool
- func (o *InputOption) IsValueRequired() bool
- func (o *InputOption) SetDefaultValue(value InputType) *InputOption
- func (o *InputOption) SetValidator(validator InputValidator) *InputOption
- type InputOptionMode
- type InputParser
- type InputType
- type InputValidator
- type Listener
- type NamespaceCommands
- type NamespaceNotFoundError
- type Output
- func (o *Output) Ask(question string, defaultValue string, validator func(string) (string, error)) (string, error)
- func (o *Output) AskHidden(question string, validator func(string) (string, error)) (string, error)
- func (o *Output) Block(messages []string, tag string, style string, prefix string, padding bool, ...)
- func (o *Output) Box(title string, body string, footer string, color string, info string)
- func (o *Output) Caution(messages ...string)
- func (o *Output) Choice(question string, choices map[string]string, defaultValue string) (string, error)
- func (o *Output) Comment(messages ...string)
- func (o *Output) Confirm(q string, defaultValue bool) (bool, error)
- func (o *Output) CreateTable(headers []string, rows [][]*TableCell, options *TableOptions) *Table
- func (o *Output) CreateTableRowsFromMaps(headers []string, rows []map[string]any) [][]*TableCell
- func (o *Output) CreateTableRowsFromSlices(rows [][]any) [][]*TableCell
- func (o *Output) DoWrite(message string, newLine bool)
- func (o *Output) Err(messages ...string)
- func (o *Output) Formatter() *OutputFormatter
- func (o *Output) Info(messages ...string)
- func (o *Output) IsDebug() bool
- func (o *Output) IsDecorated() bool
- func (o *Output) IsQuiet() bool
- func (o *Output) IsVerbose() bool
- func (o *Output) IsVeryVerbose() bool
- func (o *Output) Listing(elements []string, prefix string)
- func (o *Output) NewLine(count int)
- func (o *Output) Note(messages ...string)
- func (o *Output) ProgressAdvance(step uint)
- func (o *Output) ProgressFinish()
- func (o *Output) ProgressStart(max uint)
- func (o *Output) Section(message string)
- func (o *Output) SetDecorated(decorated bool)
- func (o *Output) SetFormatter(formatter *OutputFormatter)
- func (o *Output) SetVerbosity(verbose uint)
- func (o *Output) Success(messages ...string)
- func (o *Output) Table(headers []string, rows [][]*TableCell, options *TableOptions)
- func (o *Output) TableFromMap(rows []map[string]any, headers []string, options *TableOptions)
- func (o *Output) TableFromSlices(headers []string, rows [][]any, options *TableOptions)
- func (o *Output) Text(messages ...string)
- func (o *Output) Title(message string)
- func (o *Output) Verbosity() uint
- func (o *Output) Warning(messages ...string)
- func (o *Output) Write(message string, newLine bool, options uint)
- func (o *Output) WriteMany(messages []string, newLine bool, options uint)
- func (o *Output) Writeln(s string, options uint)
- func (o *Output) Writelnf(f string, options uint, args ...any)
- func (o *Output) Writelns(s []string, options uint)
- type OutputFormatter
- func (o *OutputFormatter) Clone() *OutputFormatter
- func (o *OutputFormatter) Format(message string) string
- func (o *OutputFormatter) FormatAndWrap(message string, width int) string
- func (o *OutputFormatter) HasStyle(name string) bool
- func (o *OutputFormatter) RemoveDecoration(str string) string
- func (o *OutputFormatter) SetStyle(name string, style *OutputFormatterStyle)
- func (o *OutputFormatter) Style(name string) (*OutputFormatterStyle, error)
- type OutputFormatterStyle
- func (s *OutputFormatterStyle) Apply(text string) string
- func (s *OutputFormatterStyle) Clone() *OutputFormatterStyle
- func (s *OutputFormatterStyle) SetBackground(c string)
- func (s *OutputFormatterStyle) SetForeground(c string)
- func (s *OutputFormatterStyle) SetHref(href string)
- func (s *OutputFormatterStyle) SetOption(option string)
- func (s *OutputFormatterStyle) SetOptions(options []string)
- func (s *OutputFormatterStyle) UnsetOption(option string)
- type OutputFormatterStyleStack
- func (s *OutputFormatterStyleStack) Clone() *OutputFormatterStyleStack
- func (s *OutputFormatterStyleStack) Current() *OutputFormatterStyle
- func (s *OutputFormatterStyleStack) Pop(style *OutputFormatterStyle) *OutputFormatterStyle
- func (s *OutputFormatterStyleStack) Push(style *OutputFormatterStyle)
- func (s *OutputFormatterStyleStack) Reset()
- type OutputTheme
- type Prompt
- type Question
- type QuestionInterface
- type QuestionNormalizer
- type QuestionValidator
- type Renderer
- func (r *Renderer) Err(message string)
- func (r *Renderer) Hint(message string)
- func (r *Renderer) Line(message string, newLine bool)
- func (r *Renderer) NewLine(count int)
- func (r *Renderer) ToString(state uint) string
- func (r *Renderer) Warning(message string)
- func (r *Renderer) When(condition bool, cb func(*Renderer), defaultCb func(*Renderer))
- type RendererInterface
- type ScrollBar
- type Spinner
- type Table
- func (t *Table) AddRow(rows []*TableCell)
- func (t *Table) AddRows(rows [][]*TableCell)
- func (t *Table) AppendRow(row []*TableCell)
- func (t *Table) ColumnStyle(columnIndex int) *TableStyle
- func (t *Table) Render()
- func (t *Table) SetColumnMaxWidth(columnIndex int, maxWidth int)
- func (t *Table) SetColumnStyle(i uint, style *TableStyle)
- func (t *Table) SetColumnStyleByName(i uint, name string)
- func (t *Table) SetColumnWidth(columnIndex int, width int)
- func (t *Table) SetColumnWidths(widths []int)
- func (t *Table) SetFooterTitle(title string)
- func (t *Table) SetHeaderTitle(title string)
- func (t *Table) SetHeaders(headers []string)
- func (t *Table) SetHorizontal(horizontal bool)
- func (t *Table) SetRow(columnIndex int, row []*TableCell)
- func (t *Table) SetRows(rows [][]*TableCell)
- func (t *Table) SetStyle(style *TableStyle)
- func (t *Table) SetStyleByName(style string)
- func (t *Table) SetVertical(vertical bool)
- func (t *Table) Style() *TableStyle
- type TableCell
- type TableCellStyle
- type TableOptions
- type TableStyle
- type TextDescriptor
- func (d *TextDescriptor) DescribeApplication(app *Application, options *DescriptorOptions)
- func (d *TextDescriptor) DescribeCommand(command *Command, options *DescriptorOptions)
- func (d *TextDescriptor) DescribeInputArgument(argument *InputArgument, options *DescriptorOptions)
- func (d *TextDescriptor) DescribeInputDefinition(definition *InputDefinition, options *DescriptorOptions)
- func (d *TextDescriptor) DescribeInputOption(option *InputOption, options *DescriptorOptions)
- func (d *TextDescriptor) Write(content string, decorated bool)
- type Theme
- type TrimmedBufferOutput
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 ( PromptStateInitial = 1 PromptStateActive = 2 PromptStateSubmit = 3 PromptStateCancel = 4 PromptStateError = 5 PromptStateSearching = 6 )
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 ChoiceQuestionDefaultErrorMessage = `Value "%s" is invalid`
View Source
const ChoiceQuestionDefaultPrompt = " > "
Variables ¶
View Source
var CustomOutputTheme = map[string]*OutputFormatterStyle{}
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"}), "primary": NewOutputFormatterStyle("yellow", "", nil), "accent": NewOutputFormatterStyle("green", "", nil), "prompt": NewOutputFormatterStyle("cyan", "", nil), "question": NewOutputFormatterStyle("black", "cyan", nil), }
View Source
var TrueAnswerRegex = regexp.MustCompile("(?i)^y")
Functions ¶
func EscapeTrailingBackslash ¶
func HasColorSupport ¶
func HasColorSupport() bool
func InputTypeToArray ¶
func InputTypeToString ¶
func RegisterTableStyle ¶ added in v0.16.0
func RegisterTableStyle(name string, style *TableStyle)
func RenderSpinner ¶ added in v0.12.0
func SetBaseTheme ¶ added in v0.15.0
func Strikethrough ¶
func StringToInputArgs ¶
func TerminalHeight ¶
func TerminalIsInteractive ¶
func TerminalIsInteractive() bool
func TerminalSize ¶
func TerminalWidth ¶
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) Definition ¶
func (app *Application) Definition() *InputDefinition
func (*Application) ExtractNamespace ¶
func (app *Application) ExtractNamespace(name string, limit int) string
func (*Application) FindNamespace ¶
func (app *Application) FindNamespace(namespace string) (string, 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) 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 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 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 Color ¶
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) ApplicationDefinition ¶
func (c *Command) ApplicationDefinition() *InputDefinition
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) IsDecorated ¶ added in v0.14.0
func (*Command) IsVeryVerbose ¶ added in v0.14.0
func (*Command) MergeApplication ¶
func (*Command) NativeDefinition ¶
func (c *Command) NativeDefinition() *InputDefinition
func (*Command) ProcessedHelp ¶
func (*Command) SetAliases ¶
func (*Command) SetApplicationDefinition ¶
func (c *Command) SetApplicationDefinition(definition *InputDefinition)
func (*Command) SetDefinition ¶
func (c *Command) SetDefinition(definition *InputDefinition)
func (*Command) SetDescription ¶
type CommandHandle ¶
type CommandInitializer ¶
type CommandInteracter ¶
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 ¶
func (*ConfirmationQuestion) DefaultNormalizer ¶
func (q *ConfirmationQuestion) DefaultNormalizer() QuestionNormalizer[bool]
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 ¶
func (*Cursor) ClearLineAfter ¶
func (*Cursor) ClearOutput ¶
func (*Cursor) ClearScreen ¶
func (*Cursor) CurrentPosition ¶
func (*Cursor) MoveToColumn ¶
func (*Cursor) RestorePosition ¶
func (*Cursor) SavePosition ¶
type DescriptorOptions ¶
type DescriptorOptions struct {
// contains filtered or unexported fields
}
type ErrorWithAlternatives ¶
func CommandNotFound ¶
func CommandNotFound(message string, alternatives []string) ErrorWithAlternatives
func NamespaceNotFound ¶
func NamespaceNotFound(message string, alternatives []string) ErrorWithAlternatives
type Input ¶
func (*Input) Bind ¶
func (i *Input) Bind(definition *InputDefinition) error
func (*Input) EscapeToken ¶
func (*Input) FirstArgument ¶
func (*Input) HasArgument ¶
func (*Input) HasParameterOption ¶
func (*Input) IsInteractive ¶
func (*Input) ParameterOption ¶
func (*Input) SetDefinition ¶
func (i *Input) SetDefinition(definition *InputDefinition) error
func (*Input) SetInteractive ¶
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 InputValidator ¶
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 ¶
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 (*Output) CreateTableRowsFromSlices ¶ added in v0.16.0
func (*Output) Formatter ¶
func (o *Output) Formatter() *OutputFormatter
func (*Output) IsDecorated ¶
func (*Output) IsVeryVerbose ¶
func (*Output) SetDecorated ¶
func (*Output) SetFormatter ¶
func (o *Output) SetFormatter(formatter *OutputFormatter)
func (*Output) SetVerbosity ¶
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(rows []map[string]any, headers []string, options *TableOptions)
func (*Output) TableFromSlices ¶ added in v0.16.0
func (o *Output) TableFromSlices(headers []string, rows [][]any, options *TableOptions)
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 (s *OutputFormatterStyle) Clone() *OutputFormatterStyle
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 (s *OutputFormatterStyleStack) Clone() *OutputFormatterStyleStack
func (*OutputFormatterStyleStack) Current ¶
func (s *OutputFormatterStyleStack) Current() *OutputFormatterStyle
func (*OutputFormatterStyleStack) Pop ¶
func (s *OutputFormatterStyleStack) Pop(style *OutputFormatterStyle) *OutputFormatterStyle
func (*OutputFormatterStyleStack) Push ¶
func (s *OutputFormatterStyleStack) Push(style *OutputFormatterStyle)
func (*OutputFormatterStyleStack) Reset ¶
func (s *OutputFormatterStyleStack) Reset()
type OutputTheme ¶
type OutputTheme map[string]*OutputFormatterStyle
type Prompt ¶ added in v0.12.0
type Prompt struct { Name string State uint Error string CancelMessage string Required bool Validator func(string) string Scroll int Highlighted int FirstVisible int DefaultValue string Input *Input Output *Output CancelUsingFn AnyFunc ValidateUsingFn func(any) string RevertUsingFn AnyFunc // contains filtered or unexported fields }
func (*Prompt) ShouldFallback ¶ added in v0.12.0
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 ¶
type QuestionInterface ¶
type QuestionInterface interface {
IsQuestion() bool
}
type QuestionNormalizer ¶
type QuestionValidator ¶
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
type RendererInterface ¶ added in v0.12.0
func NewSpinnerRenderer ¶ added in v0.12.0
func NewSpinnerRenderer(s *Spinner) RendererInterface
type Spinner ¶ added in v0.12.0
type Spinner struct { *Prompt Interval int Count int Message string Frames []string Color string // contains filtered or unexported fields }
func NewSpinner ¶ added in v0.12.0
type Table ¶ added in v0.16.0
type Table struct {
// contains filtered or unexported fields
}
func (*Table) ColumnStyle ¶ added in v0.16.0
func (t *Table) ColumnStyle(columnIndex int) *TableStyle
func (*Table) SetColumnMaxWidth ¶ added in v0.16.0
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 (*Table) SetColumnWidth ¶ added in v0.16.0
func (*Table) SetColumnWidths ¶ added in v0.16.0
func (*Table) SetFooterTitle ¶ added in v0.16.0
func (*Table) SetHeaderTitle ¶ added in v0.16.0
func (*Table) SetHeaders ¶ added in v0.16.0
func (*Table) SetHorizontal ¶ added in v0.16.0
func (*Table) SetStyle ¶ added in v0.16.0
func (t *Table) SetStyle(style *TableStyle)
func (*Table) SetStyleByName ¶ added in v0.16.0
func (*Table) SetVertical ¶ added in v0.16.0
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 uint ColSpan uint Style *TableCellStyle IsSeparator bool }
func NewTableCell ¶ added in v0.16.0
func NewTableSeparator ¶ added in v0.16.0
func NewTableSeparator() *TableCell
type TableCellStyle ¶ added in v0.16.0
type TableOptions ¶ added in v0.16.0
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 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 (s *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) 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
Source Files
¶
- application-descriptor.go
- application.go
- box.go
- child-process.go
- choice-question.go
- color.go
- command.go
- confirmation-question.go
- console-section-output.go
- cursor.go
- descriptor.go
- err.go
- input-argument.go
- input-definition.go
- input-option.go
- input.go
- output-formatter-style-stack.go
- output-formatter-style.go
- output-formatter.go
- output.go
- progress-bar.go
- prompt.go
- question-helper.go
- question.go
- renderer.go
- scroll-bar.go
- spinner.go
- stylist.go
- table.go
- terminal.go
- trimmed-buffer-output.go
- types.go
- util.go
Click to show internal directories.
Click to hide internal directories.