1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-25 08:12:40 +01:00

Crudely bridge legacy workflows into "arc help"

Summary:
Ref T13490. One of the biggest issues users are hitting in modern "arc" is that workflows don't appear in "arc help" until they're updated.

Since there's still some work to do and gluing them in isn't terribly difficult, at least get things connected for now.

Test Plan: Ran "arc help", "arc help diff".

Maniphest Tasks: T13490

Differential Revision: https://secure.phabricator.com/D21101
This commit is contained in:
epriestley 2020-04-13 11:37:48 -07:00
parent 196f8f54ce
commit c8dd2a3753
5 changed files with 116 additions and 3 deletions

View file

@ -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 )------------------------------------------------------- */

View file

@ -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(<<<EOHELP
@ -28,6 +39,45 @@ EOHELP
public function execute(PhutilArgumentParser $args) {
$with = $args->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 {

View file

@ -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;
}
}

View file

@ -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) {

View file

@ -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);