plugin

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Information

func Information(name string) error

func List

func List(ctx context.Context) error

func Run

func Run(ctx context.Context, name string, opts Options) error
func Search(ctx context.Context, keyword string) error

func Uninstall

func Uninstall(ctx context.Context, name string) error

func Update

func Update(ctx context.Context, opts Options) error

func Upgrade

func Upgrade(ctx context.Context, names []string) error

Types

type Index

type Index struct {
	Version int `yaml:"version"`
	Plugins []struct {
		Name       string `yaml:"name"`
		Version    string `yaml:"version"`
		Maintainer string `yaml:"maintainer"`
		Summary    string `yaml:"summary"`
		Repository string `yaml:"repository"`
		Output     bool   `yaml:"output"`
	} `yaml:"plugins"`
}

type Input

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

Input represents the user-specified Input.

func (*Input) String

func (i *Input) String() string

type Installed

type Installed struct {
	Platform Selector `yaml:"platform"`
}

type Manager

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

Manager manages the plugins

func NewManager

func NewManager(opts ...ManagerOption) *Manager

func (*Manager) Information

func (m *Manager) Information(name string) error

Information gets the information about an installed plugin

func (*Manager) Install

func (m *Manager) Install(ctx context.Context, arg string, opts Options) (Plugin, error)

Install installs a plugin

func (*Manager) List

func (m *Manager) List(ctx context.Context) error

List gets a list of all installed plugins

func (*Manager) LoadAll

func (m *Manager) LoadAll(ctx context.Context) ([]Plugin, error)

LoadAll loads all plugins

func (*Manager) Run

func (m *Manager) Run(ctx context.Context, name string, opts Options) error

Run installs and runs the plugin

func (*Manager) Search

func (m *Manager) Search(ctx context.Context, keyword string) error

func (*Manager) Start

func (m *Manager) Start(ctx context.Context, name string, opts Options) (Wait, error)

Start starts the plugin

func (*Manager) Uninstall

func (m *Manager) Uninstall(ctx context.Context, name string) error

Uninstall installs the plugin

func (*Manager) Update

func (m *Manager) Update(ctx context.Context, opts Options) error

func (*Manager) Upgrade

func (m *Manager) Upgrade(ctx context.Context, names []string) error

Upgrade upgrades an existing plugins

type ManagerOption

type ManagerOption func(indexer *Manager)

func WithIndexURL

func WithIndexURL(indexURL string) ManagerOption

func WithLogger

func WithLogger(logger *log.Logger) ManagerOption

func WithWriter

func WithWriter(w io.Writer) ManagerOption

type Options

type Options struct {
	Args     []string
	Stdin    io.Reader // For output plugin
	Platform ftypes.Platform
	Insecure bool
}

type Platform

type Platform struct {
	Selector *Selector
	URI      string
	Bin      string
}

Platform represents where the execution file exists per platform.

type Plugin

type Plugin struct {
	Name        string     `yaml:"name"`
	Repository  string     `yaml:"repository"`
	Version     string     `yaml:"version"`
	Summary     string     `yaml:"summary"`
	Usage       string     `yaml:"usage"` // Deprecated: Use summary instead
	Description string     `yaml:"description"`
	Platforms   []Platform `yaml:"platforms"`

	// Installed holds the metadata about installation
	Installed Installed `yaml:"installed"`
	// contains filtered or unexported fields
}

Plugin represents a plugin.

func Install

func Install(ctx context.Context, name string, opts Options) (Plugin, error)

func (*Plugin) Cmd

func (p *Plugin) Cmd(ctx context.Context, opts Options) (*exec.Cmd, error)

func (*Plugin) Dir

func (p *Plugin) Dir() string

func (*Plugin) Run

func (p *Plugin) Run(ctx context.Context, opts Options) error

Run runs the plugin

func (*Plugin) Start

func (p *Plugin) Start(ctx context.Context, opts Options) (Wait, error)

Start starts the plugin

After a successful call to Start the Wait method must be called.

type Selector

type Selector struct {
	OS   string `yaml:"os"`
	Arch string `yaml:"arch"`
}

Selector represents the environment.

type Wait

type Wait func() error

func Start

func Start(ctx context.Context, name string, opts Options) (Wait, error)

Jump to

Keyboard shortcuts

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