trait ExecTrait (View source)

Class ExecTrait

Properties

protected bool $background
protected null|int $timeout
protected null|int $idleTimeout
protected null|array $env
protected Process $process
protected resource|string $input
protected bool $interactive
protected bool $isPrinted
protected bool $isMetadataPrinted
protected string $workingDirectory

Methods

string
getCommandDescription()

No description

startTimer()

No description

stopTimer()

No description

null|float
getExecutionTime()

No description

bool
hideTaskProgress()

No description

showTaskProgress(bool $inProgress)

No description

printTaskInfo(string $text, null|array $context = null)

No description

bool
verbosityMeetsThreshold()

No description

writeMessage(string $message)

No description

$this
detectInteractive()

Sets $this->interactive() based on posix_isatty().

$this
background(bool $arg = true)

Executes command in background mode (asynchronously)

$this
timeout(int $timeout)

Stop command if it runs longer then $timeout in seconds

$this
idleTimeout(int $timeout)

Stops command if it does not output something for a while

$this
env(string|array $env, bool|string $value = null)

Set a single environment variable, or multiple.

$this
envVars(array $env)

Sets the environment variables for the command

$this
setProcessInput(resource|string $input)

Pass an input to the process. Can be resource created with fopen() or string

$this
setInput(resource|string $input) deprecated

Pass an input to the process. Can be resource created with fopen() or string

$this
interactive(bool $interactive = true)

Attach tty to process for interactive input

bool
getPrinted()

Is command printing its output to screen

$this
dir(string $dir)

Changes working directory of command

$this
silent(bool $arg)

Shortcut for setting isPrinted() and isMetadataPrinted() to false.

$this
printed(bool $arg) deprecated

Should command output be printed

$this
printOutput(bool $arg)

Should command output be printed

$this
printMetadata(bool $arg)

Should command metadata be printed. I,e., command and timer.

execute(Process $process, callable $output_callback = null)

No description

stop()

No description

printAction(array $context = [])

No description

string
formatCommandDisplay(string $command)

No description

array
getResultData()

Gets the data array to be passed to Result().

Details

abstract string getCommandDescription()

No description

Return Value

string

abstract protected startTimer()

No description

abstract protected stopTimer()

No description

abstract protected null|float getExecutionTime()

No description

Return Value

null|float

See also

ProgressIndicatorAwareTrait
Timer

abstract protected bool hideTaskProgress()

No description

Return Value

bool

See also

TaskIO

abstract protected showTaskProgress(bool $inProgress)

No description

Parameters

bool $inProgress

See also

TaskIO

abstract protected printTaskInfo(string $text, null|array $context = null)

No description

Parameters

string $text
null|array $context

See also

TaskIO

abstract bool verbosityMeetsThreshold()

No description

Return Value

bool

See also

VerbosityThresholdTrait

abstract writeMessage(string $message)

No description

Parameters

string $message

See also

VerbosityThresholdTrait

$this detectInteractive()

Sets $this->interactive() based on posix_isatty().

Return Value

$this

$this background(bool $arg = true)

Executes command in background mode (asynchronously)

Parameters

bool $arg

Return Value

$this

$this timeout(int $timeout)

Stop command if it runs longer then $timeout in seconds

Parameters

int $timeout

Return Value

$this

$this idleTimeout(int $timeout)

Stops command if it does not output something for a while

Parameters

int $timeout

Return Value

$this

$this env(string|array $env, bool|string $value = null)

Set a single environment variable, or multiple.

Parameters

string|array $env
bool|string $value

Return Value

$this

$this envVars(array $env)

Sets the environment variables for the command

Parameters

array $env

Return Value

$this

$this setProcessInput(resource|string $input)

Pass an input to the process. Can be resource created with fopen() or string

Parameters

resource|string $input

Return Value

$this

$this setInput(resource|string $input) deprecated

deprecated

Pass an input to the process. Can be resource created with fopen() or string

Parameters

resource|string $input

Return Value

$this

$this interactive(bool $interactive = true)

Attach tty to process for interactive input

Parameters

bool $interactive

Return Value

$this

bool getPrinted()

Is command printing its output to screen

Return Value

bool

$this dir(string $dir)

Changes working directory of command

Parameters

string $dir

Return Value

$this

$this silent(bool $arg)

Shortcut for setting isPrinted() and isMetadataPrinted() to false.

Parameters

bool $arg

Return Value

$this

$this printed(bool $arg) deprecated

deprecated

Should command output be printed

Parameters

bool $arg

Return Value

$this

$this printOutput(bool $arg)

Should command output be printed

Parameters

bool $arg

Return Value

$this

$this printMetadata(bool $arg)

Should command metadata be printed. I,e., command and timer.

Parameters

bool $arg

Return Value

$this

protected ResultData execute(Process $process, callable $output_callback = null)

No description

Parameters

Process $process
callable $output_callback

Return Value

ResultData

protected stop()

No description

protected printAction(array $context = [])

No description

Parameters

array $context

protected string formatCommandDisplay(string $command)

No description

Parameters

string $command

Return Value

string

protected array getResultData()

Gets the data array to be passed to Result().

Return Value

array

The data array passed to Result().