Skip to content

Commit

Permalink
Add setProcessInput and deprecate setInput. (consolidation#1034)
Browse files Browse the repository at this point in the history
* Add setProcessInput and deprecate setInput.

* Set interactive to false when a process input is provided.

* Keep same behaviour for the deprecated method.
  • Loading branch information
rodrigoaguilera authored May 20, 2021
1 parent c925d29 commit 85efe28
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/tasks/Base.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if ($this->taskExec('phpunit .')->run()->wasSuccessful()) {

* `simulate($context)` {@inheritdoc}
* `setOutput($output)` Sets the Console Output.
* `setProcessInput($input)` Sets the input for the command. Similar to a pipe like `echo "input" | cat`.
* `dir($dir)` Changes working directory of command
* `arg($arg)` Pass argument to executable. Its value will be automatically escaped.
* `args($args)` Pass methods parameters as arguments to executable. Argument values
Expand Down Expand Up @@ -49,7 +50,7 @@ $this->taskExecStack()
* `executable($executable)` * `param string` $executable
* `exec($command)` * `param string|string[]|CommandInterface` $command
* `stopOnFail($stopOnFail = null)` * `param bool` $stopOnFail
* `result($result)`
* `result($result)`
* `setOutput($output)` Sets the Console Output.
* `dir($dir)` Changes working directory of command

Expand Down Expand Up @@ -94,7 +95,7 @@ $this->taskSymfonyCommand(new ModelGeneratorCommand())
```

* `arg($arg, $value)` * `param string` $arg
* `opt($option, $value = null)`
* `opt($option, $value = null)`
* `setOutput($output)` Sets the Console Output.


Expand Down
18 changes: 18 additions & 0 deletions src/Common/ExecTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,26 @@ public function envVars(array $env)
*
* @return $this
*/
public function setProcessInput($input)
{
$this->input = $input;
// A tty should not be allocated when the input is provided.
$this->interactive(false);
return $this;
}

/**
* Pass an input to the process. Can be resource created with fopen() or string
*
* @param resource|string $input
*
* @return $this
*
* @deprecated
*/
public function setInput($input)
{
trigger_error('setInput() is deprecated. Please use setProcessInput(().', E_USER_DEPRECATED);
$this->input = $input;
return $this;
}
Expand Down

0 comments on commit 85efe28

Please sign in to comment.