cli

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

package cli provides wrapper support for executing commands, this is so we can test the rest of the implementations quickly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cli

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

Cli

func (*Cli) Execute

func (c *Cli) Execute(args ...string) (string, error)

func (*Cli) ExecuteAndStreamOutput

func (c *Cli) ExecuteAndStreamOutput(outputHandler OutputHandler, args ...string) error

ExecuteAndStreamOutput runs a system command and streams the output (stdout) and errors (stderr) to the provided output handler function. This function will run the command specified by the args parameters. The first arg should be the command itself, and the rest of the args should be its parameters. The outputHandler is a callback function that is called with each line of output and error from the command. If the command runs successfully, the function will return nil. If there's an error executing the command, it will return an error. Note that an error from the command itself (e.g., a non-zero exit status) will also be returned as an error from this function.

func (*Cli) ExecuteBytes

func (c *Cli) ExecuteBytes(args ...string) ([]byte, error)

type CmdExecutor

type CmdExecutor interface {
	Execute(args ...string) (out string, err error)
	ExecuteAndStreamOutput(outputHandler OutputHandler, args ...string) error
}

type ExecuteCliErr

type ExecuteCliErr struct {
	Err error
	Cmd string
}

type OutputHandler

type OutputHandler func(line string)

OutputHandler is a function type that processes lines of output

type UnableToStartErr

type UnableToStartErr struct {
	Err error
	Cmd string
}

func (UnableToStartErr) Error

func (u UnableToStartErr) Error() string

Jump to

Keyboard shortcuts

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