dotfile

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: 7 Imported by: 0

Documentation

Overview

Package dotfile holds functionality for working with dotfiles and registries.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("dotfile not found")

ErrNotFound is returned when a dotfile is not found.

Functions

This section is empty.

Types

type Dotfile

type Dotfile struct {
	// Name is the name of the dotfile used to uniquely identify it in the registry.
	Name string `yaml:"-"`
	// SrcPath is the path to the dotfile source within the registry.
	// It must be relative and cannot start with '.' or '..'.
	SrcPath string `yaml:"src"`
	// DstPath is the path dotfile on the OS filesystem.
	// It must be absolute i.e. start with a slash.
	// The one exception to this rule is it maybe start with '~/'.
	// It is up to the caller to decide how to handle '~'.
	DstPath string `yaml:"dst"`
	// OS is a list of supported operating systems for this dotfile.
	// If OS is empty, it is interpreted as all operating systems being supported.
	OS []string `yaml:"os"`
}

Dotfile represents a dotfile managed by a registry.

type ErrorList

type ErrorList []error

ErrorList is a list of errors encountered.

func (ErrorList) Error

func (e ErrorList) Error() string

type Registry

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

Registry represents a dot registry. A registry is a directory containing dotfile sources and configuration. Registries are read-only.

func NewRegistry

func NewRegistry(fsys fs.FS) (*Registry, error)

NewRegistry creates a new Registry object from fsys. fsys must contain a `dot.yml` file that holds the configuration for the registry. NewRegistry will read `dot.yml` and return an validation errors encountered.

func (*Registry) Dotfiles

func (r *Registry) Dotfiles(names ...string) ([]Dotfile, error)

Dotfiles returns a list of dotfiles contained in the registry. A list of names can be provided to filter which dotfiles are returned. If no names are provided, all dotfiles are returned.

func (*Registry) OpenDotfile

func (r *Registry) OpenDotfile(name string) (fs.File, error)

OpenDotfile opens the dotfile and returns a fs.File allowing access to the data.

type ValidationError

type ValidationError struct {
	DotfileName string
	Messages    []string
}

ValidationError represents a dotfile having failed validation. It contains the dotfile name and a list of validation failure messages.

func (*ValidationError) Error

func (ve *ValidationError) Error() string

Jump to

Keyboard shortcuts

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