]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Improve handling of options for `arc` workflows
authorJoshua Spence <josh@joshuaspence.com>
Thu, 22 Jan 2015 20:07:37 +0000 (07:07 +1100)
committerJoshua Spence <josh@joshuaspence.com>
Thu, 22 Jan 2015 20:07:37 +0000 (07:07 +1100)
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

src/workflow/ArcanistWorkflow.php

index 194d9211c27e29011d2f85b5b90e7b313542e6ab..8f4dc3aaec4e60ec37e6deb2c6327c02739a3fcd 100644 (file)
@@ -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));