From: Joshua Spence Date: Thu, 22 Jan 2015 20:07:37 +0000 (+1100) Subject: Improve handling of options for `arc` workflows X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=937861ce58c93fbeebe417800f1caa67b00b3ef0;p=arcanist.git Improve handling of options for `arc` workflows Summary: Allow `--severity=warning` to mean the same as `--severity warning`. Longer term, we should convert this code to use `PhutilArgumentParser`, although it doesn't seem that `PhutilArgumentParser` support British spelling ;) Test Plan: Ran `arc lint --severity=warning`. Also `var_dump`ed `$args` to make sure it looked reasonable. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11464 --- diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php index 194d9211..8f4dc3aa 100644 --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -661,7 +661,8 @@ abstract class ArcanistWorkflow extends Phobject { } $more = array(); - for ($ii = 0; $ii < count($args); $ii++) { + $size = count($args); + for ($ii = 0; $ii < $size; $ii++) { $arg = $args[$ii]; $arg_name = null; $arg_key = null; @@ -672,6 +673,14 @@ abstract class ArcanistWorkflow extends Phobject { break; } else if (!strncmp($arg, '--', 2)) { $arg_key = substr($arg, 2); + $parts = explode('=', $arg_key, 2); + if (count($parts) == 2) { + list($arg_key, $val) = $parts; + + array_splice($args, $ii, 1, array('--'.$arg_key, $val)); + $size++; + } + if (!array_key_exists($arg_key, $spec)) { $corrected = ArcanistConfiguration::correctArgumentSpelling( $arg_key, @@ -706,7 +715,7 @@ abstract class ArcanistWorkflow extends Phobject { if (empty($options['param'])) { $dict[$arg_key] = true; } else { - if ($ii == count($args) - 1) { + if ($ii == $size - 1) { throw new ArcanistUsageException(pht( "Option '%s' requires a parameter.", $arg));