Documentation ¶
Overview ¶
Package terminalio handles interaction with the command line.
Index ¶
- func AddDotfile(userspaceFile, userspaceHomedir, dotfilesDir string) error
- func CheckIfFileExists(absPath string) (bool, error)
- func CopyExternalDotfile(fpath, fromdir, todir string, confirm bool) (string, error)
- func FindCommonPathPrefix(path1, path2 string) (string, error)
- func FindCommonPathSuffix(path1, path2 string) (string, error)
- func GetAndValidateAbsolutePath(path string) (string, error)
- func InstallDotfile(file, userspaceDir, dotfilesDir string, overwrite bool) error
- func IsFileSymlink(file string) (bool, error)
- func RevertDotfile(file, userspaceDir, dotfilesDir string) error
- func SyncLocalRemote(repoPath string) error
- func UpdateSymlinks(userSpaceDir, dotfilesDir string) error
- func WriteFile(fpath string, contents []byte, overwrite bool) error
- type ErrAbortOnOverwrite
- type ErrConfirmProceed
- type ErrFileAlreadyExists
- type ErrFileNotFound
- type ErrMergeFail
- type ErrSymlinkNotFound
- type ErrUnmatchedShellReturn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDotfile ¶
Copies file from userspace to the dotfiles directory and creates symlink from userspace file into the newly copied file in the dotfiles dirctory. The identical relative path is used for both 'homeDir' and 'dotfilesDir'.
func CheckIfFileExists ¶
Checks if file exists by trying to open it. The given path should be absolute or relative to dotf executable. An error is returned if the file does not exist.
func CopyExternalDotfile ¶
Copies a file from an external location into current dotfiles directory. E.g. fromdir can be the root of another dotfiles directory and todir can be the path to current dotfiles root dir. Returns the path of the copied file. If confirm==true an empty string and an error containing the calucated path to the new dotfile are returned. If the file to be copied is a symlink, a symlink will be created in todir pointing back to the symlink in fromdir. This is to keep the semantics, that userspace links always point into their own dotfiles dir.
func FindCommonPathPrefix ¶
Finds common prefix of two already split strings. E.g. '/a/b/c' and '/a/b/c/d' gives 'a/b/c'.
func FindCommonPathSuffix ¶
Finds common suffix of two already split strings. E.g. '/a/b/c' and 'd/b/c' gives 'b/c'.
func GetAndValidateAbsolutePath ¶
Returns the absolute path from current directory or an error if the created path does not point to a file.
func InstallDotfile ¶
Installs a dotfile into its relative equal location in userspace by way of a symlink in userspace pointing back to the file in dotfiles. The userspace file will be removed if 'overwrite' is true. Both the filepath inside dotfile as well as in userspace can be given.
func IsFileSymlink ¶
IsFileSymlink returns true if the given path is an existing symlink.
func RevertDotfile ¶
Reverts the insertion of a file into the dotfiles directory and return it to its original location in userspace. The symlink is removed first. The operation can be applied both to the symlink in userspace and the actual file in the dotfiles directory.
func SyncLocalRemote ¶
SyncLocalRemote uses Git to update local and remote repository with newest changes from either place. The given path 'absPathToLocalRepo' must point to a directory initialized with git and with push/pull abilities to a remote. If it is not possible to merge changes or if a command fails in the shell, an error will be returned.
func UpdateSymlinks ¶
UpdateSymlinks walks over files and folders in the dotfiles dir, while updating their respective symlinks in userspace relative to the placement in the dotfiles directory. If a matching symlink is not found in userspace, the file is ignored. `dotfilesDirPath` denotes the path to the dotfiles directory. `userSpacePath` denotes the root of where the symlinks can be found.
Types ¶
type ErrAbortOnOverwrite ¶
type ErrAbortOnOverwrite struct {
Path string
}
func (*ErrAbortOnOverwrite) Error ¶
func (e *ErrAbortOnOverwrite) Error() string
type ErrConfirmProceed ¶
type ErrConfirmProceed struct {
Path string
}
func (*ErrConfirmProceed) Error ¶
func (e *ErrConfirmProceed) Error() string
type ErrFileAlreadyExists ¶
type ErrFileAlreadyExists struct {
// contains filtered or unexported fields
}
func (*ErrFileAlreadyExists) Error ¶
func (e *ErrFileAlreadyExists) Error() string
type ErrFileNotFound ¶
type ErrFileNotFound struct {
// contains filtered or unexported fields
}
func (*ErrFileNotFound) Error ¶
func (e *ErrFileNotFound) Error() string
type ErrMergeFail ¶
type ErrMergeFail struct {
// contains filtered or unexported fields
}
The ErrMergeFail is returned if the remote could not be merged into the local data without interaction.
func (*ErrMergeFail) Error ¶
func (e *ErrMergeFail) Error() string
type ErrSymlinkNotFound ¶
type ErrSymlinkNotFound struct {
// contains filtered or unexported fields
}
func (*ErrSymlinkNotFound) Error ¶
func (e *ErrSymlinkNotFound) Error() string
type ErrUnmatchedShellReturn ¶
type ErrUnmatchedShellReturn struct {
// contains filtered or unexported fields
}
func (*ErrUnmatchedShellReturn) Error ¶
func (e *ErrUnmatchedShellReturn) Error() string