Documentation
¶
Overview ¶
Package local executes commands and transfers files on the machine the program is running on. It is the reference invoke.Environment: every behavior it implements is pinned by the invoketest contract suite.
Windows is not a supported execution target this cycle; the package compiles there, but New returns an error wrapping invoke.ErrNotSupported.
A command asked for a terminal gets a real one: its own session with a controlling terminal, both output streams merged onto it, and the dimensions the caller requested.
Index ¶
- type Environment
- func (e *Environment) Capabilities() invoke.Capabilities
- func (e *Environment) Close() error
- func (e *Environment) Download(ctx context.Context, remotePath, localPath string, ...) error
- func (e *Environment) LookPath(ctx context.Context, name string) (string, error)
- func (e *Environment) OS() invoke.TargetOS
- func (e *Environment) Start(ctx context.Context, cmd invoke.Command, stdio invoke.IO) (invoke.Process, error)
- func (e *Environment) Upload(ctx context.Context, localPath, remotePath string, ...) error
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment runs commands on the local machine.
func New ¶
func New(opts ...Option) (*Environment, error)
New returns an Environment for the local machine.
func (*Environment) Capabilities ¶
func (e *Environment) Capabilities() invoke.Capabilities
Capabilities reports the local target's optional features. All of them are available: signal delivery, symlink-preserving transfers, and terminal allocation.
func (*Environment) Close ¶
func (e *Environment) Close() error
Close marks the environment closed and terminates any processes still running. It is idempotent.
func (*Environment) Download ¶
func (e *Environment) Download(ctx context.Context, remotePath, localPath string, opts ...invoke.TransferOption) error
Download copies a file or directory tree between local paths, with the same semantics as Upload.
func (*Environment) OS ¶
func (e *Environment) OS() invoke.TargetOS
OS reports the local operating system.
func (*Environment) Start ¶
func (e *Environment) Start(ctx context.Context, cmd invoke.Command, stdio invoke.IO) (invoke.Process, error)
Start launches cmd on the local machine.
func (*Environment) Upload ¶
func (e *Environment) Upload(ctx context.Context, localPath, remotePath string, opts ...invoke.TransferOption) error
Upload copies a file or directory tree between local paths. On this provider Upload and Download are the same operation; both exist so the Environment contract holds regardless of target.
type Option ¶ added in v0.3.0
type Option func(*config)
Option configures a local Environment.
func WithTerminationGrace ¶ added in v0.3.0
WithTerminationGrace sets how long a command that has been canceled or closed is given to finish writing before it is abandoned.
Terminating a command does not necessarily close its output: a descendant it left behind can hold the pipes open, and waiting on them forever would hang the caller. Once the grace period passes the command is abandoned and Wait returns, which is why the default is short.
A command that flushes something substantial when told to stop needs longer than the default two seconds, or its last output is lost. A caller that would rather never wait can set a shorter one.