Documentation
¶
Index ¶
- Variables
- func CommandPath(cmd *Command, groups []*Group) string
- func CurrentDir() (string, error)
- func ExpandAllVars(cfg *AppConfig, basePath string) error
- func FetchURL(url string) (data []byte, err error)
- func GetCachePath(url string) string
- func IsURL(path string) bool
- func ProcessImports(cfg *AppConfig, basePath string) error
- func ResolveImportPath(importPath, basePath string) string
- type AppConfig
- func ParseConfig(path string) (*AppConfig, error)
- func ParseConfigFromBytes(data []byte) (*AppConfig, error)
- func ParseConfigFromBytesWithWriter(data []byte, warnTo io.Writer) (*AppConfig, error)
- func ParseConfigFromBytesWithWriterAndImports(data []byte, warnTo io.Writer, allowImports bool, basePath string) (*AppConfig, error)
- func ParseConfigFromReader(r io.Reader) (*AppConfig, error)
- func ParseConfigFromReaderWithWriter(r io.Reader, warnTo io.Writer) (*AppConfig, error)
- func ParseConfigFromReaderWithWriterAndImports(r io.Reader, warnTo io.Writer, allowImports bool, basePath string) (*AppConfig, error)
- func ParseConfigWithWriter(path string, warnTo io.Writer) (*AppConfig, error)
- func ParseConfigWithWriterAndImports(path string, warnTo io.Writer, allowImports bool) (*AppConfig, error)
- type Arg
- type Command
- type ConfigValidator
- type FileConfig
- type Group
- type ImportConfig
- type LogConfig
- type SearchResult
- type ValidationResult
- type Validator
- type Var
Constants ¶
This section is empty.
Variables ¶
var ErrConfigNotFound = errors.New("no config file found")
ErrConfigNotFound is returned when no config file is found in the directory tree
Functions ¶
func CommandPath ¶
CommandPath builds the dot-separated path for a command.
func CurrentDir ¶
func ExpandAllVars ¶
ExpandAllVars recursively expands all variables in the config
func FetchURL ¶ added in v1.17.0
FetchURL downloads content from a URL and returns it as bytes. It skips TLS verification and enforces a 100MB size limit.
func GetCachePath ¶ added in v1.17.0
GetCachePath returns the cache file path for a given URL. The path is based on a SHA256 hash of the URL.
func ProcessImports ¶ added in v1.17.0
ProcessImports processes all imports in the config and merges them. It handles both local files and URLs, and supports namespacing.
func ResolveImportPath ¶ added in v1.17.0
ResolveImportPath resolves an import path relative to a base file. If the path is absolute or a URL, it's returned as-is. If the path is relative, it's resolved relative to the base file's directory.
Types ¶
type AppConfig ¶
type AppConfig struct {
Shell string `yaml:"shell,omitempty"`
Vars []Var `yaml:"vars"`
Args []Arg `yaml:"-"`
RawArgs []string `yaml:"args"`
Log *LogConfig `yaml:"log,omitempty"`
Imports []ImportConfig `yaml:"imports"`
Groups []Group `yaml:"groups"`
Commands []Command `yaml:"commands"`
// contains filtered or unexported fields
}
func ParseConfig ¶
func ParseConfigFromBytes ¶
func ParseConfigFromBytesWithWriterAndImports ¶ added in v1.17.0
func ParseConfigFromReaderWithWriterAndImports ¶ added in v1.17.0
func ParseConfigWithWriter ¶
func ParseConfigWithWriterAndImports ¶ added in v1.17.0
func (*AppConfig) BuildIndexes ¶
func (*AppConfig) Find ¶
func (c *AppConfig) Find(name string) SearchResult
func (*AppConfig) GetAllCommandNames ¶ added in v1.17.0
type Arg ¶
type Command ¶
type Command struct {
Shell string `yaml:"shell,omitempty"`
Dir string `yaml:"dir,omitempty"`
Name string
Desc string `yaml:"desc"`
Color string `yaml:"color,omitempty"`
InheritColor *bool `yaml:"inherit_color,omitempty"`
Show *bool `yaml:"show,omitempty"`
Vars []Var `yaml:"vars"`
Args []Arg `yaml:"-"`
RawArgs []string `yaml:"args"`
Log *LogConfig `yaml:"log,omitempty"`
Depends []string `yaml:"depends,omitempty"`
Parallel *bool `yaml:"parallel,omitempty"`
Script string `yaml:"script"`
Before string `yaml:"before"`
After string `yaml:"after"`
Fallback string `yaml:"fallback"`
Finally string `yaml:"finally"`
Native bool `yaml:"native,omitempty"`
}
type ConfigValidator ¶
type ConfigValidator struct {
*AppConfig
// contains filtered or unexported fields
}
func GetValidator ¶
func GetValidator(config *AppConfig, basePath string) ConfigValidator
func (ConfigValidator) Validate ¶
func (c ConfigValidator) Validate() ValidationResult
type FileConfig ¶
type FileConfig struct {
Path string
}
func GetConfigPath ¶
func GetConfigPath(path string) (*FileConfig, error)
type Group ¶
type Group struct {
Shell string `yaml:"shell,omitempty"`
Dir string `yaml:"dir,omitempty"`
Name string
Desc string `yaml:"desc"`
Color string `yaml:"color,omitempty"`
InheritColor *bool `yaml:"inherit_color,omitempty"`
Show *bool `yaml:"show,omitempty"`
Vars []Var `yaml:"vars"`
Args []Arg `yaml:"-"`
RawArgs []string `yaml:"args"`
Log *LogConfig `yaml:"log,omitempty"`
Commands []Command
Groups []Group
// contains filtered or unexported fields
}
func (*Group) BuildIndexes ¶
func (*Group) Find ¶
func (g *Group) Find(name string) SearchResult
type ImportConfig ¶ added in v1.17.0
type SearchResult ¶
type SearchResult struct {
Exists bool
Command *Command // non-nil if result is a command
Groups []*Group // chain of groups from outermost to innermost
}
func FindCommandByPath ¶
func FindCommandByPath(cfg *AppConfig, path string) (SearchResult, error)
FindCommandByPath finds a command by its full dot-separated path (e.g., "infra.docker.up").
func ResolveCommand ¶
func ResolveCommand(cfg *AppConfig, cliArgs []string) (SearchResult, []string, int)
ResolveCommand greedily walks the config tree consuming CLI tokens. Returns the resolved result, remaining (unconsumed) arguments, and index of last found element. Supports arbitrary nesting: group subgroup ... command [args...]
func ResolveDependencies ¶
func ResolveDependencies(cfg *AppConfig, result SearchResult) ([]SearchResult, error)
ResolveDependencies resolves and topologically sorts all dependencies for a command. Returns the ordered list of dependency results (excluding the target command itself).
type ValidationResult ¶
type Validator ¶
type Validator interface {
Validate() ValidationResult
}
type Var ¶
type Var struct {
Name string
Value string
FromFile string `yaml:"-"` // path to file to import variables from
Format string `yaml:"-"` // file format: env, yaml, json, toml, etc.
IsFile bool `yaml:"-"` // whether this variable is loaded from a file
Prefix string `yaml:"-"` // prefix for imported variables (e.g., "public" for import:yaml file.yaml public)
}
func ExpandVarsFromFile ¶
ExpandVarsFromFile expands variables that reference env files