plugins

package
Version: v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleCommand

func HandleCommand(handler PluginHandler, args []string) error

HandleCommand receives a PluginHandler and command-line arguments and attempts to find a plugin executable on the PATH that satisfies the given arguments.

Types

type ExecHandler

type ExecHandler struct {
	Prefix string
	Exec   execFunc
}

ExecHandler implements PluginHandler using the "os/exec" package.

func NewExecHandler

func NewExecHandler(prefix string) *ExecHandler

NewExecHandler creates and returns a new ExecHandler configured with the prefix.

func (*ExecHandler) Execute

func (h *ExecHandler) Execute(filename string, args, env []string) error

Execute implements PluginHandler.Execute

func (*ExecHandler) Lookup

func (h *ExecHandler) Lookup(command string) string

Lookup implements PluginHandler, using https://golang.org/pkg/os/exec/#LookPath to search for the command.

type PluginHandler

type PluginHandler interface {
	// Lookup should return the full path to an executable for the provided
	// command, or "" if no matching command can be found.
	Lookup(command string) string

	// Execute should execute the provided path, passing in the args and env.
	Execute(filename string, args, env []string) error
}

PluginHandler provides functionality for finding and executing external plugins.

Jump to

Keyboard shortcuts

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