Documentation
¶
Overview ¶
Package types defines the core types and interfaces used throughout dodot. This includes interfaces for Trigger, PowerUp, and Action, as well as data structures like Pack, TriggerMatch, and Matcher.
Index ¶
- Constants
- func GetShellIntegrationSnippet(shell string, dataDir string) string
- type Action
- func (a *Action) CheckStatus(fs FS, paths Pather) (Status, error)
- func (a *Action) GetDeployedPathPath(paths Pather) (string, error)
- func (a *Action) GetDeployedShellProfilePath(paths Pather) (string, error)
- func (a *Action) GetDeployedSymlinkPath(paths Pather) (string, error)
- func (a *Action) GetSentinelInfo(paths Pather) (*SentinelInfo, error)
- type ActionResult
- type ActionType
- type DisplayFile
- type DisplayPack
- type DisplayResult
- type ExecutionContext
- type ExecutionStatus
- type FS
- type FileStatus
- type FillResult
- type IgnoreRule
- type InitResult
- type ListPacksResult
- type Matcher
- type MatcherConfig
- type OperationStatus
- type OverrideRule
- type Pack
- type PackConfig
- type PackExecutionResult
- type PackInfo
- type Pather
- type PowerUp
- type PowerUpFactory
- type PowerUpResult
- type RunMode
- type SentinelInfo
- type Status
- type StatusState
- type Trigger
- type TriggerFactory
- type TriggerMatch
- type TriggerType
Constants ¶
const ( // ShellIntegrationSnippet is the line users need to add to their shell config ShellIntegrationSnippet = `[ -f "$HOME/.local/share/dodot/shell/dodot-init.sh" ] && source "$HOME/.local/share/dodot/shell/dodot-init.sh"` // ShellIntegrationSnippetWithCustomDir is the snippet template for custom DODOT_DATA_DIR ShellIntegrationSnippetWithCustomDir = `[ -f "%s/shell/dodot-init.sh" ] && source "%s/shell/dodot-init.sh"` // FishIntegrationSnippet is the line for Fish shell users FishIntegrationSnippet = `if test -f "$HOME/.local/share/dodot/shell/dodot-init.fish" source "$HOME/.local/share/dodot/shell/dodot-init.fish" end` )
Shell integration constants
const (
// OverridePriority is a high priority value for config overrides
OverridePriority = 100
)
Variables ¶
This section is empty.
Functions ¶
func GetShellIntegrationSnippet ¶
GetShellIntegrationSnippet returns the appropriate shell integration snippet If dataDir is provided, it uses that path; otherwise it uses the default snippet
Types ¶
type Action ¶
type Action struct {
// Type specifies what kind of action this is
Type ActionType
// Description is a human-readable description of what this action does
Description string
// Source is the source path (for link, copy operations)
Source string
// Target is the target path (for link, copy, write operations)
Target string
// Content is the content to write (for write, append operations)
Content string
// Mode is the file permissions (for write, mkdir operations)
Mode uint32
// Command is the command to run (for run operations)
Command string
// Args are the arguments for the command (for run operations)
Args []string
// Pack is the name of the pack that generated this action
Pack string
// PowerUpName is the name of the power-up that generated this action
PowerUpName string
// Priority determines the order of execution (higher = executed first)
Priority int
// Metadata contains any additional data for this action
Metadata map[string]interface{}
}
Action represents a high-level operation to be performed. Actions are generated by PowerUps and later converted to filesystem operations.
func (*Action) CheckStatus ¶ added in v0.1.4
CheckStatus checks the deployment status of this action
func (*Action) GetDeployedPathPath ¶ added in v0.1.4
GetDeployedPathPath returns the path to the deployed PATH directory symlink
func (*Action) GetDeployedShellProfilePath ¶ added in v0.1.4
GetDeployedShellProfilePath returns the path to the deployed shell profile symlink
func (*Action) GetDeployedSymlinkPath ¶ added in v0.1.4
GetDeployedSymlinkPath returns the path to the intermediate symlink for a link action
func (*Action) GetSentinelInfo ¶ added in v0.1.4
func (a *Action) GetSentinelInfo(paths Pather) (*SentinelInfo, error)
GetSentinelInfo returns standardized sentinel file information for an action
type ActionResult ¶ added in v0.1.4
type ActionResult struct {
// Action contains the action that was executed
Action Action `json:"action"`
// Status is the execution status
Status OperationStatus `json:"status"`
// Error contains any error that occurred during execution
Error error `json:"error,omitempty"`
// StartTime is when execution began
StartTime time.Time `json:"startTime"`
// EndTime is when execution completed
EndTime time.Time `json:"endTime"`
// Message provides additional context about the execution
Message string `json:"message,omitempty"`
// SynthfsOperationIDs tracks the synthfs operations that were executed for this action
// This is useful for debugging and correlation with synthfs results
SynthfsOperationIDs []string `json:"synthfsOperationIds,omitempty"`
}
ActionResult represents the execution result of a single Action This replaces OperationResult and is focused on Action execution, not Operation details
func (*ActionResult) Duration ¶ added in v0.1.4
func (ar *ActionResult) Duration() time.Duration
Duration returns the time taken to execute the action
type ActionType ¶
type ActionType string
ActionType represents the type of action to be performed
const ( // ActionTypeLink creates a symbolic link ActionTypeLink ActionType = "link" // ActionTypeCopy copies a file ActionTypeCopy ActionType = "copy" // ActionTypeWrite writes content to a file ActionTypeWrite ActionType = "write" // ActionTypeAppend appends content to a file ActionTypeAppend ActionType = "append" // ActionTypeMkdir creates a directory ActionTypeMkdir ActionType = "mkdir" // ActionTypeShellSource adds a file to be sourced by the shell ActionTypeShellSource ActionType = "shell_source" // ActionTypePathAdd adds a directory to PATH ActionTypePathAdd ActionType = "path_add" // ActionTypeRun executes a command ActionTypeRun ActionType = "run" // ActionTypeBrew processes a Brewfile ActionTypeBrew ActionType = "brew" // ActionTypeInstall runs an install script ActionTypeInstall ActionType = "install" // ActionTypeRead reads file contents ActionTypeRead ActionType = "read" // ActionTypeChecksum calculates file checksum ActionTypeChecksum ActionType = "checksum" )
type DisplayFile ¶ added in v0.1.3
type DisplayFile struct {
PowerUp string `json:"powerUp"`
Path string `json:"path"`
Status string `json:"status"` // File-level: "success", "error", "queue", "config", "ignored"
Message string `json:"message"`
IsOverride bool `json:"isOverride"` // File power-up was overridden in .dodot.toml
LastExecuted *time.Time `json:"lastExecuted"` // When operation was last executed
}
DisplayFile represents a single file within a pack for display.
type DisplayPack ¶ added in v0.1.3
type DisplayPack struct {
Name string `json:"name"`
Status string `json:"status"` // Aggregated: "alert", "success", "queue"
Files []DisplayFile `json:"files"`
HasConfig bool `json:"hasConfig"` // Pack has .dodot.toml
IsIgnored bool `json:"isIgnored"` // Pack has .dodotignore
}
DisplayPack represents a single pack for display.
func (*DisplayPack) GetPackStatus ¶ added in v0.1.3
func (dp *DisplayPack) GetPackStatus() string
GetPackStatus determines the pack-level status based on its files. Following the aggregation rules from the design: - If ANY file has ERROR status → Pack status is "alert" - If ALL files have SUCCESS status → Pack status is "success" - Empty pack or mixed states → Pack status is "queue"
type DisplayResult ¶ added in v0.1.3
type DisplayResult struct {
Command string `json:"command"` // "status", "deploy", "install"
Packs []DisplayPack `json:"packs"`
DryRun bool `json:"dryRun"` // For deploy/install commands
Timestamp time.Time `json:"timestamp"`
}
DisplayResult is the top-level structure for commands that produce rich output. This replaces the old PackStatusResult and is used by status, deploy, and install commands.
type ExecutionContext ¶ added in v0.1.3
type ExecutionContext struct {
// Command is the command being executed (deploy, install, etc.)
Command string
// PackResults contains results organized by pack
PackResults map[string]*PackExecutionResult
// StartTime is when execution began
StartTime time.Time
// EndTime is when execution completed
EndTime time.Time
// DryRun indicates if this was a dry run
DryRun bool
// TotalActions is the total count of actions across all packs
TotalActions int
// CompletedActions is the count of successfully completed actions
CompletedActions int
// FailedActions is the count of failed actions
FailedActions int
// SkippedActions is the count of skipped actions
SkippedActions int
}
ExecutionContext tracks the complete context and results of a command execution
func NewExecutionContext ¶ added in v0.1.3
func NewExecutionContext(command string, dryRun bool) *ExecutionContext
NewExecutionContext creates a new execution context
func (*ExecutionContext) AddPackResult ¶ added in v0.1.3
func (ec *ExecutionContext) AddPackResult(packName string, result *PackExecutionResult)
AddPackResult adds or updates a pack result
func (*ExecutionContext) Complete ¶ added in v0.1.3
func (ec *ExecutionContext) Complete()
Complete marks the execution as complete
func (*ExecutionContext) GetPackResult ¶ added in v0.1.3
func (ec *ExecutionContext) GetPackResult(packName string) (*PackExecutionResult, bool)
GetPackResult retrieves a pack result by name
func (*ExecutionContext) ToDisplayResult ¶ added in v0.1.4
func (ec *ExecutionContext) ToDisplayResult() *DisplayResult
ToDisplayResult transforms the ExecutionContext into a DisplayResult suitable for rendering
type ExecutionStatus ¶ added in v0.1.3
type ExecutionStatus string
ExecutionStatus represents the overall status of a pack's execution
const ( // ExecutionStatusSuccess means all actions succeeded ExecutionStatusSuccess ExecutionStatus = "success" // ExecutionStatusPartial means some actions succeeded, some failed ExecutionStatusPartial ExecutionStatus = "partial" // ExecutionStatusError means all actions failed ExecutionStatusError ExecutionStatus = "error" // ExecutionStatusSkipped means all actions were skipped ExecutionStatusSkipped ExecutionStatus = "skipped" // ExecutionStatusPending means execution hasn't started ExecutionStatusPending ExecutionStatus = "pending" )
type FS ¶ added in v0.1.4
type FS interface {
// File operations
Stat(name string) (fs.FileInfo, error)
ReadFile(name string) ([]byte, error)
WriteFile(name string, data []byte, perm fs.FileMode) error
// Directory operations
MkdirAll(path string, perm fs.FileMode) error
ReadDir(name string) ([]fs.DirEntry, error)
// Symlink operations
Symlink(oldname, newname string) error
Readlink(name string) (string, error)
// Other operations
Remove(name string) error
RemoveAll(path string) error
// Optional operations - implementations should check for support
// For testing, Lstat can fall back to Stat
Lstat(name string) (fs.FileInfo, error)
}
FS is the filesystem interface required for dodot operations
type FileStatus ¶ added in v0.1.3
type FileStatus struct {
// Path is the file or directory path
Path string
// PowerUp is the power-up that manages this file
PowerUp string
// Status is the current status of the file
Status OperationStatus
// Message provides additional context about the status
Message string
// LastApplied is when the file was last successfully applied
LastApplied time.Time
// Metadata contains power-up specific status information
// For example:
// - Symlinks: target path, whether link is valid
// - Profiles: which shell files contain entries
// - PATH: whether directory is in PATH
// - Homebrew: package version, installation status
Metadata map[string]interface{}
}
FileStatus represents the current status of a file managed by dodot
type FillResult ¶
type FillResult struct {
PackName string `json:"packName"`
FilesCreated []string `json:"filesCreated"`
}
FillResult holds the result of the 'fill' command.
type IgnoreRule ¶
type IgnoreRule struct {
Path string `toml:"path"`
}
IgnoreRule defines a file or pattern to be ignored
type InitResult ¶
type InitResult struct {
PackName string `json:"packName"`
Path string `json:"path"`
FilesCreated []string `json:"filesCreated"`
}
InitResult holds the result of the 'init' command.
type ListPacksResult ¶
type ListPacksResult struct {
Packs []PackInfo `json:"packs"`
}
ListPacksResult holds the result of the 'list' command.
type Matcher ¶
type Matcher struct {
// Name is an optional name for this matcher
Name string
// TriggerName specifies which trigger to use
TriggerName string
// PowerUpName specifies which power-up to invoke on match
PowerUpName string
// Priority determines the order of matcher evaluation (higher = first)
Priority int
// Options contains configuration for both trigger and power-up
Options map[string]interface{}
// TriggerOptions contains trigger-specific options
TriggerOptions map[string]interface{}
// PowerUpOptions contains power-up-specific options
PowerUpOptions map[string]interface{}
// Enabled indicates if this matcher is active
Enabled bool
}
Matcher connects triggers to power-ups. It specifies: "when this trigger fires, invoke this power-up with these options."
type MatcherConfig ¶
type MatcherConfig struct {
// Name is an optional name for this matcher
Name string `toml:"name"`
// Trigger specifies which trigger to use
Trigger string `toml:"trigger"`
// PowerUp specifies which power-up to invoke
PowerUp string `toml:"powerup"`
// Priority for this matcher
Priority int `toml:"priority"`
// Pattern is a common trigger option (for convenience)
Pattern string `toml:"pattern"`
// Target is a common power-up option (for convenience)
Target string `toml:"target"`
// Options for trigger and power-up configuration
Options map[string]interface{} `toml:"options"`
// TriggerOptions for trigger-specific configuration
TriggerOptions map[string]interface{} `toml:"trigger_options"`
// PowerUpOptions for power-up-specific configuration
PowerUpOptions map[string]interface{} `toml:"powerup_options"`
// Enabled indicates if this matcher is active (default: true)
Enabled *bool `toml:"enabled"`
}
MatcherConfig represents matcher configuration from TOML files
type OperationStatus ¶ added in v0.1.1
type OperationStatus string
OperationStatus defines the state of an operation/action execution
const ( StatusReady OperationStatus = "ready" StatusSkipped OperationStatus = "skipped" StatusConflict OperationStatus = "conflict" StatusError OperationStatus = "error" StatusUnknown OperationStatus = "unknown" )
type OverrideRule ¶
type OverrideRule struct {
Path string `toml:"path"`
Powerup string `toml:"powerup"`
With map[string]interface{} `toml:"with"`
}
OverrideRule defines a behavior override for a specific file or pattern
type Pack ¶
type Pack struct {
// Name is the pack name (usually the directory name)
Name string
// Path is the absolute path to the pack directory
Path string
// Config contains pack-specific configuration from .dodot.toml
Config PackConfig
// Metadata contains any additional pack information
Metadata map[string]interface{}
}
Pack represents a directory containing dotfiles and configuration
type PackConfig ¶
type PackConfig struct {
Ignore []IgnoreRule `toml:"ignore"`
Override []OverrideRule `toml:"override"`
}
PackConfig represents configuration options for a pack from .dodot.toml
func (*PackConfig) FindOverride ¶
func (c *PackConfig) FindOverride(filename string) *OverrideRule
FindOverride returns the override rule that matches the given filename, if any. It prioritizes exact matches over pattern matches.
func (*PackConfig) IsIgnored ¶
func (c *PackConfig) IsIgnored(filename string) bool
IsIgnored checks if a given file path should be ignored based on the pack's configuration. It matches the filename against the list of ignore rules.
type PackExecutionResult ¶ added in v0.1.3
type PackExecutionResult struct {
// Pack is the pack being executed
Pack *Pack
// PowerUpResults contains all PowerUp results and their status
PowerUpResults []*PowerUpResult
// Status is the aggregated status for this pack
Status ExecutionStatus
// StartTime is when this pack's execution began
StartTime time.Time
// EndTime is when this pack's execution completed
EndTime time.Time
// TotalPowerUps in this pack
TotalPowerUps int
// CompletedPowerUps in this pack
CompletedPowerUps int
// FailedPowerUps in this pack
FailedPowerUps int
// SkippedPowerUps in this pack
SkippedPowerUps int
}
PackExecutionResult contains the execution results for a single pack
func NewPackExecutionResult ¶ added in v0.1.3
func NewPackExecutionResult(pack *Pack) *PackExecutionResult
NewPackExecutionResult creates a new pack execution result
func (*PackExecutionResult) AddPowerUpResult ¶ added in v0.1.4
func (per *PackExecutionResult) AddPowerUpResult(result *PowerUpResult)
AddPowerUpResult adds a PowerUp result and updates statistics
func (*PackExecutionResult) Complete ¶ added in v0.1.3
func (per *PackExecutionResult) Complete()
Complete marks the pack execution as complete
type Pather ¶ added in v0.1.4
type Pather interface {
// DotfilesRoot returns the root directory for dotfiles
DotfilesRoot() string
// DataDir returns the XDG data directory for dodot
DataDir() string
// ConfigDir returns the XDG config directory for dodot
ConfigDir() string
// CacheDir returns the XDG cache directory for dodot
CacheDir() string
// StateDir returns the XDG state directory for dodot
StateDir() string
}
Pather provides paths for dodot operations
type PowerUp ¶
type PowerUp interface {
// Name returns the unique name of this power-up
Name() string
// Description returns a human-readable description of what this power-up does
Description() string
// RunMode returns whether this power-up runs once or many times
RunMode() RunMode
// Process takes a group of trigger matches and generates actions
// The matches are grouped by pack and options before being passed here
Process(matches []TriggerMatch) ([]Action, error)
// ValidateOptions checks if the provided options are valid for this power-up
ValidateOptions(options map[string]interface{}) error
// GetTemplateContent returns the template content for this power-up
// Returns empty string if the power-up doesn't provide a template
GetTemplateContent() string
}
PowerUp is an interface for action generators that process matched files. PowerUps receive groups of files that their associated triggers matched, and generate high-level actions describing what should be done.
type PowerUpFactory ¶
PowerUpFactory is a function that creates a new PowerUp instance It takes a map of options to configure the power-up
type PowerUpResult ¶ added in v0.1.4
type PowerUpResult struct {
// PowerUpName is the name of the PowerUp (symlink, homebrew, etc.)
PowerUpName string
// Files are the files processed by this PowerUp
Files []string
// Status is the final status after execution
Status OperationStatus
// Error contains any error that occurred
Error error
// StartTime is when the PowerUp execution began
StartTime time.Time
// EndTime is when the PowerUp execution completed
EndTime time.Time
// Message provides additional context
Message string
// Pack is the pack this PowerUp belongs to
Pack string
}
PowerUpResult tracks the result of a single PowerUp execution This is the atomic unit - if ANY action in a PowerUp fails, the PowerUp fails
type SentinelInfo ¶ added in v0.1.4
type SentinelInfo struct {
// Path is the full path to the sentinel file
Path string
// Name is just the filename of the sentinel
Name string
// Dir is the directory containing the sentinel
Dir string
}
SentinelInfo contains information about a sentinel file
type Status ¶ added in v0.1.4
type Status struct {
// State is the current status state
State StatusState
// Message is a human-readable status message
Message string
// Timestamp is when the action was last executed (optional)
Timestamp *time.Time
}
Status represents the deployment status of an action
type StatusState ¶ added in v0.1.4
type StatusState string
StatusState represents the state of a deployment
const ( // StatusStatePending indicates the action has not been executed yet StatusStatePending StatusState = "pending" // StatusStateSuccess indicates the action was executed successfully StatusStateSuccess StatusState = "success" // StatusStateError indicates the action failed or is broken StatusStateError StatusState = "error" // StatusStateIgnored indicates the item is explicitly ignored StatusStateIgnored StatusState = "ignored" // StatusStateConfig indicates this is a configuration file StatusStateConfig StatusState = "config" )
type Trigger ¶
type Trigger interface {
// Name returns the unique name of this trigger
Name() string
// Description returns a human-readable description of what this trigger matches
Description() string
// Match checks if the given file or directory matches this trigger's pattern
// It returns true if the file matches, along with any extracted metadata
Match(path string, info fs.FileInfo) (bool, map[string]interface{})
// Priority returns the priority of this trigger (higher = evaluated first)
Priority() int
// Type returns whether this is a specific or catchall trigger
Type() TriggerType
}
Trigger is an interface for pattern-matching engines that scan files and directories within packs. When a trigger finds a match, it returns metadata about what was found.
type TriggerFactory ¶
TriggerFactory creates a new Trigger instance with the given options
type TriggerMatch ¶
type TriggerMatch struct {
// TriggerName is the name of the trigger that matched
TriggerName string
// Pack is the name of the pack containing the matched file
Pack string
// Path is the relative path within the pack
Path string
// AbsolutePath is the absolute path to the file
AbsolutePath string
// Metadata contains any additional data extracted by the trigger
Metadata map[string]interface{}
// PowerUpName is the name of the power-up that should process this match
PowerUpName string
// PowerUpOptions contains options to pass to the power-up
PowerUpOptions map[string]interface{}
// Priority determines the order of processing (higher = processed first)
Priority int
}
TriggerMatch represents a successful trigger match on a file or directory
type TriggerType ¶ added in v0.1.1
type TriggerType int
TriggerType represents the type of trigger - specific or catchall
const ( // TriggerTypeSpecific is for triggers that match specific patterns TriggerTypeSpecific TriggerType = iota // TriggerTypeCatchall is for triggers that match everything not already matched TriggerTypeCatchall )