Documentation ¶
Index ¶
- func GetParentsFromDir(dir string) []string
- func LoadCommandAliasFromYAML(s io.Reader, options ...alias.Option) ([]*alias.CommandAlias, error)
- func LoadCommandOrAliasFromReader(r io.Reader, rawLoadCommand LoadReaderCommandFunc, ...) ([]cmds.Command, error)
- type FSCommandLoader
- type FSFileCommandLoader
- type FileCommandLoader
- type LoadReaderCommandFunc
- type ReaderCommandLoader
- type ReaderCommandOrAliasLoader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetParentsFromDir ¶
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 LoadCommandOrAliasFromReader ¶ added in v0.4.34
func LoadCommandOrAliasFromReader( r io.Reader, rawLoadCommand LoadReaderCommandFunc, options []cmds.CommandDescriptionOption, aliasOptions []alias.Option, ) ([]cmds.Command, error)
Types ¶
type FSCommandLoader ¶
type FSCommandLoader interface { LoadCommandsFromFS( f fs.FS, entryName string, options []cmds.CommandDescriptionOption, aliasOptions []alias.Option, ) ([]cmds.Command, 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 FSFileCommandLoader ¶ added in v0.4.34
type FSFileCommandLoader struct {
// contains filtered or unexported fields
}
FSFileCommandLoader 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 NewFSFileCommandLoader ¶ added in v0.4.34
func NewFSFileCommandLoader( loader FileCommandLoader, ) *FSFileCommandLoader
func (*FSFileCommandLoader) LoadCommandsFromFS ¶ added in v0.4.34
func (l *FSFileCommandLoader) LoadCommandsFromFS( f fs.FS, dir string, 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
type FileCommandLoader ¶ added in v0.4.34
type FileCommandLoader interface { ReaderCommandLoader IsFileSupported(f fs.FS, fileName string) bool }
type LoadReaderCommandFunc ¶ added in v0.4.34
type ReaderCommandLoader ¶ added in v0.2.69
type ReaderCommandLoader interface { LoadCommandsFromReader( r io.Reader, options []cmds.CommandDescriptionOption, aliasOptions []alias.Option, ) ([]cmds.Command, error) }
ReaderCommandLoader loads commands (and aliases) out of a reader, meaning it can load single files. We go through the reader interface because we want to be able to load commands from strings if they come from different backing stores (e.g. databases, elasticsearch indices, ...)
type ReaderCommandOrAliasLoader ¶ added in v0.4.34
type ReaderCommandOrAliasLoader struct {
// contains filtered or unexported fields
}
func NewReaderCommandOrAliasLoader ¶ added in v0.4.34
func NewReaderCommandOrAliasLoader( loader ReaderCommandLoader, ) *ReaderCommandOrAliasLoader
func (*ReaderCommandOrAliasLoader) LoadCommandsFromReader ¶ added in v0.4.34
func (l *ReaderCommandOrAliasLoader) LoadCommandsFromReader( r io.Reader, options []cmds.CommandDescriptionOption, aliasOptions []alias.Option, ) ([]cmds.Command, error)