Documentation
¶
Index ¶
- func EnsureGitignore(sys GitignoreSystem, path string, block string) error
- func Run(root string, opts Options) error
- func ValidateGitignoreBlock(block string, blockPath string) (string, error)
- type GitignoreSystem
- type MatchTemplateFunc
- type Options
- type PromptDeleteUnknownAllFunc
- type PromptDeleteUnknownFunc
- type PromptFuncs
- func (p PromptFuncs) DeleteUnknown(path string) (bool, error)
- func (p PromptFuncs) DeleteUnknownAll(paths []string) (bool, error)
- func (p PromptFuncs) Overwrite(path string) (bool, error)
- func (p PromptFuncs) OverwriteAll(paths []string) (bool, error)
- func (p PromptFuncs) OverwriteAllMemory(paths []string) (bool, error)
- type PromptOverwriteAllFunc
- type PromptOverwriteFunc
- type Prompter
- type RealSystem
- func (RealSystem) MkdirAll(path string, perm os.FileMode) error
- func (RealSystem) ReadFile(name string) ([]byte, error)
- func (RealSystem) RemoveAll(path string) error
- func (RealSystem) Stat(name string) (os.FileInfo, error)
- func (RealSystem) WalkDir(root string, fn fs.WalkDirFunc) error
- func (RealSystem) WriteFileAtomic(filename string, data []byte, perm os.FileMode) error
- type System
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureGitignore ¶ added in v0.6.1
func EnsureGitignore(sys GitignoreSystem, path string, block string) error
EnsureGitignore updates or creates a .gitignore file with the given block. It merges the block into existing content, replacing any previous agent-layer block. The block should contain only the template content (ignore patterns and comments); managed markers and headers are added automatically.
Types ¶
type GitignoreSystem ¶ added in v0.6.1
type GitignoreSystem interface {
ReadFile(name string) ([]byte, error)
WriteFileAtomic(filename string, data []byte, perm os.FileMode) error
}
GitignoreSystem is the minimal interface needed for gitignore operations.
type MatchTemplateFunc ¶ added in v0.5.7
type MatchTemplateFunc func(sys System, path string, templatePath string, info fs.FileInfo) (bool, error)
MatchTemplateFunc compares a destination file to a template.
type Options ¶
type Options struct {
Overwrite bool
Force bool
Prompter Prompter
WarnWriter io.Writer
PinVersion string
System System
}
Options controls installer behavior.
type PromptDeleteUnknownAllFunc ¶ added in v0.5.4
PromptDeleteUnknownAllFunc asks whether to delete all unknown paths.
type PromptDeleteUnknownFunc ¶ added in v0.5.4
PromptDeleteUnknownFunc asks whether to delete a specific unknown path.
type PromptFuncs ¶ added in v0.5.7
type PromptFuncs struct {
OverwriteAllFunc PromptOverwriteAllFunc
OverwriteAllMemoryFunc PromptOverwriteAllFunc
OverwriteFunc PromptOverwriteFunc
DeleteUnknownAllFunc PromptDeleteUnknownAllFunc
DeleteUnknownFunc PromptDeleteUnknownFunc
}
PromptFuncs adapts optional prompt callbacks into a Prompter.
func (PromptFuncs) DeleteUnknown ¶ added in v0.5.7
func (p PromptFuncs) DeleteUnknown(path string) (bool, error)
DeleteUnknown prompts the user to confirm deleting a single unknown path. Returns an error if no DeleteUnknownFunc is configured.
func (PromptFuncs) DeleteUnknownAll ¶ added in v0.5.7
func (p PromptFuncs) DeleteUnknownAll(paths []string) (bool, error)
DeleteUnknownAll prompts the user to confirm deleting all unknown paths. Returns an error if no DeleteUnknownAllFunc is configured.
func (PromptFuncs) Overwrite ¶ added in v0.5.7
func (p PromptFuncs) Overwrite(path string) (bool, error)
Overwrite prompts the user to confirm overwriting a single path. Returns an error if no OverwriteFunc is configured.
func (PromptFuncs) OverwriteAll ¶ added in v0.5.7
func (p PromptFuncs) OverwriteAll(paths []string) (bool, error)
OverwriteAll prompts the user to confirm overwriting all given paths. Returns an error if no OverwriteAllFunc is configured.
func (PromptFuncs) OverwriteAllMemory ¶ added in v0.5.7
func (p PromptFuncs) OverwriteAllMemory(paths []string) (bool, error)
OverwriteAllMemory prompts the user to confirm overwriting all memory file paths. Returns an error if no OverwriteAllMemoryFunc is configured.
type PromptOverwriteAllFunc ¶ added in v0.5.4
PromptOverwriteAllFunc asks whether to overwrite all managed files. paths contains the relative files that differ from templates.
type PromptOverwriteFunc ¶
PromptOverwriteFunc asks whether to overwrite a given path.
type Prompter ¶ added in v0.5.7
type Prompter interface {
OverwriteAll(paths []string) (bool, error)
OverwriteAllMemory(paths []string) (bool, error)
Overwrite(path string) (bool, error)
DeleteUnknownAll(paths []string) (bool, error)
DeleteUnknown(path string) (bool, error)
}
Prompter provides user prompts for overwrite and delete decisions.
type RealSystem ¶ added in v0.5.7
type RealSystem struct{}
RealSystem implements System using the OS filesystem.
func (RealSystem) MkdirAll ¶ added in v0.5.7
func (RealSystem) MkdirAll(path string, perm os.FileMode) error
MkdirAll creates a directory named path, along with any necessary parents.
func (RealSystem) ReadFile ¶ added in v0.5.7
func (RealSystem) ReadFile(name string) ([]byte, error)
ReadFile reads the named file and returns the contents.
func (RealSystem) RemoveAll ¶ added in v0.5.7
func (RealSystem) RemoveAll(path string) error
RemoveAll removes path and any children it contains.
func (RealSystem) Stat ¶ added in v0.5.7
func (RealSystem) Stat(name string) (os.FileInfo, error)
Stat returns a FileInfo describing the named file.
func (RealSystem) WalkDir ¶ added in v0.5.7
func (RealSystem) WalkDir(root string, fn fs.WalkDirFunc) error
WalkDir walks the file tree rooted at root.
func (RealSystem) WriteFileAtomic ¶ added in v0.5.7
WriteFileAtomic writes data to a file atomically by writing to a temp file and renaming.
type System ¶ added in v0.5.7
type System interface {
Stat(name string) (os.FileInfo, error)
ReadFile(name string) ([]byte, error)
MkdirAll(path string, perm os.FileMode) error
RemoveAll(path string) error
WalkDir(root string, fn fs.WalkDirFunc) error
WriteFileAtomic(filename string, data []byte, perm os.FileMode) error
}
System abstracts filesystem operations needed by the installer. This interface is intentionally package-local per Decision edefea6 to enable parallel-safe unit tests without shared global state. Other packages (dispatch, sync) define their own System interfaces with operations specific to their needs.