plugin

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotUpgradable = errors.New("this plugin is not upgradable")

Returned by `Plugin.CheckUpdate` and indicates that a plugin being checked is not upgradable.

View Source
var ErrUnknownPluginType = errors.New("cannot parse the spec for an unknown plugin type")
View Source
var NotInstallable = errors.New("this plugin cannot be installed from the external source")
View Source
var NotInstalled = errors.New("not installed")

Returned by `Plugin.CheckUpdate` and indicates that a plugin being checked have not been installed.

View Source
var UpToDate = errors.New("up to date")

Returned by `Plugin.CheckUpdate` and indicates that a plugin being checked is up to date.

Functions

func IsNotInstalled

func IsNotInstalled(err error) bool

Check if a plugin is not installed with the error value of `Plugin.CheckUpdate`.

func IsNotUpgradable added in v0.2.0

func IsNotUpgradable(err error) bool

Check if a plugin is cannot be updated with the error value of `Plugin.CheckUpdate`.

func IsUpToDate added in v0.2.0

func IsUpToDate(err error) bool

Check if a plugin is up to date with the error value of `Plugin.CheckUpdate`.

func MakePluginStorage added in v0.2.0

func MakePluginStorage(
	root string,
	pluginSpecs []string,
) (ps *pluginStorage, err error)

Types

type Dir

type Dir struct {
	Path string
}

Dir is the plugin type loaded from a source directory.

func (Dir) CheckUpdate

func (p Dir) CheckUpdate(bool) (*string, error)

func (Dir) InstallUpdate

func (p Dir) InstallUpdate() error

func (Dir) IsInstalled added in v0.2.0

func (p Dir) IsInstalled() (installed bool, err error)

func (Dir) Load

func (p Dir) Load() (fpath []string, exec []string, err error)

type Git added in v0.1.1

type Git struct {
	// Remote URL
	URL string

	// We reuse the `Dir` plugin type to load the plugin into zsh.
	Dir Dir
	// contains filtered or unexported fields
}

The plugin type downloaded from a Git repository.

func NewGit added in v0.1.1

func NewGit(URL string, requiredRevision string, root string) Git

NewGit creates a new Git plugin. URL must come without a scheme (like github.com/robbyrussel/oh-my-zsh).

func (*Git) CheckUpdate added in v0.1.1

func (p *Git) CheckUpdate(offline bool) (message *string, err error)

func (*Git) InstallUpdate added in v0.1.1

func (p *Git) InstallUpdate() error

func (*Git) IsInstalled added in v0.2.0

func (p *Git) IsInstalled() (installed bool, err error)

func (*Git) Load added in v0.1.1

func (p *Git) Load() ([]string, []string, error)

type OhMyZsh

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

The plugin type to deal with Oh My Zsh

func (*OhMyZsh) CheckUpdate

func (p *OhMyZsh) CheckUpdate(offline bool) (*string, error)

func (*OhMyZsh) InstallUpdate

func (p *OhMyZsh) InstallUpdate() error

func (*OhMyZsh) IsInstalled added in v0.2.0

func (p *OhMyZsh) IsInstalled() (installed bool, err error)

func (*OhMyZsh) Load

func (p *OhMyZsh) Load() (fpath []string, exec []string, err error)

func (*OhMyZsh) LoadPlugin

func (p *OhMyZsh) LoadPlugin(name string) Dir

func (*OhMyZsh) LoadTheme

func (p *OhMyZsh) LoadTheme(name string) Dir

func (OhMyZsh) MakePlugin added in v0.3.0

func (p OhMyZsh) MakePlugin(_ string, params map[string]string) (*Plugin, error)

func (OhMyZsh) MakeTheme added in v0.3.0

func (p OhMyZsh) MakeTheme(_ string, params map[string]string) (*Plugin, error)

type Plugin

type Plugin interface {
	// Returns `fpath` with functions to be loaded from a plugin and the lines
	// that are required to be executed in order to correctly load a plugin.
	Load() (fpath []string, exec []string, err error)
	// Check for update and return the message describing the update. If no
	// update is available, `nil` is returned instead of an update description.
	// If a plugin is not installed, an error must be set to `NotInstalled` and
	// this can be checked with the `IsNotInstalled` function.
	CheckUpdate(offline bool) (message *string, err error)
	// Install an update if available or install a plugin if not installed. Must
	// be called after a successful `CheckUpdate` call (that returned an update
	// description or the `NotInstalled` error). Otherwise it may cause a panic
	// or an unexpected error.
	InstallUpdate() error
	// IsInstalled checks if the plugin is actually installed.
	IsInstalled() (installed bool, err error)
}

This is the universal interface for all plugin types loaded by `zpm`. All plugins must be used via this interface outside the `plugin` module.

func MakeDir

func MakeDir(root string, params map[string]string) (*Plugin, error)

func MakeGitHub

func MakeGitHub(root string, params map[string]string) (*Plugin, error)

func MakeOhMyZsh

func MakeOhMyZsh(root string, params map[string]string) (*Plugin, error)

Jump to

Keyboard shortcuts

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