loaders

package
v0.4.18 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 12 Imported by: 18

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetParentsFromDir

func GetParentsFromDir(dir string) []string

GetParentsFromDir is a helper function to simply return a list of parent verbs for applications loaded from declarative yaml files. The directory structure mirrors the verb structure in cobra.

func LoadCommandAliasFromYAML

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

Types

type FSCommandLoader

type FSCommandLoader interface {
	LoadCommandsFromFS(f fs.FS, dir string, options []cmds.CommandDescriptionOption, aliasOptions []alias.Option) ([]cmds.Command, []*alias.CommandAlias, error)
}

FSCommandLoader is an interface that describes the most generic loader type, which is then used to load commands and command aliases from embedded queries and from "repository" directories used by glazed.

Examples of this pattern are used in sqleton, escuse-me and pinocchio.

type ReaderCommandLoader added in v0.2.69

type ReaderCommandLoader interface {
	LoadCommandsFromReader(r io.Reader, options []cmds.CommandDescriptionOption, aliasOptions []alias.Option) ([]cmds.Command, error)
}

type YAMLCommandLoader

type YAMLCommandLoader interface {
	LoadCommandFromYAML(s io.Reader, options ...cmds.CommandDescriptionOption) ([]cmds.Command, error)
	LoadCommandAliasFromYAML(s io.Reader, options ...alias.Option) ([]*alias.CommandAlias, error)
}

YAMLCommandLoader is an interface that allows an application using the glazed library to loader commands from YAML files.

type YAMLCommandWithFSLoader added in v0.4.10

type YAMLCommandWithFSLoader interface {
	LoadCommandFromYAMLWithDir(s io.Reader, f fs.FS, dir string, options ...cmds.CommandDescriptionOption) ([]cmds.Command, error)
	LoadCommandAliasFromYAMLWithDir(s io.Reader, f fs.FS, dir string, options ...alias.Option) ([]*alias.CommandAlias, error)
}

YAMLCommandWithFSLoader is an interface that allows an application using the glazed library to loader commands from YAML files. In contrast to YAMLCommandLoader, this command loader also takes a fs.FS as an argument, which can then be used to load additional files from the directory the YAML file is present in.

TODO(manuel, 2023-09-16): Implement loading additional files into a glazed command when a FS is passed. This could potentially be extended to using the full prompt manager to load contexts.

See https://github.com/go-go-golems/glazed/issues/350

This interface is currently not implemented.

type YAMLFSCommandLoader

type YAMLFSCommandLoader struct {
	// contains filtered or unexported fields
}

YAMLFSCommandLoader walks a FS and finds all yaml files, loading them using the passed YAMLCommandLoader.

It handles the following generic functionality: - recursive FS walking - setting SourceName for each command - setting Parents for each command

func NewYAMLFSCommandLoader

func NewYAMLFSCommandLoader(
	loader YAMLCommandLoader,
) *YAMLFSCommandLoader

func (*YAMLFSCommandLoader) LoadCommandsFromFS

func (l *YAMLFSCommandLoader) LoadCommandsFromFS(f fs.FS, dir string, options []cmds.CommandDescriptionOption, aliasOptions []alias.Option) ([]cmds.Command, []*alias.CommandAlias, error)

LoadCommandsFromFS walks the FS and loads all commands and command aliases found.

TODO(manuel, 2023-03-16) Add loading of helpsystem files See https://github.com/go-go-golems/glazed/issues/55 See https://github.com/go-go-golems/glazed/issues/218

type YAMLReaderCommandLoader added in v0.2.69

type YAMLReaderCommandLoader struct {
	YAMLCommandLoader
}

func YAMLReaderCommandLoaderFromYAMLCommandLoader added in v0.2.69

func YAMLReaderCommandLoaderFromYAMLCommandLoader(loader YAMLCommandLoader) *YAMLReaderCommandLoader

func (*YAMLReaderCommandLoader) LoadCommandsFromReader added in v0.2.69

func (l *YAMLReaderCommandLoader) LoadCommandsFromReader(r io.Reader, options []cmds.CommandDescriptionOption, aliasOptions []alias.Option) ([]cmds.Command, error)

Jump to

Keyboard shortcuts

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