golug_plugin

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All() map[string][]Plugin

func IsRegistered

func IsRegistered(plugin Plugin, opts ...ManagerOption) bool

IsRegistered check plugin whether registered global. Notice plugin is not check whether is nil

func Register

func Register(plugin Plugin, opts ...ManagerOption)

Register registers a global plugins

func String

func String() string

Types

type Base

type Base struct {
	Name       string
	OnInit     func(ent interface{})
	OnWatch    func(r *golug_watcher.Response)
	OnCommands func(cmd *cobra.Command)
	OnFlags    func(flags *pflag.FlagSet)
}

func (*Base) Commands

func (p *Base) Commands() *cobra.Command

func (*Base) Flags

func (p *Base) Flags() *pflag.FlagSet

func (*Base) Init

func (p *Base) Init(ent interface{}) (err error)

func (*Base) String

func (p *Base) String() string

func (*Base) Watch

func (p *Base) Watch(r *golug_watcher.Response) (err error)

type Manager

type Manager interface {
	Plugins(...ManagerOption) []Plugin
	Register(Plugin, ...ManagerOption) error
}

func NewManager

func NewManager() Manager

NewManager creates a new internal_plugin manager

type ManagerOption

type ManagerOption func(o *ManagerOptions)

func Module

func Module(m string) ManagerOption

Module will scope the plugin to a specific module, e.g. the "api"

type ManagerOptions

type ManagerOptions struct {
	Module string
}

type Option

type Option func(o *Options)

type Options

type Options struct {
	Name     string
	Flags    *pflag.FlagSet
	Commands *cobra.Command
}

type Plugin

type Plugin interface {
	Watch(r *golug_watcher.Response) error
	Init(ent interface{}) error
	Flags() *pflag.FlagSet
	Commands() *cobra.Command
	String() string
}

func List

func List(opts ...ManagerOption) []Plugin

List lists the global plugins

Jump to

Keyboard shortcuts

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