Documentation
¶
Index ¶
- func New(rootCmd *cobra.Command, options ...Option) tea.Model
- type AutoCompleteMode
- func (a *AutoCompleteMode) AcceptOption(m Model) (Model, tea.Cmd)
- func (a *AutoCompleteMode) AdditionalView(m Model) string
- func (a *AutoCompleteMode) Enter(m Model) (Model, tea.Cmd)
- func (a *AutoCompleteMode) FullHelp(m Model, keyMap KeyMap) [][]key.Binding
- func (a *AutoCompleteMode) Leave(m Model) (Model, tea.Cmd)
- func (a *AutoCompleteMode) ShortHelp(m Model, keyMap KeyMap) []key.Binding
- func (a *AutoCompleteMode) Update(m Model, msg tea.Msg) (Model, tea.Cmd)
- type CommandEntryMode
- func (c *CommandEntryMode) AdditionalView(m Model) string
- func (c *CommandEntryMode) Enter(m Model) (Model, tea.Cmd)
- func (c *CommandEntryMode) FullHelp(m Model, keyMap KeyMap) [][]key.Binding
- func (c *CommandEntryMode) Leave(m Model) (Model, tea.Cmd)
- func (c *CommandEntryMode) ShortHelp(m Model, keyMap KeyMap) []key.Binding
- func (c *CommandEntryMode) Update(m Model, msg tea.Msg) (Model, tea.Cmd)
- type CommandRunningMode
- func (c *CommandRunningMode) AdditionalView(m Model) string
- func (c *CommandRunningMode) Enter(m Model) (Model, tea.Cmd)
- func (c *CommandRunningMode) FullHelp(m Model, keyMap KeyMap) [][]key.Binding
- func (c *CommandRunningMode) Leave(m Model) (Model, tea.Cmd)
- func (c *CommandRunningMode) ShortHelp(m Model, keyMap KeyMap) []key.Binding
- func (c *CommandRunningMode) Update(m Model, msg tea.Msg) (Model, tea.Cmd)
- type HistoryLookbackMode
- func (h *HistoryLookbackMode) AdditionalView(m Model) string
- func (h *HistoryLookbackMode) Enter(m Model) (Model, tea.Cmd)
- func (h *HistoryLookbackMode) FullHelp(m Model, keyMap KeyMap) [][]key.Binding
- func (h *HistoryLookbackMode) Leave(m Model) (Model, tea.Cmd)
- func (h *HistoryLookbackMode) ShortHelp(m Model, keyMap KeyMap) []key.Binding
- func (h *HistoryLookbackMode) Update(m Model, msg tea.Msg) (Model, tea.Cmd)
- type HistorySearchMode
- func (h *HistorySearchMode) AdditionalView(m Model) string
- func (h *HistorySearchMode) Enter(m Model) (Model, tea.Cmd)
- func (h *HistorySearchMode) FullHelp(m Model, keyMap KeyMap) [][]key.Binding
- func (h *HistorySearchMode) Leave(m Model) (Model, tea.Cmd)
- func (h *HistorySearchMode) ShortHelp(m Model, keyMap KeyMap) []key.Binding
- func (h *HistorySearchMode) Update(m Model, msg tea.Msg) (Model, tea.Cmd)
- type KeyMap
- type Mode
- type Model
- func (m Model) Enter(mode Mode) tea.Cmd
- func (m Model) ExecuteCommand(cmd history.Item) tea.Cmd
- func (m Model) FullHelp() [][]key.Binding
- func (m Model) Init() tea.Cmd
- func (m Model) ShortHelp() []key.Binding
- func (m Model) Shutdown() tea.Msg
- func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (m Model) View() string
- type Option
- func WithAdditionalStackTraceFilters(packages ...string) Option
- func WithBaseContext(ctx context.Context) Option
- func WithHistoryFile(fileName string) Option
- func WithInlineShell() Option
- func WithKeyMap(keyMap KeyMap) Option
- func WithMaxStackFrames(frames int) Option
- func WithNoHistory() Option
- func WithPromptFunc(promptFunc func() string) Option
- func WithStackTraceFilters(packages ...string) Option
- func WithStyles(styles Styles) Option
- type ShutdownMsg
- type Styles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AutoCompleteMode ¶
type AutoCompleteMode struct{}
func (*AutoCompleteMode) AcceptOption ¶
func (a *AutoCompleteMode) AcceptOption(m Model) (Model, tea.Cmd)
func (*AutoCompleteMode) AdditionalView ¶
func (a *AutoCompleteMode) AdditionalView(m Model) string
func (*AutoCompleteMode) FullHelp ¶
func (a *AutoCompleteMode) FullHelp(m Model, keyMap KeyMap) [][]key.Binding
type CommandEntryMode ¶
type CommandEntryMode struct{ KeepInputContent bool }
func (*CommandEntryMode) AdditionalView ¶
func (c *CommandEntryMode) AdditionalView(m Model) string
func (*CommandEntryMode) FullHelp ¶
func (c *CommandEntryMode) FullHelp(m Model, keyMap KeyMap) [][]key.Binding
type CommandRunningMode ¶
type CommandRunningMode struct{ KeepInputContent bool }
func (*CommandRunningMode) AdditionalView ¶
func (c *CommandRunningMode) AdditionalView(m Model) string
func (*CommandRunningMode) FullHelp ¶
func (c *CommandRunningMode) FullHelp(m Model, keyMap KeyMap) [][]key.Binding
type HistoryLookbackMode ¶
func (*HistoryLookbackMode) AdditionalView ¶
func (h *HistoryLookbackMode) AdditionalView(m Model) string
func (*HistoryLookbackMode) FullHelp ¶
func (h *HistoryLookbackMode) FullHelp(m Model, keyMap KeyMap) [][]key.Binding
type HistorySearchMode ¶
type HistorySearchMode struct{}
func (*HistorySearchMode) AdditionalView ¶
func (h *HistorySearchMode) AdditionalView(m Model) string
func (*HistorySearchMode) FullHelp ¶
func (h *HistorySearchMode) FullHelp(m Model, keyMap KeyMap) [][]key.Binding
type KeyMap ¶
KeyMap is a collection of all the key bindings used by the shell
A default is provided and will be used by the shell if no other KeyMap is provided when creating a new shell.
type Mode ¶
type Mode interface { // Enter is called when the mode is entered Enter(m Model) (Model, tea.Cmd) // Leave is called when the mode is left, before the next mode is entered Leave(m Model) (Model, tea.Cmd) // Update is called when a message is received for the mode Update(m Model, msg tea.Msg) (Model, tea.Cmd) // AdditionalView is called to render additional output // at the bottom of the screen AdditionalView(m Model) string // ShortHelp returns a list of key bindings and their descriptions ShortHelp(m Model, keyMap KeyMap) []key.Binding // FullHelp returns a list of key bindings and their descriptions FullHelp(m Model, keyMap KeyMap) [][]key.Binding }
Mode is an interface which represents an input mode the shell can be in and is used to handle input
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the main shell model
type Option ¶
Option is a function that configures the shell.
func WithAdditionalStackTraceFilters ¶
WithAdditionalStackTraceFilters adds additional packages to filter from the stack traces of errors when rendered to the user.
func WithBaseContext ¶
WithBaseContext sets the context that commands will be run with when they are executed by users.
By default context.Background will be used
func WithHistoryFile ¶
WithHistoryFile sets the history file to be used by the shell if not absolute will be relative to $HOME
func WithInlineShell ¶
func WithInlineShell() Option
WithInlineShell sets the shell to be inline rather than trying to render full screen
This means that recovered history will not be shown, however your terminals own render will be incharge of scrolling.
func WithKeyMap ¶
WithKeyMap sets the keymap to be used by the shell
func WithMaxStackFrames ¶
WithMaxStackFrames sets the maximum number of stack frames to show in errors when rendered to the user.
The shell defaults to 8 frames.
func WithPromptFunc ¶
WithPromptFunc sets the function for rendering the prompt
By default a function will be provided that returns "> "
func WithStackTraceFilters ¶
WithStackTraceFilters sets the packages to filter from the stack traces of errors when rendered to the user.
By default the shell will filter out packages related to running the shell itself, if you want to keep these filters, then use WithAdditionalStackTraceFilters.
If you want no filtering to be done, then call this with no packages listed.
func WithStyles ¶
WithStyles sets the styles to be used by the shell
type ShutdownMsg ¶
ShutdownMsg is sent by the shell when it wants to shutdown the application.
It is used to allow for one render cycle to occur before the tea.Quit is sent, allowing us to remove the prompt
func (ShutdownMsg) ForModelID ¶
func (msg ShutdownMsg) ForModelID() modelid.ID
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
examples
|
|
internal
|
|
pkg
|
|
modelid
Package modelid provides a way to identify a specific model instance by providing a global counter that is incremented each time a new model is created.
|
Package modelid provides a way to identify a specific model instance by providing a global counter that is incremented each time a new model is created. |