cli

package
v2.25.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHelpCalled = errors.New("help called")

ErrHelpCalled is returned from the Call function if the given command is not found and the help function was executed

Functions

This section is empty.

Types

type Registry

type Registry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Registry contains a collection of commands to be executed

func New

func New() *Registry

New creates a new Registry

func (*Registry) Add

func (c *Registry) Add(e RegistryEntry)

Add adds a new command to the Registry

func (*Registry) Call

func (c *Registry) Call(args []string) error

Call executes the matchign command from the given arguments

type RegistryEntry

type RegistryEntry struct {
	Description string
	Name        string
	Params      []string
	Run         func([]string) error
}

Entry defines a sub-command with its parameters, description and run function to be called when this command is executed

Jump to

Keyboard shortcuts

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