Documentation ¶
Overview ¶
Package command provides a common structure for building command line programs.
Index ¶
- func BackgroundContext(log *zap.Logger) context.Context
- func Logger() (*zap.Logger, error)
- func Run(m MainStatus)
- func RunError(m MainError)
- type Base
- func (b Base) CheckClose(statusp *subcommands.ExitStatus, c io.Closer)
- func (b Base) Error(err error) subcommands.ExitStatus
- func (b Base) Fail(format string, args ...interface{}) subcommands.ExitStatus
- func (Base) SetFlags(f *flag.FlagSet)
- func (b Base) Status(err error) subcommands.ExitStatus
- func (b Base) UsageError(format string, args ...interface{}) subcommands.ExitStatus
- type MainError
- type MainStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackgroundContext ¶
BackgroundContext returns a context suitable for a command-line tool or service.
func Run ¶
func Run(m MainStatus)
Types ¶
type Base ¶
Base is a base for all subcommands.
func (Base) CheckClose ¶
func (b Base) CheckClose(statusp *subcommands.ExitStatus, c io.Closer)
CheckClose closes c. On error it logs and writes to the status pointer. Intended for deferred Close() calls.
func (Base) Error ¶
func (b Base) Error(err error) subcommands.ExitStatus
Error logs err and returns a failing exit code.
func (Base) Fail ¶
func (b Base) Fail(format string, args ...interface{}) subcommands.ExitStatus
Fail logs an error message and returns a failing exit code.
func (Base) Status ¶
func (b Base) Status(err error) subcommands.ExitStatus
Status fails if the provided error is non-nil, and returns success otherwise.
func (Base) UsageError ¶
func (b Base) UsageError(format string, args ...interface{}) subcommands.ExitStatus
UsageError logs a usage error and returns a suitable exit code.
Click to show internal directories.
Click to hide internal directories.