ExecCommand
trait ExecCommand (View source)
This task is supposed to be executed as shell command.
You can specify working directory and if output is printed.
Traits
Class ExecTrait
Properties
protected bool | $background | from ExecTrait | |
protected null|int | $timeout | from ExecTrait | |
protected null|int | $idleTimeout | from ExecTrait | |
protected null|array | $env | from ExecTrait | |
protected Process | $process | from ExecTrait | |
protected resource|string | $input | from ExecTrait | |
protected bool | $interactive | from ExecTrait | |
protected bool | $isPrinted | from ExecTrait | |
protected bool | $isMetadataPrinted | from ExecTrait | |
protected string | $workingDirectory | from ExecTrait | |
protected TimeKeeper | $execTimer |
Methods
{@inheritdoc}
Executes command in background mode (asynchronously)
Stops command if it does not output something for a while
Set a single environment variable, or multiple.
Pass an input to the process. Can be resource created with fopen() or string
Pass an input to the process. Can be resource created with fopen() or string
Attach tty to process for interactive input
Shortcut for setting isPrinted() and isMetadataPrinted() to false.
Should command metadata be printed. I,e., command and timer.
No description
Look for a "{$cmd}.phar" in the current working directory; return a string to exec it if it is found. Otherwise, look for an executable command of the same name via findExecutable.
Return the best path to the executable program with the provided name. Favor vendor/bin in the current project. If not found there, use whatever is on the $PATH.
No description
Wrap Windows executables in 'call' per 7a88757d
No description
Details
protected
getCommandDescription()
{@inheritdoc}
abstract protected
startTimer()
No description
abstract protected
stopTimer()
No description
abstract protected null|float
getExecutionTime()
No description
abstract protected bool
hideTaskProgress()
No description
abstract protected
showTaskProgress(bool $inProgress)
No description
abstract protected
printTaskInfo(string $text, null|array $context = null)
No description
abstract bool
verbosityMeetsThreshold()
No description
abstract
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
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
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.
protected ResultData
execute(Process $process, callable $output_callback = null)
No description
protected
stop()
No description
protected
printAction(array $context = [])
No description
protected string
formatCommandDisplay(string $command)
No description
protected array
getResultData()
Gets the data array to be passed to Result().
protected TimeKeeper
getExecTimer()
No description
protected bool|string
findExecutablePhar(string $cmd)
Look for a "{$cmd}.phar" in the current working directory; return a string to exec it if it is found. Otherwise, look for an executable command of the same name via findExecutable.
protected bool|string
findExecutable(string $cmd)
Return the best path to the executable program with the provided name. Favor vendor/bin in the current project. If not found there, use whatever is on the $PATH.
protected bool|string
findProjectBin()
No description
protected string
useCallOnWindows(string $cmd)
Wrap Windows executables in 'call' per 7a88757d
protected Result
executeCommand(string $command)
No description