thirdparty

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImplemented = errors.New("thirdparty: not implemented")

ErrNotImplemented is the error returned if a method is not implemented.

Functions

func Register

func Register(name CommandName, factory Factory)

Register registers a command factory by name.

The command MUST have a name: lower case and one word.

Types

type Command

type Command interface {
	// Name returns the third-party command name.
	Name() CommandName

	// Run invokes the command with optional arguments. An error is
	// returned if the command fails, nil otherwise.
	Run(ctx context.Context, args ...string) error

	// RunWithStdin invokes the command with stdin override and optional arguments. An error is
	// returned if the command fails, nil otherwise.
	RunWithStdin(ctx context.Context, stdin io.Reader, args ...string) error
}

Command defines the interface that should be implemented by a third-party command.

func GetInstance

func GetInstance(name CommandName, options ...CommandOption) (Command, error)

GetInstance returns an instance of command by name.

type CommandName

type CommandName string

CommandName represents the name of a third-party command.

type CommandOption

type CommandOption func(*CommandOptions)

CommandOption allows specifying various settings configurable by a command.

func WithPath added in v0.0.16

func WithPath(path string) CommandOption

WithPath specifies the path of the command to run from.

func WithStdio

func WithStdio(in io.Reader, out, err io.Writer) CommandOption

WithStdio specifies the standard input, output and error files data streams.

type CommandOptions

type CommandOptions struct {
	// Stdin, Stdout, and Stderr represent the respective data streams that the
	// command may act upon.
	In       io.Reader
	Out, Err io.Writer

	// Path is the path of the command to run. If Path is relative, it is
	// evaluated relative to Dir.
	Path string
}

type Factory

type Factory func(options *CommandOptions) (Command, error)

Factory is a function that returns a command interface. An error is returned if the command fails to initialize, nil otherwise.

func GetFactory

func GetFactory(name CommandName) (Factory, error)

GetFactory returns a factory of command by name.

Directories

Path Synopsis
aws

Jump to

Keyboard shortcuts

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