plugin

package
v0.1.73 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandlePluginCommand

func HandlePluginCommand(pluginHandler Handler, cmdArgs []string) (found bool, err error)

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

Types

type DefaultHandler

type DefaultHandler struct {
	ValidPrefixes []string
}

DefaultHandler implements Handler

func (*DefaultHandler) Execute

func (h *DefaultHandler) Execute(executablePath string, cmdArgs, environment []string) error

Execute implements Handler

func (*DefaultHandler) Lookup

func (h *DefaultHandler) Lookup(filename string) (string, bool)

Lookup implements Handler

type Handler

type Handler interface {
	// exists at the given filename, or a boolean false.
	// Lookup will iterate over a list of given prefixes
	// in order to recognize valid plugin filenames.
	// The first filepath to match a prefix is returned.
	Lookup(filename string) (string, bool)
	// Execute receives an executable's filepath, a slice
	// of arguments, and a slice of environment variables
	// to relay to the executable.
	Execute(executablePath string, cmdArgs, environment []string) error
}

Handler is capable of parsing command line arguments and performing executable filename lookups to search for valid plugin files, and execute found plugins.

func NewDefaultPluginHandler

func NewDefaultPluginHandler(validPrefixes []string) Handler

NewDefaultPluginHandler instantiates the DefaultPluginHandler with a list of given filename prefixes used to identify valid plugin filenames.

Jump to

Keyboard shortcuts

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