Documentation ¶
Index ¶
- func Add(profile, dir, path string) error
- func Fix() error
- func Init(p *Profile, opts *InitOptions) error
- func Install(p *Profile, opts *InstallOptions) error
- func InstallWithContext(ctx context.Context, p *Profile, opts *InstallOptions) error
- func New(p *Profile) error
- func Uninstall(profile string, opts *UninstallOptions) error
- func Update(profile string, opts *UpdateOptions) error
- func UpdateWithContext(ctx context.Context, profile string, opts *UpdateOptions) error
- type Config
- type Hook
- type Hooks
- type InitOptions
- type InstallOptions
- type LinkOptions
- type Profile
- type TraversalOptions
- type UninstallOptions
- type UpdateOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
Add adds the given file to the profile under the given top level dir. If the file already exists under $HOME/path, A backup is created and then copied to the profile.
func Fix ¶ added in v0.4.0
func Fix() error
Fix tries to fix the configuration file, after breaking changes were introduced.
List of things that get fixed:
- [0.3.0] move config from olf location at $HOME/.dotfiles/dotm.toml
- [0.3.0] set ignore_prefix to "_", when not set
- [0.4.0] set hooks_enabled to true, when not set
func Init ¶
func Init(p *Profile, opts *InitOptions) error
Init initializes a new dotfile profile from an existing local path.
func Install ¶
func Install(p *Profile, opts *InstallOptions) error
Install calls InstallWithContext with the background context.
func InstallWithContext ¶
func InstallWithContext(ctx context.Context, p *Profile, opts *InstallOptions) error
InstallWithContext installs a new dotfile profile by cloning the remote repository to the local path. The clone operation can be canceled with the passed context.
func Uninstall ¶
func Uninstall(profile string, opts *UninstallOptions) error
Uninstall unlinks a dotfile profile. If any backup files exist, they get restored.
func Update ¶
func Update(profile string, opts *UpdateOptions) error
Update calls UpdateWithContext with the background context.
func UpdateWithContext ¶
func UpdateWithContext(ctx context.Context, profile string, opts *UpdateOptions) error
UpdateWithContext updates the symlinks for the given profile.
When the given profile is empty all profiles get updated.
Types ¶
type Config ¶
type Config struct { // Ingoreprefix is a prefix to be ignored when traversing the dotfiles. // Both directories and files get ignored if they have the prefix. // For directories with the prefix, all sub directories get ignored aswell. // // The default value is "_". IgnorePrefix string `toml:"ignore_prefix" clic:"ignore_prefix"` // Profiles is the list of profiles. Profiles map[string]*Profile `toml:"profiles" clic:"profile"` }
Config represents the configuration file for dotm. A configuration file consists of multiple profiles.
func LoadOrCreateConfig ¶
LoadOrCreateConfig tries to load the config file. If it doesn't not exist, it returns a new config.
func (*Config) AddProfile ¶
AddProfile adds a new profile. If a profile with the same name exists, it returns an error.
It sanitizes and expands vars.
If the profile path already exists, it returns an error. If a profile with the same name exists, it returns an error.
func (*Config) AddProfileFromExistingPath ¶
AddProfileFromExistingPath adds a new profile.
It sanitizes and expands vars.
If a profile with the same name exists, it returns an error.
type Hooks ¶
type Hooks struct { PreUpdate Hook `toml:"pre_update" clic:"pre_update"` PostUpdate Hook `toml:"post_update" clic:"post_update"` }
Hooks represents all hooks.
func LoadHooksFromFile ¶
LoadHooksFromFile reads a hook file from a given file path.
type InitOptions ¶
type InitOptions struct {
LinkOptions
}
InitOptions are the options used to initialize a dotfile profile.
type InstallOptions ¶
type InstallOptions struct {
LinkOptions
}
InstallOptions are the options used to install a dotfile profile.
type LinkOptions ¶
type LinkOptions struct { Force bool Dry bool TraversalOptions }
LinkOptions are the options used during the symlink creation.
type Profile ¶
type Profile struct { Name string `toml:"-" clic:"name"` Path string `toml:"path" clic:"path"` Remote string `toml:"remote" clic:"remote"` HooksEnabled bool `toml:"hooks_enabled" clic:"hooks_enabled"` Includes []string `toml:"includes" clic:"includes"` Excludes []string `toml:"excludes" clic:"excludes"` Vars map[string]string `toml:"vars" clic:"vars"` Hooks // contains filtered or unexported fields }
Profile defines the data of a dotfile profile.
type TraversalOptions ¶
TraversalOptions are used during the dotfile traversal.
type UninstallOptions ¶
type UninstallOptions struct { Dry bool // Dry performes a dry run Clean bool // Clean also removes the local dotfile path and the config entry }
UninstallOptions are the options used to uninstall a dotfile profile.
type UpdateOptions ¶
type UpdateOptions struct { FromRemote bool ExecHooks bool LinkOptions }
UpdateOptions are the options used to update a dotfile profile.