Documentation ¶
Index ¶
- func GetFunctionName(i interface{}) string
- func OnInterrupt(fn func())
- func OnReload(fn func())
- type Command
- type ShellCli
- func (a *ShellCli[T]) AddCommand(name string, cmd *Command[T])
- func (a *ShellCli[T]) Exec(cmd []string) error
- func (a *ShellCli[T]) ExecuteCommands(cmd string) (cancel bool, err error)
- func (s *ShellCli[T]) Help() *Command[T]
- func (a *ShellCli[T]) Init() error
- func (a *ShellCli[T]) Run()
- func (a *ShellCli[T]) RunString(command string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFunctionName ¶ added in v0.9.3
func GetFunctionName(i interface{}) string
func OnInterrupt ¶ added in v0.9.3
func OnInterrupt(fn func())
Types ¶
type Command ¶
type Command[T any] struct { Description string Args [][3]string // Map of argument to the description and default value Run func(a *ShellCli[T], args map[string]string) error }
Command is a command for the shell client
type ShellCli ¶
type ShellCli[T any] struct { ProjectName string Commands map[string]*Command[T] Splitter splitter.Splitter ArgSplitter splitter.Splitter CaseInsensitive bool Prompter func(*ShellCli[T]) string Data *T // contains filtered or unexported fields }
ShellCli is a simple shell-like interface with commands
func (*ShellCli[T]) AddCommand ¶
AddCommand adds a command to the shell client
It is recommended to use this to add a command over directly modifying the Commands map as this function will be updated to be backwards compatible with future changes
func (*ShellCli[T]) ExecuteCommands ¶ added in v1.5.0
ExecuteCommands handles a list of commands in the form 'cmd; cmd etc.'
Click to show internal directories.
Click to hide internal directories.