Documentation
¶
Index ¶
- Variables
- type CLI
- type Env
- func (env *Env) CaptureOutput() (*bytes.Buffer, error)
- func (env *Env) Mount(dirFs fs.ReadDirFS, at string) error
- func (e *Env) MountDir(filePath string) error
- func (env *Env) PipeIn(r io.Reader) error
- func (env *Env) PipeInFile(fpath string) error
- func (env *Env) PipeInFiles(fPaths ...string) error
- func (env *Env) Spy(ch chan string) error
- type InitRunner
- type Initializer
- type PassthroughInit
- type Runner
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrOutputNotReadable = pear.Defer("output stream is not readable")
Functions ¶
This section is empty.
Types ¶
type CLI ¶
type CLI[T InitRunner] struct { Env Env App T // contains filtered or unexported fields }
A CLI is a command line interface. It runs an app against an environment
func NewCLI ¶ added in v0.7.0
func NewCLI[T InitRunner](env *Env, app T) *CLI[T]
func NewRealCli ¶
func NewRealCli[T InitRunner](exe T) CLI[T]
func NewTestCli ¶
func NewTestCli[T InitRunner](exe T, binaryName string) CLI[T]
func (CLI[T]) ErrStream ¶
ErrStream returns an io.Reader representing the stuff you put in StdErr.
This will not work in a real CLI because os.StdOut is not readable
type Env ¶
type Env struct {
InStream io.Reader
OutStream io.Writer
ErrStream io.Writer
Filesystem afero.IOFS
Randomness io.Reader
Args []string
Vars map[string]string
Exit func(int)
// contains filtered or unexported fields
}
Env is a computing environment.
func (*Env) Mount ¶
Mount mounts a subdirectory into an environment. Useful for testing. Probably dangerous otherwise
func (*Env) PipeInFile ¶
func (*Env) PipeInFiles ¶ added in v0.5.2
PipeInFiles pipes in files to the environment's stdin (InputStream)
type InitRunner ¶
type InitRunner interface {
Runner
Initializer
}
type Initializer ¶
An Initializer initializes itself in preparation of running. It can modify its Env
type PassthroughInit ¶
type PassthroughInit struct{}
PassthroughInit is an Initializer that does nothing
func (PassthroughInit) Init ¶
func (p PassthroughInit) Init(_ *Env) error
Click to show internal directories.
Click to hide internal directories.