repositories

package
v0.1.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2024 License: MIT Imports: 16 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadCommandsFromInputs added in v0.1.8

func LoadCommandsFromInputs(
	commandLoader loaders.CommandLoader,
	inputs []string,
) ([]cmds.Command, error)

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 Directory added in v0.1.9

type Directory struct {
	FS fs.FS
	// Root directories are relative to the FS
	RootDirectory    string
	RootDocDirectory string
	Name             string
	SourcePrefix     string
	WatchDirectory   string
}

type RemoveCallback

type RemoveCallback func(cmd cmds.Command) error

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
	// 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) 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)

func (*Repository) Watch added in v0.0.14

func (r *Repository) Watch(
	ctx context.Context,
	options ...watcher.Option,
) error

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 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

type TrieNode struct {
	Children map[string]*TrieNode
	Commands []cmds.Command
}

func NewTrieNode

func NewTrieNode(commands []cmds.Command, aliases []*alias.CommandAlias) *TrieNode

NewTrieNode creates a new trie node.

func (*TrieNode) CollectCommands

func (t *TrieNode) CollectCommands(prefix []string, recurse bool) []cmds.Command

CollectCommands collects all commands and aliases under the given prefix.

func (*TrieNode) FindCommand added in v0.0.15

func (t *TrieNode) FindCommand(path []string) (cmds.Command, bool)

func (*TrieNode) FindNode added in v0.1.10

func (t *TrieNode) FindNode(prefix []string) *TrieNode

func (*TrieNode) InsertCommand

func (t *TrieNode) InsertCommand(prefix []string, command cmds.Command)

InsertCommand inserts a command in the trie, replacing it if it already exists.

func (*TrieNode) Remove

func (t *TrieNode) Remove(prefix []string) []cmds.Command

Remove removes a command from the trie.

func (*TrieNode) ToRenderNode added in v0.1.10

func (r *TrieNode) ToRenderNode() *RenderNode

type UpdateCallback

type UpdateCallback func(cmd cmds.Command) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL