plugcmd

package
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: 11 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

func Clean(p plugins.Plugin, flags []*flag.Flag) []*flag.Flag

CleanFlags sanitizes, and namespaces, flags to be used when incorporating flags from other plugins.

func CleanSet

func CleanSet(p plugins.Plugin, set *flag.FlagSet) []*flag.Flag

CleanFlagSet sanitizes, and namespaces, flags to be used when incorporating flags from other plugins.

func Print

func Print(w io.Writer, main plugins.Plugin) error

Print will try and print a helpful Usage printing of the plugin and any plugins that are provided.

$ foobar
---------

Usage of foobar:
-h, --help   print this help

Available Commands:
	foobar info     Print diagnostic information (useful for debugging)
	foobar version  Print the version information

func SetToSlice

func SetToSlice(set *flag.FlagSet) []*flag.Flag

SetToSlice takes a flag set and returns a slice of the flags

Types

type Aliaser

type Aliaser interface {
	plugins.Plugin
	CmdAliases() []string
}

Aliaser is a command that provides aliases for itself

type AliaserFn

type AliaserFn func() []string

AliaserFn is a function that can be used to implement the Aliaser interface

func (AliaserFn) CmdAliases

func (fn AliaserFn) CmdAliases() []string

func (AliaserFn) PluginName

func (fn AliaserFn) PluginName() string

type Commander

type Commander interface {
	plugins.Plugin
	Main(ctx context.Context, root string, args []string) error
}

Commander is a plugin that is meant to be the beginning of a CLI application

func Find

func Find(name string, plugs plugins.Plugins) Commander

Find wraps the other cmd finders into a mega finder for cmds

func FindFromArgs

func FindFromArgs(args []string, plugs plugins.Plugins) Commander

FindFromArgs uses the first arg that does not begin with `-` as the name argument for Find

type CommanderFn

type CommanderFn func(ctx context.Context, root string, args []string) error

CommanderFn is a function that can be used to implement the Commander interface

func (CommanderFn) Main

func (fn CommanderFn) Main(ctx context.Context, root string, args []string) error

func (CommanderFn) PluginName

func (fn CommanderFn) PluginName() string

type Describer

type Describer interface {
	plugins.Plugin
	Description() string
}

Describer is called by `Print` and can be implemented to print a short, single line, description of the plugin. `-h`

type DescriberFn

type DescriberFn func() string

DescriberFn is a function that can be used to implement the Describer interface

func (DescriberFn) Description

func (fn DescriberFn) Description() string

func (DescriberFn) PluginName

func (fn DescriberFn) PluginName() string

type FlagPrinter

type FlagPrinter interface {
	plugins.Plugin
	PrintFlags(w io.Writer) error
}

type FlagPrinterFn

type FlagPrinterFn func(w io.Writer) error

FlagPrinterFn is a function that can be used to implement the FlagPrinter interface

func (FlagPrinterFn) PluginName

func (fn FlagPrinterFn) PluginName() string

func (FlagPrinterFn) PrintFlags

func (fn FlagPrinterFn) PrintFlags(w io.Writer) error

type Flagger

type Flagger interface {
	plugins.Plugin
	Flags() (*flag.FlagSet, error)
}

type FlaggerFn

type FlaggerFn func() (*flag.FlagSet, error)

FlaggerFn is a function that can be used to implement the Flagger interface

func (FlaggerFn) Flags

func (fn FlaggerFn) Flags() (*flag.FlagSet, error)

func (FlaggerFn) PluginName

func (fn FlaggerFn) PluginName() string

type NamedCommander

type NamedCommander interface {
	Commander
	Namer
}

type Namer

type Namer interface {
	plugins.Plugin
	CmdName() string
}

Namer is a command that provides a different name for the command than the name of the Plugin

type NamerFn

type NamerFn func() string

NamerFn is a function that can be used to implement the Namer interface

func (NamerFn) CmdName

func (fn NamerFn) CmdName() string

func (NamerFn) PluginName

func (fn NamerFn) PluginName() string

type SubCommander

type SubCommander interface {
	plugins.Plugin
	SubCommands() []Commander
}

SubCommander can be implemented to provide a list of plugins.Plugin that can be used as sub-commands of the current Plugin

type SubCommanderFn

type SubCommanderFn func() []Commander

SubCommanderFn is a function that can be used to implement the SubCommander interface

func (SubCommanderFn) PluginName

func (fn SubCommanderFn) PluginName() string

func (SubCommanderFn) SubCommands

func (fn SubCommanderFn) SubCommands() []Commander

type UsagePrinter

type UsagePrinter interface {
	plugins.Plugin
	PrintUsage(w io.Writer) error
}

UsagePrinter is called by `Print` and can be implemented to print a large block of usage information after the `Describer` interface is called. This is useful for printing flag information, links, and other messages to users.

type UsagePrinterFn

type UsagePrinterFn func(w io.Writer) error

UsagePrinterFn is a function that can be used to implement the UsagePrinter interface

func (UsagePrinterFn) PluginName

func (fn UsagePrinterFn) PluginName() string

func (UsagePrinterFn) PrintUsage

func (fn UsagePrinterFn) PrintUsage(w io.Writer) error

Jump to

Keyboard shortcuts

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