Skip to content

Commit

Permalink
+ binary exec to return exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Feb 28, 2016
1 parent d9d9c69 commit 0378e33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/base/Binary.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ public function passthru($args = [])
/**
* Prepares and runs with exec, returns stdout array.
* @param string|array $args
* @return array stdout
* @param bool $returnExitCode, default false
* @return array|int stdout or exit code
*/
public function exec($args = [])
public function exec($args = [], $returnExitCode = false)
{
exec($this->prepareCommand($args), $array);
exec($this->prepareCommand($args), $array, $exitcode);

return $array;
return $returnExitCode ? $exitcode : $array;
}

public function prepareCommand($args)
Expand Down
7 changes: 4 additions & 3 deletions src/controllers/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,12 @@ public function passthru($name, $args = '')
* Runs given binary with given arguments. Returns stdout array.
* @param string $name
* @param string $args
* @return array stdout
* @param bool $returnExitCode, default false
* @return array|int stdout or exitcode
*/
public function exec($name, $args = '')
public function exec($name, $args = '', $returnExitCode = false)
{
return $this->takeGoal('binaries')->exec($name, $args);
return $this->takeGoal('binaries')->exec($name, $args, $returnExitCode);
}

public function takeGoal($id)
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/BinariesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public function passthru($name, $args = [])
* @param string $args
* @return array stdout
*/
public function exec($name, $args = [])
public function exec($name, $args = '', $returnExitCode = false)
{
return $this->get($name)->exec($args);
return $this->get($name)->exec($args, $returnExitCode);
}
}

0 comments on commit 0378e33

Please sign in to comment.