Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCrankHank committed Sep 24, 2016
1 parent ce3c0c3 commit b925628
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/ConsoleAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,10 @@ public function bin($bin, $escape = true)
* @param $param string
* @param $hidden boolean
* @param $escape boolean
* @param $delimiter string
*
* @return $this
*/
public function param($param, $hidden = false, $escape = true, $delimiter = ' ')
public function param($param, $hidden = false, $escape = true)
{
if ($escape) {
// prevent multiple parameters from being
Expand All @@ -162,8 +161,7 @@ public function param($param, $hidden = false, $escape = true, $delimiter = ' ')

$this->params[] = [
'param' => $param,
'hidden' => $hidden,
'delimiter' => $delimiter,
'hidden' => $hidden
];

return $this;
Expand All @@ -184,7 +182,7 @@ public function exec(Closure $live = null)
}

if (! is_null($this->pre)) {
call_user_func($this->pre, $this->bin);
call_user_func($this->pre, $this->getCommand());
}

$this->buildCommand();
Expand All @@ -196,7 +194,7 @@ public function exec(Closure $live = null)
$this->end = time();

if (! is_null($this->post)) {
call_user_func_array($this->post, [$this->bin, $this->getExitStatus(), $this->start, $this->end, $this->getDuration()]);
call_user_func_array($this->post, [$this->getCommand(), $this->getExitStatus(), $this->start, $this->end, $this->getDuration()]);
}
}

Expand Down Expand Up @@ -311,6 +309,9 @@ public function getCommand()
return $this->buildCommandWithoutHiddenParams();
}

/**
* Build the command for execution.
*/
private function buildCommand()
{
// prepend sudo if enabled
Expand All @@ -321,10 +322,15 @@ private function buildCommand()
}

foreach ($this->params as $param) {
$this->command .= ' ' . $param['param'] . $param['delimiter'];
$this->command .= ' ' . $param['param'];
}
}

/**
* Build the command without hidden params.
*
* @return string
*/
private function buildCommandWithoutHiddenParams()
{
// prepend sudo if enabled
Expand All @@ -336,9 +342,9 @@ private function buildCommandWithoutHiddenParams()

foreach ($this->params as $param) {
if ($param['hidden']) {
$command .= ' hidden' . $param['delimiter'];
$command .= ' hidden';
} else {
$command .= ' ' . $param['param'] . $param['delimiter'];
$command .= ' ' . $param['param'];
}
}

Expand Down

0 comments on commit b925628

Please sign in to comment.