diff --git a/src/parser/argument/PhutilArgumentParser.php b/src/parser/argument/PhutilArgumentParser.php index 8d0e9ca5..81f86cde 100644 --- a/src/parser/argument/PhutilArgumentParser.php +++ b/src/parser/argument/PhutilArgumentParser.php @@ -627,6 +627,16 @@ final class PhutilArgumentParser extends Phobject { return $this; } + public function setWorkflows($workflows) { + $workflows = mpull($workflows, null, 'getName'); + $this->workflows = $workflows; + return $this; + } + + public function getWorkflows() { + return $this->workflows; + } + /* -( Command Help )------------------------------------------------------- */ diff --git a/src/parser/argument/workflow/PhutilHelpArgumentWorkflow.php b/src/parser/argument/workflow/PhutilHelpArgumentWorkflow.php index d464e1cf..7e455fc7 100644 --- a/src/parser/argument/workflow/PhutilHelpArgumentWorkflow.php +++ b/src/parser/argument/workflow/PhutilHelpArgumentWorkflow.php @@ -2,6 +2,17 @@ final class PhutilHelpArgumentWorkflow extends PhutilArgumentWorkflow { + private $runtime; + + public function setRuntime($runtime) { + $this->runtime = $runtime; + return $this; + } + + public function getRuntime() { + return $this->runtime; + } + protected function didConstruct() { $this->setName('help'); $this->setExamples(<<getArg('help-with-what'); + $runtime = $this->getRuntime(); + $toolset = $runtime->getToolset(); + if ($toolset->getToolsetKey() === 'arc') { + $workflows = $args->getWorkflows(); + + $legacy = array(); + + $legacy[] = new ArcanistCloseRevisionWorkflow(); + $legacy[] = new ArcanistCommitWorkflow(); + $legacy[] = new ArcanistCoverWorkflow(); + $legacy[] = new ArcanistDiffWorkflow(); + $legacy[] = new ArcanistExportWorkflow(); + $legacy[] = new ArcanistGetConfigWorkflow(); + $legacy[] = new ArcanistSetConfigWorkflow(); + $legacy[] = new ArcanistInstallCertificateWorkflow(); + $legacy[] = new ArcanistLandWorkflow(); + $legacy[] = new ArcanistLintersWorkflow(); + $legacy[] = new ArcanistLintWorkflow(); + $legacy[] = new ArcanistListWorkflow(); + $legacy[] = new ArcanistPatchWorkflow(); + $legacy[] = new ArcanistPasteWorkflow(); + $legacy[] = new ArcanistTasksWorkflow(); + $legacy[] = new ArcanistTodoWorkflow(); + $legacy[] = new ArcanistUnitWorkflow(); + $legacy[] = new ArcanistWhichWorkflow(); + + foreach ($legacy as $workflow) { + // If this workflow has been updated but not removed from the list + // above yet, just skip it. + if ($workflow instanceof ArcanistArcWorkflow) { + continue; + } + + $workflows[] = $workflow->newLegacyPhutilWorkflow(); + } + + $args->setWorkflows($workflows); + } + if (!$with) { $args->printHelpAndExit(); } else { diff --git a/src/runtime/ArcanistRuntime.php b/src/runtime/ArcanistRuntime.php index 79d665b1..bed9e5cc 100644 --- a/src/runtime/ArcanistRuntime.php +++ b/src/runtime/ArcanistRuntime.php @@ -9,6 +9,7 @@ final class ArcanistRuntime { private $stack = array(); private $viewer; + private $toolset; private $hardpointEngine; private $symbolEngine; private $conduitEngine; @@ -107,6 +108,7 @@ final class ArcanistRuntime { $config->validateConfiguration($this); $toolset = $this->newToolset($argv); + $this->setToolset($toolset); $args->parsePartial($toolset->getToolsetArguments()); @@ -118,13 +120,13 @@ final class ArcanistRuntime { $phutil_workflows = array(); foreach ($workflows as $key => $workflow) { - $phutil_workflows[$key] = $workflow->newPhutilWorkflow(); - $workflow ->setRuntime($this) ->setConfigurationEngine($config_engine) ->setConfigurationSourceList($config) ->setConduitEngine($conduit_engine); + + $phutil_workflows[$key] = $workflow->newPhutilWorkflow(); } @@ -858,4 +860,13 @@ final class ArcanistRuntime { return $this->conduitEngine; } + public function setToolset($toolset) { + $this->toolset = $toolset; + return $this; + } + + public function getToolset() { + return $this->toolset; + } + } diff --git a/src/toolset/workflow/ArcanistHelpWorkflow.php b/src/toolset/workflow/ArcanistHelpWorkflow.php index e7ac38fc..8cda9ab2 100644 --- a/src/toolset/workflow/ArcanistHelpWorkflow.php +++ b/src/toolset/workflow/ArcanistHelpWorkflow.php @@ -8,7 +8,8 @@ final class ArcanistHelpWorkflow } public function newPhutilWorkflow() { - return new PhutilHelpArgumentWorkflow(); + return id(new PhutilHelpArgumentWorkflow()) + ->setRuntime($this->getRuntime()); } public function supportsToolset(ArcanistToolset $toolset) { diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php index 6e7dec14..0098990b 100644 --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -166,6 +166,47 @@ abstract class ArcanistWorkflow extends Phobject { return $phutil_workflow; } + final public function newLegacyPhutilWorkflow() { + $phutil_workflow = id(new ArcanistPhutilWorkflow()) + ->setName($this->getWorkflowName()); + + $arguments = $this->getArguments(); + + $specs = array(); + foreach ($arguments as $key => $argument) { + if ($key == '*') { + $key = $argument; + $argument = array( + 'wildcard' => true, + ); + } + + unset($argument['paramtype']); + unset($argument['supports']); + unset($argument['nosupport']); + unset($argument['passthru']); + unset($argument['conflict']); + + $spec = array( + 'name' => $key, + ) + $argument; + + $specs[] = $spec; + } + + $phutil_workflow->setArguments($specs); + + $synopses = $this->getCommandSynopses(); + $phutil_workflow->setSynopsis($synopses); + + $help = $this->getCommandHelp(); + if (strlen($help)) { + $phutil_workflow->setHelp($help); + } + + return $phutil_workflow; + } + final protected function newWorkflowArgument($key) { return id(new ArcanistWorkflowArgument()) ->setKey($key);