dotfile

package
v0.0.0-...-6b1ef89 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2023 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Linked    = State("linked")
	NotLinked = State("not linked")
	Conflict  = State("conflict")
	Missing   = State("missing")
)

States DotFile can be in.

Functions

This section is empty.

Types

type DotFile

type DotFile struct {
	StoredLocation   string
	OriginalLocation string
}

DotFile type represents a single dotfile, defined by its storage and linking location. If dotfile is stored, its StoredLocation corresponds to a file within dotfiles repository and OriginalLocation - to symlink in user home directory where system expects original file to be.

func New

func New(stored, original string) *DotFile

New returns a pointer to a DotFile object. Paths passed as arguments must be absolute.

func (*DotFile) CurrentState

func (df *DotFile) CurrentState() *State

CurrentState returns State object representing a state DotFile is currently in.

func (*DotFile) Delete

func (df *DotFile) Delete() error

Delete removes stored file and link to it from home dir, fails if file is not linked properly.

func (*DotFile) IsFromThisHost

func (df *DotFile) IsFromThisHost() bool

IsFromThisHost returns true if dotfile is specific to current host, false otherwise.

func (*DotFile) IsGeneric

func (df *DotFile) IsGeneric() bool

IsGeneric returns true if dotfile is not specific to any host, false otherwise.

func (*DotFile) IsLinked

func (df *DotFile) IsLinked() bool

IsLinked returns true if file is stored and linked to it's original location, false otherwise.

func (*DotFile) IsReadyToBeStored

func (df *DotFile) IsReadyToBeStored() bool

IsReadyToBeStored returns true if dotfile is ready to be stored, that is if it is a regular file not conflicting with any of already stored files.

func (*DotFile) IsStored

func (df *DotFile) IsStored() bool

IsStored returns true if given dotfile is stored.

func (df *DotFile) Link() error

Link links stored dotfile to its original location.

func (*DotFile) MustBeCopied

func (df *DotFile) MustBeCopied() bool

MustBeCopied returns true if dotfile can not be symlinked and must be copied to appropriate place instead.

func (*DotFile) Restore

func (df *DotFile) Restore() error

Restore moves stored file back into its original location, replacing symlink.

func (*DotFile) Store

func (df *DotFile) Store() error

Store puts file in storage and links to it from original location.

type FailError

type FailError string

func FailErrorFrom

func FailErrorFrom(e error) FailError

func (FailError) Error

func (e FailError) Error() string

func (FailError) ExitCode

func (e FailError) ExitCode() int

type SkipError

type SkipError string

func (SkipError) Error

func (e SkipError) Error() string

func (SkipError) ExitCode

func (e SkipError) ExitCode() int

type State

type State string

State represents current state of DotFile.

func (*State) ColorString

func (s *State) ColorString() string

ColorString generates ansi-colored representation of given State object.

func (State) String

func (s State) String() string

String returns a string representation of State.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL