cmd

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLI

type CLI struct {
	Binary string
	Path   string
	Args   []string
	Stderr io.Writer
	Stdout io.Writer
	Logger *log.Entry
	// contains filtered or unexported fields
}

A CLI defines the structure that will be used for the Cmd interface. It's composed by:

  • Binary: The name of the binary that will be executed.
  • Path: The path of the binary that will be executed.
  • Args: A list of strings that will be passed as arguments to the command executed.
  • Stderr: An interface that will be used to write the stderr.
  • Stdout: An interface that will be used to write the stdout.
  • Logger: The apex log entry.
  • stderrString: The stderr in a string format, used only internally.

func (*CLI) GetStderr

func (c *CLI) GetStderr() string

GetStderr returns the stderr in string format.

func (*CLI) Initialize

func (c *CLI) Initialize(logger *log.Entry, args []string) error

Initialize sets the struct attributes necessary to execute the command.

func (*CLI) Run

func (c *CLI) Run() error

Run executes the command. If debug is set, the stderr and stdout of the executed command will be actually redirected to the terminals stderr and stdout. If not, it will be written in a variable used to further analysis of the errors.

type Cmd

type Cmd interface {
	Initialize(*log.Entry, []string) error
	Run() error
	GetStderr() string
}

A Cmd defines an interface to execute some operations with os/exec. Is composed by:

  • Initialize: It will do what's necessary to be able to run a command, like set the stdout or the logger.
  • Run: It will run the command, duh.
  • GetStderr: It will return the stderr of the command. It's usually used to determinate if an error is really an error in particle.

Jump to

Keyboard shortcuts

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