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, customDataDir string) string
- type Action
- type ActionType
- type ExecutionResult
- type FillResult
- type IgnoreRule
- type InitResult
- type ListPacksResult
- type Matcher
- type MatcherConfig
- type Operation
- type OperationType
- type OverrideRule
- type Pack
- type PackConfig
- type PackInfo
- type PackStatus
- type PackStatusResult
- type PowerUp
- type PowerUpFactory
- type PowerUpStatus
- type RunMode
- type Trigger
- type TriggerFactory
- type TriggerMatch
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
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.
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" // ActionTypeTemplate processes a template file ActionTypeTemplate ActionType = "template" // ActionTypeRead reads file contents ActionTypeRead ActionType = "read" // ActionTypeChecksum calculates file checksum ActionTypeChecksum ActionType = "checksum" )
type ExecutionResult ¶
type ExecutionResult struct {
Packs []string `json:"packs"`
Operations []Operation `json:"operations"`
DryRun bool `json:"dryRun"`
}
ExecutionResult holds the outcome of an 'install' or 'deploy' command. It details the operations that were/would be performed.
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 Operation ¶
type Operation struct {
// Type is the type of operation
Type OperationType
// Source is the source path (for symlinks, copies)
Source string
// Target is the target path
Target string
// Content is the content to write (for write operations)
Content string
// Mode is the file permissions (optional)
Mode *uint32
// Description is a human-readable description
Description string
}
Operation represents a low-level file system operation These are the actual operations that will be performed by synthfs
type OperationType ¶
type OperationType string
OperationType defines the type of file system operation
const ( // OperationCreateSymlink creates a symbolic link OperationCreateSymlink OperationType = "create_symlink" // OperationCreateDir creates a directory OperationCreateDir OperationType = "create_dir" // OperationCopyFile copies a file OperationCopyFile OperationType = "copy_file" // OperationWriteFile writes content to a file OperationWriteFile OperationType = "write_file" // OperationDeleteFile deletes a file OperationDeleteFile OperationType = "delete_file" // OperationBackupFile creates a backup of a file OperationBackupFile OperationType = "backup_file" // OperationReadFile reads file contents OperationReadFile OperationType = "read_file" // OperationChecksum calculates file checksum OperationChecksum OperationType = "checksum" )
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 PackStatus ¶
type PackStatus struct {
Name string `json:"name"`
PowerUpState []PowerUpStatus `json:"powerUpState"`
}
PackStatus represents the detailed status of a single pack.
type PackStatusResult ¶
type PackStatusResult struct {
Packs []PackStatus `json:"packs"`
}
PackStatusResult holds the status of one or more packs.
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
}
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 PowerUpStatus ¶
type PowerUpStatus struct {
Name string `json:"name"`
State string `json:"state"` // e.g., "Installed", "Not Installed", "Changed"
Description string `json:"description"`
}
PowerUpStatus describes the state of a single power-up within a pack.
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
}
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