From 89350d9ea064eb4902261b7cb9c3f7fa627e0f8f Mon Sep 17 00:00:00 2001 From: Catalin Date: Tue, 19 Jun 2018 14:51:18 +0300 Subject: [PATCH] add support for parameters (#11) * add support for parameters * use array values to prevent key value arrays breaking the formatting --- src/SteveEdson/BitBar.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/SteveEdson/BitBar.php b/src/SteveEdson/BitBar.php index c3de14f..f46547a 100644 --- a/src/SteveEdson/BitBar.php +++ b/src/SteveEdson/BitBar.php @@ -24,6 +24,7 @@ class BitBarLine { protected $length; protected $terminal; protected $bash; + protected $params = []; protected $dropdown; protected $image; protected $imageIsTemplate = false; @@ -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; } @@ -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) {