Documentation
¶
Index ¶
- Variables
- func L(id string) string
- func Run(app *App) error
- func RunCLI(app *App) error
- type ASTArgument
- type ASTFlag
- type ASTNode
- type App
- type AppParams
- type Argument
- type Command
- type Commands
- type Context
- func (c *Context) Command() string
- func (c *Context) Confirm(p *TUIConfirmParams) (bool, error)
- func (c *Context) Ctx() context.Context
- func (c *Context) Delete(key string)
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Elapsed() time.Duration
- func (c *Context) Error(data ...interface{})
- func (c *Context) Errorf(format string, data ...interface{})
- func (c *Context) Exec(cmd string, args ...string) (string, string, error)
- func (c *Context) ExecLive(cmd string, args ...string) error
- func (c *Context) ExecSilent(cmd string, args ...string) error
- func (c *Context) Get(key string) interface{}
- func (c *Context) GetCommandNameTree() []string
- func (c *Context) GetFlagBool(name string) bool
- func (c *Context) GetFlagInt(name string, defaultValue int) int
- func (c *Context) GetFlagIntArray(name string) []int
- func (c *Context) GetFlagString(name string, defaultValue string) string
- func (c *Context) GetFlagStringArray(name string) []string
- func (c *Context) GetName() string
- func (c *Context) InputFile(p *TUIInputFileParams) (TUIInputFileResult, error)
- func (c *Context) InputInt(p *TUIInputIntParams) (int, error)
- func (c *Context) InputText(p *TUIInputTextParams) (string, error)
- func (c *Context) IsCancelled() bool
- func (c *Context) MustGetInt(key string) int
- func (c *Context) MustGetString(key string) string
- func (c *Context) Print(data ...interface{})
- func (c *Context) PrintMarkdown(markdown string, data ...interface{})
- func (c *Context) Printf(format string, data ...interface{})
- func (c *Context) SelectOne(p *TUISelectOneParams) (TUISelectOneResult, error)
- func (c *Context) Set(key string, value interface{})
- func (c *Context) StartTime() time.Time
- func (c *Context) Stderr() io.Writer
- func (c *Context) Stdout() io.Writer
- func (c *Context) Warn(data ...interface{})
- func (c *Context) Warnf(format string, data ...interface{})
- type Flag
- type FlagType
- type FlagValue
- func (f *FlagValue[T]) Clear()
- func (f *FlagValue[T]) GetAlias() string
- func (f *FlagValue[T]) GetName() string
- func (f *FlagValue[T]) GetUsage() string
- func (f *FlagValue[T]) Parse(flag string) (interface{}, error)
- func (f *FlagValue[T]) ParsedValue() (interface{}, error)
- func (f *FlagValue[T]) Value() string
- func (f *FlagValue[T]) ValueType() string
- type Flags
- type TUIConfirmParams
- type TUIInputFileParams
- type TUIInputFileResult
- type TUIInputIntParams
- type TUIInputTextParams
- type TUIRequest
- type TUIResponse
- type TUISelectItem
- type TUISelectOneParams
- type TUISelectOneResult
Constants ¶
This section is empty.
Variables ¶
var ErrorArgumentNotFound = errors.New("argument not found for command")
var ErrorCommandEmpty = errors.New("command empty")
var ErrorCommandPanic = errors.New("cmdpanic")
var ErrorCommandUnclosedQuotes = errors.New("unclosed quotes")
var ErrorIncompleteEscapeSequence = errors.New("incomplete escape sequence")
var ErrorSubcommandUnknown = errors.New("unknown subcommand")
var ErrorUnknownCommand = errors.New("unknown command")
var ErrorUnknownFlagType = errors.New("unknown flag type")
var HelpCommandTemplate = `` /* 608-byte string literal not displayed */
Functions ¶
Types ¶
type ASTArgument ¶
ASTArgument - is a structure for storing arguments inside the AST.
type ASTNode ¶
type ASTNode struct {
Command string
FullCommand string
CommandTree []string
Subcommands []string
Arguments []ASTArgument
Flags map[string]map[string][]ASTFlag
Args []string
ColorCommand string
}
ASTNode - is a structure that defines the storage of a command after its successful parsing.
type App ¶
type App struct {
// The name of your application
Name string
// Description of the application, why it is needed
Usage string
// The authors of the application
Authors []string
// Your copyright in the form of "YEAR-YEAR author"
Copyright string
// The license under which you distribute the code
License string
// A list of all your commands
Commands Commands
// Allows you to enable Debug mode (with it, all Debug messages are output to the console)
Debug bool
// Allows you to disable the color output
NoColor bool
// Application parameters. For more information, see AppParams.
Params AppParams
}
App - the structure of the application.
type AppParams ¶
type AppParams struct {
// Allows you to turn on the cursor blinking inside the input. It's not working yet, added to the Roadmap.
//nolint:godox
//TODO(unimportant): Add cursor blinking
EnableInputBlinking bool
}
AppParams - the structure of the application parameters.
type Command ¶
type Command struct {
// Command name
Name string
// What is this command for?
Usage string
// Allows you to specify abbreviations for the command
Aliases []string
// The subcommands of your main command
Subcommands Commands
// Flags for executing your command
Flags Flags
// Arguments for executing your command
Arguments []*Argument
// The function that is executed before executing the main function Action
Before func(ctx *Context) (bool, error)
// The main function of the command
Action func(ctx *Context) error
// A function that runs after the main Action function has successfully completed its action
OnEnd func(ctx *Context) error
}
Command - the structure for creating your command.
type Commands ¶
type Commands []*Command
Commands is an abbreviation for the type `[]*replyme.Command`.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context - the structure that is passed when executing the functions of the command.
func (*Context) Confirm ¶
func (c *Context) Confirm(p *TUIConfirmParams) (bool, error)
Confirm is a method that triggers TUI to receive confirmation from the user.
func (*Context) Done ¶
func (c *Context) Done() <-chan struct{}
Done is a method for getting the done channel.
func (*Context) Error ¶
func (c *Context) Error(data ...interface{})
Error is a method for printing an error message.
func (*Context) ExecLive ¶
ExecLive is a method for executing a shell command in a live environment.
func (*Context) ExecSilent ¶
ExecSilent is a method for executing a shell command silently.
func (*Context) GetCommandNameTree ¶
GetCommandNameTree is a method for getting a command tree.
func (*Context) GetFlagBool ¶
GetFlagBool is a method for getting a flag bool value.
func (*Context) GetFlagInt ¶
GetFlagInt is a method for getting a flag int value.
func (*Context) GetFlagIntArray ¶
GetFlagIntArray is a method for getting a flag int array value.
func (*Context) GetFlagString ¶
GetFlagString is a method for getting a flag string value.
func (*Context) GetFlagStringArray ¶
GetFlagStringArray is a method for getting a flag string array value.
func (*Context) InputFile ¶
func (c *Context) InputFile(p *TUIInputFileParams) (TUIInputFileResult, error)
InputFile is a method that triggers TUI to receive file from the user.
func (*Context) InputInt ¶
func (c *Context) InputInt(p *TUIInputIntParams) (int, error)
InputInt is a method that triggers TUI to receive integer from the user.
func (*Context) InputText ¶
func (c *Context) InputText(p *TUIInputTextParams) (string, error)
InputText is a method that triggers TUI to receive text from the user.
func (*Context) IsCancelled ¶
IsCancelled is a method for checking if the context is cancelled.
func (*Context) MustGetInt ¶
MustGetInt is a method for getting a value from the memory and converting it to an int.
func (*Context) MustGetString ¶
MustGetString is a method for getting a value from the memory and converting it to a string.
func (*Context) Print ¶
func (c *Context) Print(data ...interface{})
Print is a method for printing a message.
func (*Context) PrintMarkdown ¶
PrintMarkdown is a method for printing a markdown message.
func (*Context) SelectOne ¶
func (c *Context) SelectOne(p *TUISelectOneParams) (TUISelectOneResult, error)
SelectOne is a method that triggers TUI to receive one item from the list from the user.
type Flag ¶
type Flag interface {
// GetName returns the name of the flag.
GetName() string
// GetAlias returns the alias of the flag.
GetAlias() string
// ValueType returns the type of the value.
ValueType() string
// Value returns the value of the flag.
Value() string
// Parse parses the flag.
Parse(flag string) (interface{}, error)
// ParsedValue returns the parsed value of the flag.
ParsedValue() (interface{}, error)
// GetUsage returns the usage of the flag.
GetUsage() string
// Clear clears the flag.
Clear()
}
Flag is an interface for getting information about flags and parsing it.
type FlagValue ¶
type FlagValue[T any] struct { // Flag name Name string // Flag usage Usage string // Flag alias Alias string // Flag parser Parser func(s string) (T, error) // contains filtered or unexported fields }
FlagValue is a structure for passing information about flags to a command.
func (*FlagValue[T]) ParsedValue ¶
ParsedValue returns the parsed value of the flag.
type Flags ¶
type Flags []Flag
Flags is an abbreviation for the type `[]Flag`, which adds additional methods for convenient management.
func (Flags) GetFlagBool ¶
GetFlagBool returns the value of the flag with the specified name as a bool.
func (Flags) GetFlagInt ¶
GetFlagInt returns the value of the flag with the specified name as an int.
func (Flags) GetFlagIntArray ¶
GetFlagIntArray returns the value of the flag with the specified name as an array of ints.
func (Flags) GetFlagString ¶
GetFlagString returns the value of the flag with the specified name as a string.
func (Flags) GetFlagStringArray ¶
GetFlagStringArray returns the value of the flag with the specified name as an array of strings.
type TUIConfirmParams ¶
type TUIInputFileParams ¶
type TUIInputFileResult ¶
type TUIInputIntParams ¶
type TUIInputTextParams ¶
type TUIRequest ¶
type TUIRequest struct {
ID string
Type tuiType
Payload interface{}
Response chan TUIResponse
}
type TUIResponse ¶
type TUIResponse struct {
Value interface{}
Err error
}
type TUISelectItem ¶
func (TUISelectItem) Description ¶
func (i TUISelectItem) Description() string
func (TUISelectItem) FilterValue ¶
func (i TUISelectItem) FilterValue() string
func (TUISelectItem) Title ¶
func (i TUISelectItem) Title() string
type TUISelectOneParams ¶
type TUISelectOneParams struct {
Name string
Description string
Items []TUISelectItem
}
type TUISelectOneResult ¶
type TUISelectOneResult struct {
SelectedID string
SelectedItem TUISelectItem
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
flags
command
|
|
|
flow
command
|
|
|
hello
command
|
|
|
subcommands
command
|
|
|
internal
|
|
|
filepicker
Package filepicker provides a file picker component for Bubble Tea applications.
|
Package filepicker provides a file picker component for Bubble Tea applications. |