hooks

package
v0.0.0-...-a114629 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// This is first hook that will run before every thing (#1).
	// The config on this stage will always be empty
	// You cannot use this in plugin of course before it execute before plugin
	// You might use this hook to add some information before cli flow will be start
	BEFORE_PLUGIN = "before-plugin"

	// run after all plugins are loaded
	// This will execute after all plugins are loaded (#2).
	// The config on this stage will contains plugins setup data
	// You might use this to setup config that relate to multiple plugins
	AFTER_PLUGIN = "after-plugin"

	// This will execute after all flags are loaded (#3).
	// The config on this stage will contains mostly every information setup by client
	// You might use this to update data to config data that relate to flags
	AFTER_FLAG = "after-flag"

	// This will execute before the command will be execute (#4).
	// The config on this stage will contains extra data added by cli itself.
	//   `internal.command` - current execution command
	//   `internal.args`    - cli arguments that leftover to command itself
	// You might use this to final setup before command will be run
	BEFORE_COMMAND = "before-command"

	// This will execute after the command is executed (#5).
	// The config on this stage will contains extra more information added by cli itself.
	//   `internal.error` - command execution result (error)
	// You might use this to override the error or print summary result
	AFTER_COMMAND = "after-command"

	// This is special hook for help commands.
	// The config Mapper on this hooks
	// will have special 'internal.command' as *commands.Manager,
	// and 'internal.flag' as *flags.Manager
	INTERNAL_HELP = "internal-help"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Creator

type Creator func(t Type, hook Hook)

Creator is action to help plugin to create new flag

type Hook

type Hook func(config mapper.Mapper) error

Hook action

type Manager

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

func New

func New(l *logger.Logger) *Manager

func (*Manager) Add

func (m *Manager) Add(t Type, hook Hook)

func (*Manager) Size

func (m *Manager) Size(t Type) int

func (*Manager) Start

func (m *Manager) Start(t Type, config mapper.Mapper) error

func (*Manager) String

func (m *Manager) String() string

type Type

type Type string

Jump to

Keyboard shortcuts

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