cmd

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSendTargetValidationFailed is returned if a send target can't pass a
	// validation.
	ErrSendTargetValidationFailed = errors.New("send target validation failed")

	// ErrCantSendEvent is returned if event can't be sent.
	ErrCantSendEvent = errors.New("can't send event")
)
View Source
var ErrCantBePresented = errors.New("can't be presented")

ErrCantBePresented is returned if data can't be presented.

View Source
var ErrUnsupportedOutputMode = errors.New("unsupported mode")

ErrUnsupportedOutputMode is returned if user passed a unsupported output mode.

Functions

This section is empty.

Types

type Cmd

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

Cmd represents a command line application entrypoint.

func (*Cmd) Execute

func (c *Cmd) Execute()

Execute will execute the application.

func (*Cmd) ExecuteWithOptions

func (c *Cmd) ExecuteWithOptions(options ...CommandOption) error

ExecuteWithOptions will execute the application with the provided options.

type CommandOption

type CommandOption func(*cobra.Command)

CommandOption is used to configure a command in Cmd.ExecuteWithOptions.

func WithArgs

func WithArgs(args ...string) CommandOption

WithArgs creates an option which sets args.

func WithOutput

func WithOutput(out io.Writer) CommandOption

WithOutput creates an option witch sets os.Stdout and os.Stderr.

type TestingCmd

type TestingCmd struct {
	*Cmd
}

TestingCmd a wrapper for Cmd to ease of testing.

func (*TestingCmd) Args

func (c *TestingCmd) Args(args ...string)

Args set to main command to be executed.

func (*TestingCmd) Execute

func (c *TestingCmd) Execute() error

Execute the command and return error if any.

func (*TestingCmd) ExecuteOrFail

func (c *TestingCmd) ExecuteOrFail()

ExecuteOrFail the command or fail on error.

func (*TestingCmd) Exit

func (c *TestingCmd) Exit(fn func(code int))

Exit sets the exit command that accepts retcode.

func (*TestingCmd) Out

func (c *TestingCmd) Out(newOut io.Writer)

Out sets output stream to cmd.

Jump to

Keyboard shortcuts

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