cmds

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListCommandsIntoProcessor added in v0.0.19

func ListCommandsIntoProcessor(ctx context.Context, commands []cmds.Command, gp middlewares.Processor) error

Types

type CommandLoader

type CommandLoader[T glazed_cmds.Command] struct {
	// contains filtered or unexported fields
}

CommandLoader wraps a series of command locations and can be ued to load them all at once. This is usually used to load all available commands on startup.

func NewCommandLoader

func NewCommandLoader[T glazed_cmds.Command](locations *CommandLocations) *CommandLoader[T]

func (*CommandLoader[T]) LoadCommands

func (c *CommandLoader[T]) LoadCommands(
	loader loaders.FSCommandLoader,
	helpSystem *help.HelpSystem,
	options ...glazed_cmds.CommandDescriptionOption,
) ([]T, []*alias.CommandAlias, error)

type CommandLocations

type CommandLocations struct {
	// List of embedded filesystems to load commands from
	Embedded []EmbeddedCommandLocation
	// List of repositories directories
	Repositories []string
	// List of additional layers to add to every command
	AdditionalLayers []layers.ParameterLayer
	// Help system to register commands with
	HelpSystem *help.HelpSystem
	// Load embedded commands first
	LoadEmbeddedFirst bool
}

CommandLocations groups all possible sources for loading commands on appplication start and is used by the LoadCommands function.

func NewCommandLocations

func NewCommandLocations(options ...LoadCommandsOption) *CommandLocations

type EmbeddedCommandLocation

type EmbeddedCommandLocation struct {
	FS      fs.FS
	Name    string
	Root    string
	DocRoot string
}

EmbeddedCommandLocation describes the location of a command inside an embedded fs.FS.

type LoadCommandsOption

type LoadCommandsOption func(*CommandLocations)

func WithAdditionalLayers

func WithAdditionalLayers(layers ...layers.ParameterLayer) LoadCommandsOption

func WithEmbeddedLocations

func WithEmbeddedLocations(locations ...EmbeddedCommandLocation) LoadCommandsOption

func WithHelpSystem

func WithHelpSystem(helpSystem *help.HelpSystem) LoadCommandsOption

func WithLoadEmbeddedFirst added in v0.0.19

func WithLoadEmbeddedFirst(loadEmbeddedFirst bool) LoadCommandsOption

func WithRepositories

func WithRepositories(locations ...string) LoadCommandsOption

type RawCommand added in v0.0.19

type RawCommand struct {
	*cmds.CommandDescription
	YAMLContent map[string]interface{}
	Content     []byte
}

func (*RawCommand) ToYAML added in v0.0.19

func (r *RawCommand) ToYAML(w io.Writer) error

type RawCommandLoader added in v0.0.19

type RawCommandLoader struct{}

func (*RawCommandLoader) LoadCommandAliasFromYAML added in v0.0.19

func (r *RawCommandLoader) LoadCommandAliasFromYAML(s io.Reader, options ...alias.Option) ([]*alias.CommandAlias, error)

func (*RawCommandLoader) LoadCommandFromYAML added in v0.0.19

func (r *RawCommandLoader) LoadCommandFromYAML(s io.Reader, options ...cmds.CommandDescriptionOption) ([]cmds.Command, error)

Jump to

Keyboard shortcuts

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