command

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 8 Imported by: 11

Documentation

Overview

Package command provides support for addons to executing (CLI) commands.

Index

Constants

View Source
const (
	// Disabled reports: NOTHING.
	Disabled = -2
	// Error reports: error.
	Error = -1
	// Default reports: error, started, succeeded.
	Default = 0
	// LiveOutput reports: error, started, succeeded, output (live).
	LiveOutput = 1
)

Verbosity.

View Source
const (
	// Backoff rate increment.
	Backoff = time.Millisecond * 100
	// MaxBackoff max backoff.
	MaxBackoff = 10 * Backoff
	// MinBackoff minimum backoff.
	MinBackoff = Backoff
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Options  Options
	Path     string
	Dir      string
	Reporter Reporter
	Writer   Writer
}

Command execution.

func New added in v0.3.0

func New(path string) (cmd *Command)

New returns a command.

func (*Command) Output

func (r *Command) Output() (b []byte)

Output returns the command output.

func (*Command) Run

func (r *Command) Run() (err error)

Run executes the command. The command and output are both reported in task Report.Activity.

func (*Command) RunSilent

func (r *Command) RunSilent() (err error)

RunSilent executes the command. On error: The command (without arguments) and output are reported in task Report.Activity

func (*Command) RunWith

func (r *Command) RunWith(ctx context.Context) (err error)

RunWith executes the command with context. The command and output are both reported in task Report.Activity.

type Options

type Options []string

Options are CLI options.

func (*Options) Add

func (a *Options) Add(option string, s ...string)

Add option.

func (*Options) Addf

func (a *Options) Addf(option string, x ...interface{})

Addf option.

type Reporter added in v0.3.0

type Reporter struct {
	Verbosity int
	// contains filtered or unexported fields
}

Reporter activity reporter.

func (*Reporter) Error added in v0.3.0

func (r *Reporter) Error(path string, err error, output []byte)

Error reports command failed in task Report.Activity.

func (*Reporter) Output added in v0.3.0

func (r *Reporter) Output(buffer []byte) (reported int)

Output reports command output.

func (*Reporter) Run added in v0.3.0

func (r *Reporter) Run(path string, options Options)

Run reports command started in task Report.Activity.

func (*Reporter) Succeeded added in v0.3.0

func (r *Reporter) Succeeded(path string, output []byte)

Succeeded reports command succeeded in task Report.Activity.

type Writer added in v0.3.0

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

Writer records command output.

func (*Writer) End added in v0.3.0

func (w *Writer) End()

End of writing.

func (*Writer) Write added in v0.3.0

func (w *Writer) Write(p []byte) (n int, err error)

Write command output.

Jump to

Keyboard shortcuts

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