plugins

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: MIT Imports: 6 Imported by: 4

README

plugins

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByType

func ByType[T any](plugs Plugins) []T

ByType finder can be used to find plugins by their type.

func Stderr

func Stderr(plugs ...Plugin) io.Writer

Stderr returns a io.MultiWriter containing all plugins that implement Outer. If none are found, then os.Stderr is returned

func Stdout

func Stdout(plugs ...Plugin) io.Writer

Stdout returns a io.MultiWriter containing all plugins that implement Outer. If none are found, then os.Stdout is returned

Types

type AvailabilityChecker

type AvailabilityChecker interface {
	Plugin
	PluginAvailable(root string) bool
}

AvailabilityChecker can be implemented to check if a plugin is available to be used at the given root.

type FSSetable

type FSSetable interface {
	Plugin
	SetFileSystem(fs.FS) error
}

FSSetable can be implemented to receive an fs.FS

type FSable

type FSable interface {
	Plugin
	FileSystem() (fs.FS, error)
}

FSable can be implemented to return an fs.FS

type Feeder

type Feeder interface {
	Plugin
	PluginFeeder() FeederFn
}

Feeder can be implemented to return a FeederFn.

type FeederFn

type FeederFn func() Plugins

FeederFn is a function that is used to feed plugins into a Needer implementation.

type Findable

type Findable interface {
	Find(plugs Plugins) (Plugins, error)
}

Findable can be implemented to find plugins

func Background

func Background(name string) Findable

Background finder that will search for a plugin based on the plugin's name.

type FinderFn

type FinderFn func(plugs Plugins) (Plugins, error)

FinderFn is a function that can be used to find plugins. It implements the Finder interface.

func (FinderFn) Find

func (f FinderFn) Find(plugs Plugins) (Plugins, error)

Find plugins using the underlying function.

type IO

type IO = iox.IO

type IOSetable

type IOSetable interface {
	Plugin
	iox.IOSetable
}

IOSetable can be implemented to receive an IO.

type IOable

type IOable interface {
	Plugin
	iox.IOable
}

IOable can be implemented to return an IO.

type Needer

type Needer interface {
	Plugin
	WithPlugins(FeederFn) error
}

Needer can be implemented to receive a Feeder function that can be used to gain access to other plugins in the system.

type Plugin

type Plugin interface {
	PluginName() string
}

Plugin is the most basic interface a plugin can implement.

type Plugins

type Plugins []Plugin

Plugins is a slice of type `Plugin` that provides additional useful functionality.

func (Plugins) Available

func (plugs Plugins) Available(root string) Plugins

Available will return plugins that are available to be used at the given root. By default, all plugins are available. The AvailabilityChecker interface can be implemented to give the plugin the ability to check if it is available.

func (Plugins) Find

func (plugs Plugins) Find(fn FinderFn) (Plugins, error)

Find plugins using the given Finder.

func (Plugins) Len

func (plugs Plugins) Len() int

Len is the number of elements in the collection.

func (Plugins) Less

func (plugs Plugins) Less(i int, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (Plugins) PluginFeeder

func (plugs Plugins) PluginFeeder() FeederFn

func (Plugins) PluginName

func (plugs Plugins) PluginName() string

func (Plugins) ScopedPlugins

func (plugs Plugins) ScopedPlugins() Plugins

ScopedPlugins implements Scoper, return itself.

func (Plugins) SetFileSystem

func (plugs Plugins) SetFileSystem(fs fs.FS) error

SetFS for those plugins that implement FSSetable.

func (Plugins) SetStdio

func (plugs Plugins) SetStdio(io IO) error

SetStdio for those plugins that implement IOSetable.

func (Plugins) Swap

func (plugs Plugins) Swap(i int, j int)

Swap swaps the elements with indexes i and j.

func (Plugins) WithPlugins

func (plugs Plugins) WithPlugins(fn FeederFn) error

WithPlugins will call any Needer plugins with the Feeder function.

type Scoper

type Scoper interface {
	Plugin
	ScopedPlugins() Plugins
}

Scoper can be implemented to return a slice of plugins that are important to the type defining it.

type Stderrer

type Stderrer interface {
	Plugin
	iox.Stderrer
}

type Stdiner

type Stdiner interface {
	Plugin
	iox.Stdiner
}

type Stdioer

type Stdioer interface {
	Plugin
	iox.Stdioer
}

type Stdouter

type Stdouter interface {
	Plugin
	iox.Stdouter
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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