Documentation ¶
Index ¶
- func LoadCommandsFromInputs(commandLoader loaders.CommandLoader, inputs []string) ([]cmds.Command, error)
- type RemoveCallback
- type Repository
- func (r *Repository) Add(commands ...cmds.Command)
- func (r *Repository) CollectCommands(prefix []string, recurse bool) []cmds.Command
- func (r *Repository) LoadCommands() error
- func (r *Repository) Remove(prefixes ...[]string)
- func (r *Repository) Watch(ctx context.Context, options ...watcher.Option) error
- type RepositoryOption
- func WithCommandDescriptionOptions(cmdOptions []cmds.CommandDescriptionOption) RepositoryOption
- func WithCommands(commands ...cmds.Command) RepositoryOption
- func WithDirectories(directories []string) RepositoryOption
- func WithDirectory(directory string) RepositoryOption
- func WithFSLoader(loader loaders.CommandLoader) RepositoryOption
- func WithRemoveCallback(callback RemoveCallback) RepositoryOption
- func WithUpdateCallback(callback UpdateCallback) RepositoryOption
- type TrieNode
- type UpdateCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadCommandsFromInputs ¶
Types ¶
type RemoveCallback ¶
type Repository ¶
type Repository struct { // The root of the repository. Root *TrieNode Directories []string // contains filtered or unexported fields }
func NewRepository ¶
func NewRepository(options ...RepositoryOption) *Repository
NewRepository creates a new repository.
func (*Repository) Add ¶
func (r *Repository) Add(commands ...cmds.Command)
func (*Repository) CollectCommands ¶
func (r *Repository) CollectCommands(prefix []string, recurse bool) []cmds.Command
func (*Repository) LoadCommands ¶
func (r *Repository) LoadCommands() error
LoadCommands initializes the repository by loading all commands from the loader, if available.
func (*Repository) Remove ¶
func (r *Repository) Remove(prefixes ...[]string)
type RepositoryOption ¶
type RepositoryOption func(*Repository)
func WithCommandDescriptionOptions ¶
func WithCommandDescriptionOptions(cmdOptions []cmds.CommandDescriptionOption) RepositoryOption
func WithCommands ¶
func WithCommands(commands ...cmds.Command) RepositoryOption
func WithDirectories ¶
func WithDirectories(directories []string) RepositoryOption
func WithDirectory ¶
func WithDirectory(directory string) RepositoryOption
func WithFSLoader ¶
func WithFSLoader(loader loaders.CommandLoader) RepositoryOption
WithFSLoader sets the command loader to use when loading commands from the filesystem on startup or when a directory changes.
func WithRemoveCallback ¶
func WithRemoveCallback(callback RemoveCallback) RepositoryOption
func WithUpdateCallback ¶
func WithUpdateCallback(callback UpdateCallback) RepositoryOption
type TrieNode ¶
func NewTrieNode ¶
func NewTrieNode(commands []cmds.Command, aliases []*alias.CommandAlias) *TrieNode
NewTrieNode creates a new trie node.
func (*TrieNode) CollectCommands ¶
CollectCommands collects all commands and aliases under the given prefix.
func (*TrieNode) InsertCommand ¶
InsertCommand inserts a command in the trie, replacing it if it already exists.
type UpdateCallback ¶
Click to show internal directories.
Click to hide internal directories.