Skip to content

Commit 89350d9

Browse files
capirSteveEdson
authored andcommitted
add support for parameters (#11)
* add support for parameters * use array values to prevent key value arrays breaking the formatting
1 parent 11fbc00 commit 89350d9

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/SteveEdson/BitBar.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class BitBarLine {
2424
protected $length;
2525
protected $terminal;
2626
protected $bash;
27+
protected $params = [];
2728
protected $dropdown;
2829
protected $image;
2930
protected $imageIsTemplate = false;
@@ -120,13 +121,17 @@ public function setTerminal($boolean) {
120121
$this->terminal = (boolean) $boolean;
121122
return $this;
122123
}
123-
124+
124125
/**
125-
* @param mixed text
126+
* @param string text
127+
* @param array $params
128+
*
126129
* @return $this
127130
*/
128-
public function setBash($text) {
129-
$this->bash = $text;
131+
public function setBash( $text, array $params = [] )
132+
{
133+
$this->bash = $text;
134+
$this->params = $params;
130135
return $this;
131136
}
132137

@@ -280,7 +285,10 @@ public function format() {
280285
$this->usedPipe = true;
281286
}
282287

283-
$string .= ' bash=' . $this->bash;
288+
$string .= sprintf(' bash="%s"', $this->bash);
289+
290+
foreach(array_values($this->params) as $k => $param)
291+
$string .= sprintf(' param%s="%s"', ++$k, $param);
284292
}
285293

286294
if ($this->refresh) {

0 commit comments

Comments
 (0)