subcmd

package
v0.0.0-...-c39e8e5 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: AGPL-3.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

type Func func(args []string) error

Func is an entry function of a sub command.

type HostFunc

type HostFunc func(host string, args []string) error

HostFunc is an entry function of a sub command with a host target.

type List

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

List is a list of sub command entires.

func New

func New() *List

New creates an empty list of sub command entries.

func (*List) Add

func (lst *List) Add(name, desc string, f Func)

Add adds a sub command entry. It panics if already exists a command with the same name.

func (*List) AddHost

func (lst *List) AddHost(name, desc string, f HostFunc)

AddHost adds a sub command entry that can accept a host target. It panics if already exists a command with the same name.

func (*List) Help

func (lst *List) Help(w io.Writer)

Help prints out the help message.

func (*List) Main

func (lst *List) Main()

Main runs with os.Args, and calls os.Exit if the return value is not 0.

func (*List) Run

func (lst *List) Run(args []string) int

Run runs and dispatches the sub command.

func (*List) SetDefaultServer

func (lst *List) SetDefaultServer(s string)

SetDefaultServer sets the default server for commands that has a host.

Jump to

Keyboard shortcuts

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