Skip to content

Commit

Permalink
add support for parameters (#11)
Browse files Browse the repository at this point in the history
* add support for parameters

* use array values to prevent key value arrays breaking the formatting
  • Loading branch information
capir authored and SteveEdson committed Jun 19, 2018
1 parent 11fbc00 commit 89350d9
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/SteveEdson/BitBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class BitBarLine {
protected $length;
protected $terminal;
protected $bash;
protected $params = [];
protected $dropdown;
protected $image;
protected $imageIsTemplate = false;
Expand Down Expand Up @@ -120,13 +121,17 @@ public function setTerminal($boolean) {
$this->terminal = (boolean) $boolean;
return $this;
}

/**
* @param mixed text
* @param string text
* @param array $params
*
* @return $this
*/
public function setBash($text) {
$this->bash = $text;
public function setBash( $text, array $params = [] )
{
$this->bash = $text;
$this->params = $params;
return $this;
}

Expand Down Expand Up @@ -280,7 +285,10 @@ public function format() {
$this->usedPipe = true;
}

$string .= ' bash=' . $this->bash;
$string .= sprintf(' bash="%s"', $this->bash);

foreach(array_values($this->params) as $k => $param)
$string .= sprintf(' param%s="%s"', ++$k, $param);
}

if ($this->refresh) {
Expand Down

0 comments on commit 89350d9

Please sign in to comment.