]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Parse "--help" correctly in `arc`
authorepriestley <git@epriestley.com>
Thu, 22 Nov 2012 16:36:28 +0000 (08:36 -0800)
committerepriestley <git@epriestley.com>
Thu, 22 Nov 2012 16:36:28 +0000 (08:36 -0800)
Summary:
We delegate parsing to `PhutilArgumentParser` but then skip the parts of the code which do something with this flag.

In particular, `arc --help list` just runs `arc list`.

See https://github.com/facebook/arcanist/issues/58

Test Plan: Ran `arc --help`, `arc list --help`, `arc --help list`, `arc --help help --help`. Got expected help in all cases.

Reviewers: vrana, chad, btrahan

Reviewed By: chad

CC: aran
Differential Revision: https://secure.phabricator.com/D4023

scripts/arcanist.php

index 01a3a0e15eec1737a3d2006caeda738f3247d317..e42f93e636bae9374483a7eeba0025f925a2e7ab 100755 (executable)
@@ -41,6 +41,7 @@ $force_conduit = $args->getArg('conduit-uri');
 $force_conduit_version = $args->getArg('conduit-version');
 $conduit_timeout = $args->getArg('conduit-timeout');
 $load = $args->getArg('load-phutil-library');
+$help = $args->getArg('help');
 
 $argv = $args->getUnconsumedArgumentVector();
 $args = array_values($argv);
@@ -59,7 +60,13 @@ try {
     phutil_get_library_root('arcanist'));
 
   if (!$args) {
-    throw new ArcanistUsageException("No command provided. Try 'arc help'.");
+    if ($help) {
+      $args = array('help');
+    } else {
+      throw new ArcanistUsageException("No command provided. Try 'arc help'.");
+    }
+  } else if ($help) {
+    array_unshift($args, 'help');
   }
 
   $global_config = ArcanistBaseWorkflow::readGlobalArcConfig();