Documentation
¶
Index ¶
- Constants
- type Argument
- type Command
- type Completion
- type Flag
- type Model
- func (m *Model) ClearHistory()
- func (m *Model) CloseCompletions()
- func (m *Model) SetHistoryFilePath(path string)
- func (m *Model) SetPlaceholder(placeholder string)
- func (m *Model) SetWidth(width int)
- func (m *Model) ShowingCompletions() bool
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- type Position
- type PositionalArgument
- type SelectedCommandMsg
Constants ¶
const ( StringArgument argumentType = "string" IntArgument argumentType = "int" FloatArgument argumentType = "float" BoolArgument argumentType = "bool" FileArgument argumentType = "file" DirArgument argumentType = "dir" FileDirArgument argumentType = "filedir" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
Command string
Description string
SubCommands []*Command
PositionalArguments []*PositionalArgument
Flags []*Flag
}
type Completion ¶
type Completion interface {
// contains filtered or unexported methods
}
type Flag ¶
type Model ¶
type Model struct {
// The commands available
Commands []*Command
// Slice that holds the history of commands
History []string
Err error
// The maximum number of history items to store
HistoryLimit int
// Whether to indent completions to match the input
IndentCompletions bool
// Whether to trim the input on enter
Autotrim bool
// The base offset from the left, applied to the completions
CompletionsOffset int
// The text style for valid commands
ValidCommandStyle lipgloss.Style
// The text style for invalid commands
InvalidCommandStyle lipgloss.Style
// Whether to show different border styles to indicate scrolling
ShowBorderScroll bool
// Whether to show the horizontal scrollbar to indicate scrolling
ShowScrollbar bool
// The position of the completions relative to the input
CompletionsPosition Position
// The number of rows to show in the completions
CompletionRows int
// contains filtered or unexported fields
}
func New ¶
New creates a new model with the given commands
Returns an error if any of the commands are invalid
func (*Model) ClearHistory ¶
func (m *Model) ClearHistory()
ClearHistory clears the command history from all previous commands.
If the history file path is set, it also clears the history on file.
func (*Model) CloseCompletions ¶
func (m *Model) CloseCompletions()
CloseCompletions hides the list of completions so it's no longer visible
Sets the input back to what the user had typed, if completions were being cycled through
func (*Model) SetHistoryFilePath ¶
SetHistoryFilePath sets the file path to the file used for persisting the command history.
It creates the file if it doesn't exist. The directory of the file path must exist. The file path must be a valid JSON file with a .json extension.
func (*Model) SetPlaceholder ¶
Set the input placeholder text
func (*Model) SetWidth ¶
SetWidth sets the width of the model
This is used to calculate the offset for the completions and when text should be wrapped
func (*Model) ShowingCompletions ¶
ShowingCompletions returns true if the completions are currently visible
type PositionalArgument ¶
func (*PositionalArgument) Validate ¶
func (p *PositionalArgument) Validate() error
