config

package
v1.17.7 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigNotFound = errors.New("no config file found")

ErrConfigNotFound is returned when no config file is found in the directory tree

Functions

func CommandPath

func CommandPath(cmd *Command, groups []*Group) string

CommandPath builds the dot-separated path for a command.

func CurrentDir

func CurrentDir() (string, error)

func ExpandAllVars

func ExpandAllVars(cfg *AppConfig, basePath string) error

ExpandAllVars recursively expands all variables in the config

func FetchURL added in v1.17.0

func FetchURL(url string) (data []byte, err error)

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

func GetCachePath(url string) string

GetCachePath returns the cache file path for a given URL. The path is based on a SHA256 hash of the URL.

func IsURL added in v1.17.0

func IsURL(path string) bool

IsURL checks if the given path is an HTTP/HTTPS URL.

func ProcessImports added in v1.17.0

func ProcessImports(cfg *AppConfig, basePath string) error

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

func ResolveImportPath(importPath, basePath string) string

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 ParseConfig(path string) (*AppConfig, error)

func ParseConfigFromBytes

func ParseConfigFromBytes(data []byte) (*AppConfig, error)

func ParseConfigFromBytesWithWriter

func ParseConfigFromBytesWithWriter(data []byte, warnTo io.Writer) (*AppConfig, error)

func ParseConfigFromBytesWithWriterAndImports added in v1.17.0

func ParseConfigFromBytesWithWriterAndImports(data []byte, warnTo io.Writer, allowImports bool, basePath string) (*AppConfig, error)

func ParseConfigFromReader

func ParseConfigFromReader(r io.Reader) (*AppConfig, error)

func ParseConfigFromReaderWithWriter

func ParseConfigFromReaderWithWriter(r io.Reader, warnTo io.Writer) (*AppConfig, error)

func ParseConfigFromReaderWithWriterAndImports added in v1.17.0

func ParseConfigFromReaderWithWriterAndImports(r io.Reader, warnTo io.Writer, allowImports bool, basePath string) (*AppConfig, error)

func ParseConfigWithWriter

func ParseConfigWithWriter(path string, warnTo io.Writer) (*AppConfig, error)

func ParseConfigWithWriterAndImports added in v1.17.0

func ParseConfigWithWriterAndImports(path string, warnTo io.Writer, allowImports bool) (*AppConfig, error)

func (*AppConfig) AllVars

func (c *AppConfig) AllVars() []Var

func (*AppConfig) BuildIndexes

func (c *AppConfig) BuildIndexes() error

func (*AppConfig) Find

func (c *AppConfig) Find(name string) SearchResult

func (*AppConfig) GetAllCommandNames added in v1.17.0

func (c *AppConfig) GetAllCommandNames() []string

type Arg

type Arg struct {
	Name     string
	Short    string
	Type     string
	Default  string
	Required bool
	Wildcard bool
	MaxArr   *int
}

func (*Arg) Parse

func (a *Arg) Parse(s string) error

func (*Arg) UnmarshalYAML

func (a *Arg) UnmarshalYAML(node *yaml.Node) error

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"`
}

func (*Command) UnmarshalYAML

func (c *Command) UnmarshalYAML(node *yaml.Node) error

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 (g *Group) BuildIndexes() error

func (*Group) Find

func (g *Group) Find(name string) SearchResult

func (*Group) UnmarshalYAML

func (g *Group) UnmarshalYAML(node *yaml.Node) error

type ImportConfig added in v1.17.0

type ImportConfig struct {
	URL       string `yaml:"url"`
	Namespace string `yaml:"namespace,omitempty"`
}

type LogConfig

type LogConfig struct {
	Path        string `yaml:"path"`
	Truncate    bool   `yaml:"truncate,omitempty"`
	Independent bool   `yaml:"independent,omitempty"`
}

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 ValidationResult struct {
	Warnings []string
	Error    error
}

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

func ExpandVarsFromFile(vars []Var, basePath string) ([]Var, error)

ExpandVarsFromFile expands variables that reference env files

func (*Var) UnmarshalYAML

func (v *Var) UnmarshalYAML(node *yaml.Node) error

Jump to

Keyboard shortcuts

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