subcmd

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrShowedHelp = errors.New("already showed help")

ErrShowedHelp is used in parsing argument function of subcommand when the subcommand showed help. Then caller can exit successfully and silently.

Functions

This section is empty.

Types

type Cmd

type Cmd interface {
	ProhibitRootExecution(args []string) bool
	Run(args []string) *Error
	FlagSet() *flag.FlagSet
}

Cmd represents volt's subcommand interface. All subcommands must implement this.

type Error

type Error struct {
	Code int
	Msg  string
}

Error is a command error. It also has a exit code.

func DefaultRunner

func DefaultRunner(c Cmd, args []string) *Error

DefaultRunner simply runs command with args

func Run

func Run(args []string, cont RunnerFunc) *Error

Run is invoked by main(), each argument means 'volt {subcmd} {args}'.

func (*Error) Error

func (e *Error) Error() string

type RunnerFunc

type RunnerFunc func(c Cmd, args []string) *Error

RunnerFunc invokes c with args. On unit testing, a mock function was given.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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