alias

package
v0.0.0-...-2bbe97e Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BucketKey is the name of the bucket where aliases are stored
	BucketKey = "alias"
	// ErrorNotFound will be thrown if the alias can not be found
	ErrorNotFound = errors.New("Alias not found")
	// ErrorNoName will be thrown if the alias has no name
	ErrorNoName = errors.New("An alias has no name")
	// ErrorDuplicateAlias will be thrown if there is already an alias with that name
	ErrorDuplicateAlias = errors.New("The alias already exist")
	// ErrorFileAlreadyPresent will be thrown if the symlink cannot be created due to an existing file with the same name
	ErrorFileAlreadyPresent = errors.New("The symlink could not be created because there is already a file with that name")
	// ErrorNaughtyBoy will be thrown it the user tries to install a tool with the slh alias
	ErrorNaughtyBoy = errors.New("It is not recommended to alias any tool with 'slh'...")
)

Functions

func CreateSymlink(name string) error

CreateSymlink will create the given symlink if possible

func HasSymlink(name string) (bool, error)

HasSymlink will check if the given symlink is already present

func RemoveSymlink(name string) error

RemoveSymlink will remove the given symlink if possible

Types

type Alias

type Alias struct {
	Name     string `json:"name"`
	Registry string `json:"registry"`
	Tool     string `json:"tool"`
	Version  string `json:"version"`
}

Alias is a struct that will be used when the user installs a tool. That will create an alias that can be used as a shortcut.

type Aliases

type Aliases struct {
	config.Database
}

Aliases is the main access point for adding/removing/editing aliases

func New

func New(db config.Database) *Aliases

New will create a new Aliases struct based on the given bolt database. It offers methods to add/remove and list all aliases registered with Sledgehammer

func (*Aliases) Add

func (m *Aliases) Add(alias Alias) error

Add will add the given alias to sledgehammer. It will overwrite any entry with the same name.

func (*Aliases) From

func (m *Aliases) From(name string, registry string) ([]Alias, error)

Get will get all alias for a given tool

func (*Aliases) Get

func (m *Aliases) Get(name string) (*Alias, error)

Get will get a single alias if available

func (*Aliases) Has

func (m *Aliases) Has(name string) (bool, error)

Has will check if a single alias is present in the database

func (*Aliases) List

func (m *Aliases) List() ([]Alias, error)

List will return the current aliases

func (*Aliases) Remove

func (m *Aliases) Remove(name string) error

Remove will try to remove the given alias and returns an error if any problem occurs.

Jump to

Keyboard shortcuts

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