plugin

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCobraSubcommand

func NewCobraSubcommand(subcmd Subcommand, hooks ...InitHook) (*cobra.Command, error)

func NewCobraSubcommandOrDie

func NewCobraSubcommandOrDie(subcmd Subcommand, hooks ...InitHook) *cobra.Command

func RunSubcommand

func RunSubcommand(cmd Subcommand, args []string) error

Types

type InitHook

type InitHook func(*cobra.Command, Subcommand) error

type RequiresPostRun

type RequiresPostRun interface {
	// PostRun runs after command's Run().
	PostRun(args []string) error
}

RequiresValidation is a subcommand that requires post run

type RequiresPreRun

type RequiresPreRun interface {
	// PreRun runs before command's Run().
	// It can be used to verify that the command can be run
	PreRun(args []string) error
}

RequiresValidation is a subcommand that requires pre run

type Subcommand

type Subcommand interface {
	// Name returns the subcommand's name
	Name() string
	// BindFlags binds the subcommand's flags to the CLI. This allows each subcommand to define its own
	// command line flags.
	BindFlags(fs *pflag.FlagSet)
	// Run runs the subcommand.
	Run(args []string) error
}

Subcommand is an interface that defines the common base for subcommands returned by plugins

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳