cmd

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearDirectory

func ClearDirectory(ctx context.Context, executor Executor, path string) error

func Command

func Command(name string, arg ...string) *exec.Cmd

Command creates a shell command, almost like a standard `exec.Command()`, except it doesn't try to resolve an absolute path of `name`. This allows to work with local commands as well as with SSH.

func CreateDirectory

func CreateDirectory(ctx context.Context, executor Executor, path string) error

func DirectoryExists

func DirectoryExists(ctx context.Context, executor Executor, path string) bool

DirectoryExists checks if a directory exists

func EnsureDirectoryIsEmpty

func EnsureDirectoryIsEmpty(ctx context.Context, executor Executor, path string) error

EnsureDirectoryIsEmpty checks if the directory exists and is empty. Removes directory contents, if it exists. Creates a directory, if it doesn't exist.

func ExecutableFileExists

func ExecutableFileExists(ctx context.Context, executor Executor, file string) error

ExecutableFileExists checks if an executable file exists

func RemoveDirectory

func RemoveDirectory(ctx context.Context, executor Executor, path string) error

Types

type Executor

type Executor interface {
	Execute(ctx context.Context, cmd *exec.Cmd) ([]byte, error)
	Run(ctx context.Context, cmd *exec.Cmd) error
	ReadFile(ctx context.Context, path string) ([]byte, error)
	WriteFile(ctx context.Context, path string, data []byte) error
}

Executor is a shell command executor interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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