Documentation
¶
Overview ¶
The lib package is the implementation of the core functionality of the raid CLI tool.
Index ¶
- Constants
- Variables
- func AddProfile(profile Profile) error
- func AddProfiles(profiles []Profile) error
- func CloneRepository(repo Repo) error
- func ContainsEnv(name string) bool
- func ContainsProfile(name string) bool
- func CreateRepoConfigs(repos []RepoDraft)
- func ExecuteCommand(name string, args []string) error
- func ExecuteEnv(name string) error
- func ExecuteTask(task Task) error
- func ExecuteTasks(tasks []Task) error
- func ForceLoad() error
- func GetEnv() string
- func InitConfig() error
- func Install(maxThreads int) error
- func ListEnvs() []string
- func Load() error
- func LoadEnv() error
- func RemoveProfile(name string) error
- func Set(key string, value any) error
- func SetEnv(name string) error
- func SetProfile(name string) error
- func ValidateProfile(path string) error
- func ValidateRepo(path string) error
- func ValidateSchema(path string, schemaPath string) error
- func Write() error
- func WriteProfileFile(draft ProfileDraft, path string) error
- type Command
- type Condition
- type Context
- type Env
- type EnvVar
- type Finding
- type OnInstall
- type Output
- type Profile
- type ProfileDraft
- type Repo
- type RepoDraft
- type Severity
- type Task
- type TaskType
Constants ¶
const ( ConfigDirName = ".raid" ConfigFileName = "config.toml" ConfigPathDefault = "~" + sys.Sep + ConfigDirName + sys.Sep + ConfigFileName ConfigPathFlag = "config" ConfigPathFlagShort = "c" ConfigPathFlagDesc = "configuration file path (default is " + ConfigPathDefault + ")" )
const (
RaidConfigFileName = "raid.yaml"
)
Variables ¶
var CfgPath string
Functions ¶
func AddProfile ¶
AddProfile registers a profile in the config store.
func AddProfiles ¶
AddProfiles registers multiple profiles in the config store.
func CloneRepository ¶
CloneRepository clones a repository to its configured path. Skips if it already exists.
func ContainsEnv ¶
ContainsEnv reports whether an environment with the given name exists in the active profile.
func ContainsProfile ¶
ContainsProfile reports whether a profile with the given name is registered.
func CreateRepoConfigs ¶
func CreateRepoConfigs(repos []RepoDraft)
CreateRepoConfigs writes a raid.yaml stub into each repository's local directory.
func ExecuteCommand ¶
ExecuteCommand runs the tasks for the named command, applying any output configuration. Args are exposed as RAID_ARG_1, RAID_ARG_2, ... environment variables for the duration of the command and are unset afterwards.
func ExecuteEnv ¶
ExecuteEnv writes environment variables to each repo's .env file and runs the environment's tasks.
func ExecuteTask ¶
func ExecuteTasks ¶
func ForceLoad ¶
func ForceLoad() error
ForceLoad rebuilds the context from the active profile, ignoring any cached state.
func InitConfig ¶
func InitConfig() error
func ListEnvs ¶
func ListEnvs() []string
ListEnvs returns the names of all environments in the active profile.
func Load ¶
func Load() error
Load initializes the context from the active profile, using cached results if available.
func LoadEnv ¶
func LoadEnv() error
LoadEnv loads .env files from all repositories in the active profile into the process environment.
func RemoveProfile ¶
RemoveProfile removes a registered profile by name.
func SetProfile ¶
SetProfile sets the named profile as the active profile.
func ValidateProfile ¶
ValidateProfile validates the profile file at path against the profile JSON schema.
func ValidateRepo ¶
ValidateRepo validates the repo config file at path against the repo JSON schema.
func ValidateSchema ¶
ValidateSchema validates the file at path against the JSON schema at schemaPath. schemaPath must be an absolute or CWD-relative path to a schema file on disk.
func WriteProfileFile ¶
func WriteProfileFile(draft ProfileDraft, path string) error
WriteProfileFile serializes draft as YAML and writes it to path, creating parent directories as needed.
Types ¶
type Command ¶
type Command struct {
Name string `json:"name"`
Usage string `json:"usage"`
Tasks []Task `json:"tasks"`
Out *Output `json:"out,omitempty"`
}
Command is a named, user-defined CLI command that can be invoked via 'raid <name>'.
func GetCommands ¶
func GetCommands() []Command
GetCommands returns all commands available in the active profile.
func QuietLoad ¶
func QuietLoad() []Command
QuietLoad attempts a best-effort, read-only profile load. It does not create config files, does not emit warnings, and returns nil if the config is absent or loading fails. Intended for info-command paths (--help, --version) where user-command registration is opportunistic and side effects are undesirable.
type Condition ¶
type Condition struct {
Platform string `json:"platform,omitempty"`
Exists string `json:"exists,omitempty"`
Cmd string `json:"cmd,omitempty"`
}
Condition guards a task — all specified fields must be satisfied for the task to run.
type Env ¶
type Env struct {
Name string `json:"name"`
Variables []EnvVar `json:"variables"`
Tasks []Task `json:"tasks"`
}
Env represents a named environment with variables and tasks.
type Finding ¶
type Finding struct {
Severity Severity
Check string
Message string
Suggestion string // shown when non-empty
}
Finding represents the result of a single doctor check.
type OnInstall ¶
type OnInstall struct {
Tasks []Task `json:"tasks"`
}
OnInstall holds the tasks to run during profile installation.
type Output ¶
type Output struct {
Stdout bool `json:"stdout"`
Stderr bool `json:"stderr"`
File string `json:"file,omitempty"`
}
Output configures how a command's task output is handled. Stdout and Stderr default to true when Out is nil. When Out is set, only streams explicitly set to true are shown.
type Profile ¶
type Profile struct {
Name string `json:"name"`
Path string `json:"path"`
Repositories []Repo `json:"repositories"`
Environments []Env `json:"environments"`
Install OnInstall `json:"install"`
Groups map[string][]Task `json:"task_groups" yaml:"task_groups"`
Commands []Command `json:"commands"`
}
Profile represents a named collection of repositories, environments, and task groups.
func ExtractProfile ¶
ExtractProfile reads and returns a single named profile from the given file.
func ExtractProfiles ¶
ExtractProfiles reads all profiles from a YAML or JSON file.
type ProfileDraft ¶
type ProfileDraft struct {
Name string `yaml:"name"`
Repositories []RepoDraft `yaml:"repositories,omitempty"`
}
ProfileDraft is the minimal structure written to a new profile file.
type Repo ¶
type Repo struct {
Name string `json:"name"`
Path string `json:"path"`
URL string `json:"url"`
Branch string `json:"branch"`
Environments []Env `json:"environments"`
Install OnInstall `json:"install"`
Commands []Command `json:"commands"`
}
Repo represents a single repository entry in a profile.
func ExtractRepo ¶
ExtractRepo reads and parses the raid.yaml from the given repository directory.
type RepoDraft ¶
type RepoDraft struct {
Name string `yaml:"name"`
Path string `yaml:"path"`
URL string `yaml:"url"`
Branch string `yaml:"branch,omitempty"`
}
RepoDraft holds the fields collected for each repository during profile creation.
func CollectRepos ¶
CollectRepos runs an interactive prompt loop to collect repository details from reader.
type Task ¶
type Task struct {
Type TaskType `json:"type"`
Concurrent bool `json:"concurrent,omitempty"`
Condition *Condition `json:"condition,omitempty"`
// Shell
Cmd string `json:"cmd,omitempty"`
Literal bool `json:"literal,omitempty"`
Shell string `json:"shell,omitempty"`
// Script
Path string `json:"path,omitempty"`
Runner string `json:"runner,omitempty"`
// HTTP
URL string `json:"url,omitempty"`
Dest string `json:"dest,omitempty"`
// Wait
Timeout string `json:"timeout,omitempty"`
// Template
Src string `json:"src,omitempty"`
// Group
Ref string `json:"ref,omitempty"`
Parallel bool `json:"parallel,omitempty"`
// Git
Op string `json:"op,omitempty"`
Branch string `json:"branch,omitempty"`
// Prompt / Confirm / Print
Message string `json:"message,omitempty"`
// Prompt
Var string `json:"var,omitempty"`
Default string `json:"default,omitempty"`
// Print
Color string `json:"color,omitempty"`
// Retry
Attempts int `json:"attempts,omitempty"`
Delay string `json:"delay,omitempty"`
}
Task represents a single unit of work in a task sequence.