diff --git a/src/configuration/ArcanistConfiguration.php b/src/configuration/ArcanistConfiguration.php index 02f39566..be5c8921 100644 --- a/src/configuration/ArcanistConfiguration.php +++ b/src/configuration/ArcanistConfiguration.php @@ -45,53 +45,29 @@ class ArcanistConfiguration { $command = 'help'; } - if ($command == 'base') { - return null; - } - - $workflow_class = 'Arcanist'.ucfirst($command).'Workflow'; - $workflow_class = preg_replace_callback( - '/-([a-z])/', - array( - 'ArcanistConfiguration', - 'replaceClassnameHyphens', - ), - $workflow_class); - - $symbols = id(new PhutilSymbolLoader()) - ->setType('class') - ->setName($workflow_class) - ->setLibrary('arcanist') - ->selectAndLoadSymbols(); - - if (!$symbols) { - return null; - } - - return newv($workflow_class, array()); + return idx($this->buildAllWorkflows(), $command); } public function buildAllWorkflows() { $symbols = id(new PhutilSymbolLoader()) ->setType('class') ->setAncestorClass('ArcanistBaseWorkflow') - ->setLibrary('arcanist') ->selectAndLoadSymbols(); $workflows = array(); foreach ($symbols as $symbol) { $class = $symbol['name']; - $name = preg_replace('/^Arcanist(\w+)Workflow$/', '\1', $class); - $name[0] = strtolower($name[0]); - $name = preg_replace_callback( - '/[A-Z]/', - array( - 'ArcanistConfiguration', - 'replaceClassnameUppers', - ), - $name); - $name = strtolower($name); - $workflows[$name] = newv($class, array()); + $workflow = newv($class, array()); + $name = $workflow->getWorkflowName(); + + if (isset($workflows[$name])) { + $other = get_class($workflows[$name]); + throw new Exception( + "Workflows {$class} and {$other} both implement workflows named ". + "{$name}."); + } + + $workflows[$workflow->getWorkflowName()] = $workflow; } return $workflows; @@ -114,12 +90,4 @@ class ArcanistConfiguration { return array(); } - public static function replaceClassnameHyphens($m) { - return strtoupper($m[1]); - } - - public static function replaceClassnameUppers($m) { - return '-'.strtolower($m[0]); - } - } diff --git a/src/workflow/ArcanistAliasWorkflow.php b/src/workflow/ArcanistAliasWorkflow.php index 8c2c5726..a91428f9 100644 --- a/src/workflow/ArcanistAliasWorkflow.php +++ b/src/workflow/ArcanistAliasWorkflow.php @@ -23,6 +23,10 @@ */ final class ArcanistAliasWorkflow extends ArcanistBaseWorkflow { + public function getWorkflowName() { + return 'alias'; + } + public function getCommandSynopses() { return phutil_console_format(<< 0 ); + + public function getWorkflowName() { + return 'close'; + } + public function getCommandSynopses() { return phutil_console_format(<< 7, 'c' => 7, 7 => 7, ); + public function getWorkflowName() { + return 'flag'; + } + public function getCommandSynopses() { return phutil_console_format(<<shouldAmendChanges = $should_amend; return $this; diff --git a/src/workflow/ArcanistListWorkflow.php b/src/workflow/ArcanistListWorkflow.php index 5c5d8bff..c3486edc 100644 --- a/src/workflow/ArcanistListWorkflow.php +++ b/src/workflow/ArcanistListWorkflow.php @@ -23,6 +23,10 @@ */ final class ArcanistListWorkflow extends ArcanistBaseWorkflow { + public function getWorkflowName() { + return 'list'; + } + public function getCommandSynopses() { return phutil_console_format(<<