loaders

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 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 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