Skip to content

Commit

Permalink
Add support for command line arguments in the format --arg=<value>
Browse files Browse the repository at this point in the history
refs #8472
  • Loading branch information
Al2Klimov committed Jun 10, 2015
1 parent e764bfb commit 392047b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion library/Icinga/Cli/Params.php
Expand Up @@ -47,7 +47,12 @@ public function __construct($argv)
$noOptionFlag = true;
} elseif (!$noOptionFlag && substr($argv[$i], 0, 2) === '--') {
$key = substr($argv[$i], 2);
if (! isset($argv[$i + 1]) || substr($argv[$i + 1], 0, 2) === '--') {
$matches = array();
if (1 === preg_match(
'/(?<!.)([^=]+)=(.*)(?!.)/ms', $key, $matches
)) {
$this->params[$matches[1]] = $matches[2];
} elseif (! isset($argv[$i + 1]) || substr($argv[$i + 1], 0, 2) === '--') {
$this->params[$key] = true;
} elseif (array_key_exists($key, $this->params)) {
if (!is_array($this->params[$key])) {
Expand Down

0 comments on commit 392047b

Please sign in to comment.