Documentation
¶
Overview ¶
Package ports defines interfaces (contracts) for external dependencies. These enable dependency injection and testability via mock implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Archiver ¶
type Archiver interface {
// Create creates a zip archive of sourceDir at destPath.
// Returns the number of files archived.
// exclude is a list of patterns to skip (e.g., "node_modules", "*.pyc").
Create(destPath, sourceDir string, exclude []string) (fileCount int, err error)
// Extract extracts a zip archive to destDir.
Extract(zipPath, destDir string) error
// List returns a map of file paths to their info from the archive.
// The path key has the project prefix stripped.
List(zipPath string) (map[string]FileInfo, error)
// ReadFile reads the contents of a file from inside a zip archive.
ReadFile(zipPath, filePath, projectName string) (string, error)
}
Archiver abstracts zip archive operations for testability. Production code uses ZipArchiver adapter; tests use MockArchiver.
type FileSystem ¶
type FileSystem interface {
// ReadDir reads the named directory and returns directory entries.
ReadDir(name string) ([]os.DirEntry, error)
// Stat returns file info for the named file.
Stat(name string) (os.FileInfo, error)
// MkdirAll creates a directory along with any necessary parents.
MkdirAll(path string, perm os.FileMode) error
// WriteFile writes data to the named file, creating it if necessary.
WriteFile(name string, data []byte, perm os.FileMode) error
// ReadFile reads the named file and returns the contents.
ReadFile(name string) ([]byte, error)
// Remove removes the named file or empty directory.
Remove(name string) error
// RemoveAll removes path and any children it contains.
RemoveAll(path string) error
// Rename renames (moves) oldpath to newpath.
Rename(oldpath, newpath string) error
// Open opens the named file for reading.
Open(name string) (fs.File, error)
// Create creates or truncates the named file.
Create(name string) (*os.File, error)
// Walk walks the file tree rooted at root, calling fn for each file or directory.
Walk(root string, fn WalkFunc) error
}
FileSystem abstracts filesystem operations for testability. Production code uses OSFileSystem adapter; tests use MockFileSystem.
type GitClient ¶
type GitClient interface {
// GetHead returns the current HEAD commit hash for the repository.
// Returns empty string if not a git repo or on error.
GetHead(repoPath string) string
// IsRepo checks if the given path is a git repository.
IsRepo(path string) bool
}
GitClient abstracts git operations for testability. Production code uses ExecGitClient adapter; tests use MockGitClient.
type LaunchdService ¶
type LaunchdService interface {
// PlistPath returns the path where the plist file should be stored.
PlistPath() string
// LogPath returns the path where logs should be written.
LogPath() string
// Install creates the plist file and loads the service.
Install(execPath, configPath string, hour, minute int) error
// Uninstall unloads the service and removes the plist file.
Uninstall() error
// IsInstalled checks if the service is currently installed.
IsInstalled() bool
// Status returns the current status of the service.
// Returns "running", "loaded", "not loaded", or error message.
Status() string
}
LaunchdService abstracts macOS launchd operations for testability. Production code uses MacLaunchdService adapter; tests use MockLaunchdService.
type TUIBackupResult ¶
TUIBackupResult contains the result of a backup operation.
type TUIProjectInfo ¶
type TUIProjectInfo struct {
Name string
Path string
Versions int
LastBackup time.Time
TotalSize int64
}
TUIProjectInfo contains project metadata for display.
type TUIService ¶
type TUIService interface {
// LoadConfig loads the application configuration.
LoadConfig() (*config.Config, error)
// ListProjects returns all projects with their metadata.
ListProjects(cfg *config.Config) ([]TUIProjectInfo, error)
// ListVersions returns all backup versions for a project.
ListVersions(cfg *config.Config, project string) ([]TUIVersionInfo, error)
// RunBackup performs a backup of the specified project.
RunBackup(cfg *config.Config, project string) TUIBackupResult
// VerifyBackup verifies the latest backup of a project.
// Returns nil if verified successfully, error otherwise.
VerifyBackup(cfg *config.Config, project string) error
}
TUIService provides operations needed by the TUI. This abstraction allows the TUI to be tested without real filesystem/backup operations.