tools

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecTool added in v0.2.0

func ExecTool(ctx context.Context, t Tool) error

ExecTool is a helper for running a Tool. It creates an exec.Command with the provided context, connects stdout/stderr to the Tool buffers, and will reduce the process priority after starting if requested.

func ReduceProcessPriority added in v0.2.0

func ReduceProcessPriority(p *os.Process) error

ReduceProcessPriority is a multi-os helper for reducing the run priority of a process.

Types

type Check

type Check interface {
	Validate() error
}

Check is used to validate if conditions are met for executing a particular tool.

type Checks

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

Checks is a helper to run multiple Check in one go

func NewChecks

func NewChecks(checks ...Check) *Checks

func (*Checks) AddCheck

func (c *Checks) AddCheck(check Check)

AddCheck adds a Check to be validated later

func (*Checks) Run

func (c *Checks) Run() error

Run will run all added Check, and stop on the first error

type ExecutableCheck

type ExecutableCheck struct {
	// Executable is the name of the executable to find
	Executable string
}

ExecutableCheck is used to determine if a specific executable can be found in the PATH env variable

func (*ExecutableCheck) Validate

func (e *ExecutableCheck) Validate() error

Validate calls exec.LookPath to find the specified executable

type Tool added in v0.2.0

type Tool interface {
	// Do should execute the program
	Do() error

	// DoWithContext should execute the program under the provided context
	DoWithContext(context.Context) error

	// GetCommand should return the name of the binary to execute (ffmpeg, mkvmerge, etc)
	GetCommand() string

	// GetCommandArgs should return a list of arguments to pass to the command
	GetCommandArgs() []string

	// GetStdout should return the stdout output after the program is executed
	GetStdout() []byte

	// GetStderr should return the stderr output after the program is executed
	GetStderr() []byte

	// GetOutputBuffers returns buffers for writing stdout and stderr to.
	GetOutputBuffers() (io.Writer, io.Writer)

	// IsLowPriority returns if the process should be run at low priority
	IsLowPriority() bool
}

Tool is a wrapper for an executable program, responsible for generating all the command-line arguments needed to execute successfully.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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