Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistWorkflow.php
| Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | final public function setConfigurationSourceList( | ||||
| $this->configurationSourceList = $list; | $this->configurationSourceList = $list; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| final public function getConfigurationSourceList() { | final public function getConfigurationSourceList() { | ||||
| return $this->configurationSourceList; | return $this->configurationSourceList; | ||||
| } | } | ||||
| public function newPhutilWorkflow() { | |||||
| $arguments = $this->getWorkflowArguments(); | |||||
| assert_instances_of($arguments, 'ArcanistWorkflowArgument'); | |||||
| $specs = mpull($arguments, 'getPhutilSpecification'); | |||||
| $phutil_workflow = id(new ArcanistPhutilWorkflow()) | |||||
| ->setName($this->getWorkflowName()) | |||||
| ->setWorkflow($this) | |||||
| ->setArguments($specs); | |||||
| $information = $this->getWorkflowInformation(); | |||||
| if ($information) { | |||||
| $examples = $information->getExamples(); | |||||
| if ($examples) { | |||||
| $examples = implode("\n", $examples); | |||||
| $phutil_workflow->setExamples($examples); | |||||
| } | |||||
| $help = $information->getHelp(); | |||||
| if (strlen($help)) { | |||||
| // Unwrap linebreaks in the help text so we don't get weird formatting. | |||||
| $help = preg_replace("/(?<=\S)\n(?=\S)/", ' ', $help); | |||||
| $phutil_workflow->setHelp($help); | |||||
| } | |||||
| } | |||||
| return $phutil_workflow; | |||||
| } | |||||
| final protected function newWorkflowArgument($key) { | |||||
| return id(new ArcanistWorkflowArgument()) | |||||
| ->setKey($key); | |||||
| } | |||||
| final protected function newWorkflowInformation() { | |||||
| return new ArcanistWorkflowInformation(); | |||||
| } | |||||
| final public function executeWorkflow(PhutilArgumentParser $args) { | |||||
| $runtime = $this->getRuntime(); | |||||
| $this->arguments = $args; | |||||
| $caught = null; | |||||
| $runtime->pushWorkflow($this); | |||||
| try { | |||||
| $err = $this->runWorkflow($args); | |||||
| } catch (Exception $ex) { | |||||
| $caught = $ex; | |||||
| } | |||||
| try { | |||||
| $this->runWorkflowCleanup(); | |||||
| } catch (Exception $ex) { | |||||
| phlog($ex); | |||||
| } | |||||
| $runtime->popWorkflow(); | |||||
| if ($caught) { | |||||
| throw $caught; | |||||
| } | |||||
| return $err; | |||||
| } | |||||
| final protected function getLogEngine() { | |||||
| return $this->getRuntime()->getLogEngine(); | |||||
| } | |||||
| protected function runWorkflowCleanup() { | |||||
| // TOOLSETS: Do we need this? | |||||
| return; | |||||
| } | |||||
| public function __construct() {} | public function __construct() {} | ||||
| public function run() { | public function run() { | ||||
| throw new PhutilMethodNotImplementedException(); | throw new PhutilMethodNotImplementedException(); | ||||
| } | } | ||||
| /** | /** | ||||
| * Finalizes any cleanup operations that need to occur regardless of | * Finalizes any cleanup operations that need to occur regardless of | ||||
| ▲ Show 20 Lines • Show All 531 Lines • ▼ Show 20 Lines | final public function buildChildWorkflow($command, array $argv) { | ||||
| $workflow->setArcanistConfiguration($arc_config); | $workflow->setArcanistConfiguration($arc_config); | ||||
| $workflow->parseArguments(array_values($argv)); | $workflow->parseArguments(array_values($argv)); | ||||
| return $workflow; | return $workflow; | ||||
| } | } | ||||
| final public function getArgument($key, $default = null) { | final public function getArgument($key, $default = null) { | ||||
| // TOOLSETS: Remove this legacy code. | |||||
| if (is_array($this->arguments)) { | |||||
| return idx($this->arguments, $key, $default); | return idx($this->arguments, $key, $default); | ||||
| } | } | ||||
| return $this->arguments->getArg($key); | |||||
| } | |||||
| final public function getPassedArguments() { | final public function getPassedArguments() { | ||||
| return $this->passedArguments; | return $this->passedArguments; | ||||
| } | } | ||||
| final public function getCompleteArgumentSpecification() { | final public function getCompleteArgumentSpecification() { | ||||
| $spec = $this->getArguments(); | $spec = $this->getArguments(); | ||||
| $arc_config = $this->getArcanistConfiguration(); | $arc_config = $this->getArcanistConfiguration(); | ||||
| $command = $this->getCommand(); | $command = $this->getCommand(); | ||||
| ▲ Show 20 Lines • Show All 1,514 Lines • Show Last 20 Lines | |||||