client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSetup = stderrors.New("not setup")

ErrNotSetup is returned when a dotfile has not been setup to be managed by dot.

View Source
var ErrSetup = stderrors.New("already setup with a different registry")

ErrSetup is returned when dot has already been setup with a different registry.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides the API for managing dotfiles with dot.

func New

func New(opts ...Option) (*Client, error)

New creates a new Client instance.

func (*Client) Apply

func (c *Client) Apply(force bool, names ...string) error

Apply will copy dotfile sources from a registry to their destination. Optionally, a list of dotfile names can be provided to only apply specific dotfiles. If no names are provided, all dotfiles will be applied.

By default, Apply will check if the dotfile destination file has been manually modified. If a modification is detected, the dotfile will not be applied and an error will be returned. If force is set to true, this check is skipped and the dotfile is always applied.

func (*Client) IsSetup

func (c *Client) IsSetup() bool

IsSetup returns whether or not dot has been setup to manage dotfiles.

func (*Client) Setup

func (c *Client) Setup(registryDir string, force bool) error

Setup will setup dot to manage dotfiles. If the dotfile destination already exists, a backup of it will be made, so the original version can be restored. Setup will only setup dotfiles that have not been previously setup. This means it can be called multiple times to setup additional dotfiles.

If registryDir is different than the one used by dot, Setup will return ErrSetup unless force is true, in which case it will overwrite the current registry dir.

type Debugger

type Debugger interface {
	Debugf(format string, args ...interface{})
}

Debugger wraps the Debugf method and represents any type that can write debug messages.

type Option

type Option func(*Client)

Option is a function that takes a Client instance and applies a configuration to it.

func WithDebugger

func WithDebugger(d Debugger) Option

WithDebugger sets a Debugger that should be used by the client to write debug messages.

func WithHomeDir

func WithHomeDir(dir string) Option

WithHomeDir sets the directory that the client should use when the home directory is needed.

Jump to

Keyboard shortcuts

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