loaders

package
v0.5.15 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 10 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileNameToFsFilePath added in v0.4.35

func FileNameToFsFilePath(fileName string) (fs.FS, string, error)

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)

func LoadCommandOrAliasFromReader added in v0.4.34

func LoadCommandOrAliasFromReader(
	r io.Reader,
	rawLoadCommand LoadReaderCommandFunc,
	options []cmds.CommandDescriptionOption,
	aliasOptions []alias.Option,
) ([]cmds.Command, error)

func LoadCommandsFromFS added in v0.4.35

func LoadCommandsFromFS(
	f fs.FS,
	dir string,
	source string,
	loader CommandLoader,
	options []cmds.CommandDescriptionOption,
	aliasOptions []alias.Option,
) ([]cmds.Command, 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

Types

type CommandLoader added in v0.4.35

type CommandLoader interface {
	LoadCommands(
		f fs.FS, entryName string,
		options []cmds.CommandDescriptionOption,
		aliasOptions []alias.Option,
	) ([]cmds.Command, error)
	IsFileSupported(f fs.FS, fileName string) bool
}

CommandLoader 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 LoadReaderCommandFunc added in v0.4.34

type LoadReaderCommandFunc func(
	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