commander

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: BSD-3-Clause Imports: 8 Imported by: 1

README

cmd

cmd is framework to make simple command. cmd is suitable for that has plenty of subcmd

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoCommand             = errors.New("No command provided")
	ErrCommandNotImplemented = errors.New("Command not implemented")
	ErrDisableHelp           = errors.New("Help command is disabled")
)

Functions

This section is empty.

Types

type Command

type Command struct {
	Commander
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(cmd Commander) Command

func (*Command) Register

func (c *Command) Register(cmd Commander)

func (*Command) SetHelp

func (c *Command) SetHelp(help string)

type CommandManager

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

func (*CommandManager) Register

func (c *CommandManager) Register(cmd Commander)

func (*CommandManager) Run

func (c *CommandManager) Run(ctx context.Context) error

type Commander

type Commander interface {
	Name() string
	Short() string
	Long() string
	SetFlags(f *pflag.FlagSet)
	Run(ctx context.Context) error
}

type Manage

type Manage struct {
	Stdout, Stderr io.Writer
	// if true, the help command will be added to the command list
	// Help is used for all commands.
	// default is true
	Help *bool
}

func NewCommandManager

func NewCommandManager() *Manage

func (*Manage) Build

func (m *Manage) Build() *CommandManager

func (*Manage) WithHelp

func (m *Manage) WithHelp(b bool) *Manage

func (*Manage) WithStderr

func (m *Manage) WithStderr(w io.Writer) *Manage

func (*Manage) WithStdout

func (m *Manage) WithStdout(w io.Writer) *Manage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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