Documentation
¶
Index ¶
- func LoadCommandsFromInputs(commandLoader loaders.CommandLoader, inputs []string) ([]cmds.Command, error)
- func LoadRepositories(helpSystem *help.HelpSystem, rootCmd *cobra.Command, ...) ([]cmds.Command, error)
- type Directory
- type RemoveCallback
- type RenderNode
- type Repository
- func (r *Repository) Add(commands ...cmds.Command)
- func (r *Repository) CollectCommands(prefix []string, recurse bool) []cmds.Command
- func (r *Repository) FindNode(prefix []string) *TrieNode
- func (r *Repository) GetCommand(name string) (cmds.Command, bool)
- func (r *Repository) GetRenderNode(prefix []string) (*RenderNode, bool)
- func (r *Repository) LoadCommands(helpSystem *help.HelpSystem, options ...cmds.CommandDescriptionOption) error
- func (r *Repository) Remove(prefixes ...[]string)
- func (r *Repository) Watch(ctx context.Context, options ...watcher.Option) error
- type RepositoryOption
- func WithCommandLoader(loader loaders.CommandLoader) RepositoryOption
- func WithDirectories(directories ...Directory) RepositoryOption
- func WithFiles(files ...string) RepositoryOption
- func WithName(name string) RepositoryOption
- func WithRemoveCallback(callback RemoveCallback) RepositoryOption
- func WithUpdateCallback(callback UpdateCallback) RepositoryOption
- type TrieNode
- func (t *TrieNode) CollectCommands(prefix []string, recurse bool) []cmds.Command
- func (t *TrieNode) FindCommand(path []string) (cmds.Command, bool)
- func (t *TrieNode) FindNode(prefix []string) *TrieNode
- func (t *TrieNode) InsertCommand(prefix []string, command cmds.Command)
- func (t *TrieNode) Remove(prefix []string) []cmds.Command
- func (r *TrieNode) ToRenderNode() *RenderNode
- type UpdateCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadCommandsFromInputs ¶ added in v0.1.8
func LoadRepositories ¶ added in v0.1.8
func LoadRepositories( helpSystem *help.HelpSystem, rootCmd *cobra.Command, repositories_ []*Repository, options ...cli.CobraParserOption, ) ([]cmds.Command, error)
Types ¶
type RemoveCallback ¶
type RenderNode ¶ added in v0.1.10
type RenderNode struct { Name string Command cmds.Command Children []*RenderNode }
type Repository ¶
type Repository struct { Name string Directories []Directory Files []string // New field for individual files // The root of the repository. Root *TrieNode // 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 ¶ added in v0.0.19
func (r *Repository) CollectCommands(prefix []string, recurse bool) []cmds.Command
func (*Repository) FindNode ¶ added in v0.1.10
func (r *Repository) FindNode(prefix []string) *TrieNode
func (*Repository) GetCommand ¶ added in v0.1.21
func (r *Repository) GetCommand(name string) (cmds.Command, bool)
GetCommand returns a single command by its full path name (components separated by /). It returns the command and true if found, nil and false otherwise.
func (*Repository) GetRenderNode ¶ added in v0.1.10
func (r *Repository) GetRenderNode(prefix []string) (*RenderNode, bool)
func (*Repository) LoadCommands ¶ added in v0.0.17
func (r *Repository) LoadCommands(helpSystem *help.HelpSystem, options ...cmds.CommandDescriptionOption) 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 WithCommandLoader ¶ added in v0.0.17
func WithCommandLoader(loader loaders.CommandLoader) RepositoryOption
WithCommandLoader sets the command loader to use when loading commands from the filesystem on startup or when a directory changes.
func WithDirectories ¶
func WithDirectories(directories ...Directory) RepositoryOption
func WithFiles ¶ added in v0.1.25
func WithFiles(files ...string) RepositoryOption
func WithName ¶ added in v0.1.8
func WithName(name string) RepositoryOption
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) FindCommand ¶ added in v0.0.15
func (*TrieNode) InsertCommand ¶
InsertCommand inserts a command in the trie, replacing it if it already exists.
func (*TrieNode) ToRenderNode ¶ added in v0.1.10
func (r *TrieNode) ToRenderNode() *RenderNode
type UpdateCallback ¶
Click to show internal directories.
Click to hide internal directories.