Changeset View
Changeset View
Standalone View
Standalone View
src/configuration/ArcanistConfiguration.php
| Show All 40 Lines | $workflows_by_class_name = id(new PhutilSymbolLoader()) | ||||
| ->setAncestorClass('ArcanistWorkflow') | ->setAncestorClass('ArcanistWorkflow') | ||||
| ->loadObjects(); | ->loadObjects(); | ||||
| foreach ($workflows_by_class_name as $class => $workflow) { | foreach ($workflows_by_class_name as $class => $workflow) { | ||||
| $name = $workflow->getWorkflowName(); | $name = $workflow->getWorkflowName(); | ||||
| if (isset($workflows_by_name[$name])) { | if (isset($workflows_by_name[$name])) { | ||||
| $other = get_class($workflows_by_name[$name]); | $other = get_class($workflows_by_name[$name]); | ||||
| throw new Exception( | throw new Exception( | ||||
| "Workflows {$class} and {$other} both implement workflows named ". | pht( | ||||
| "{$name}."); | 'Workflows %s and %s both implement workflows named %s.', | ||||
| $class, | |||||
| $other, | |||||
| $name)); | |||||
| } | } | ||||
| $workflows_by_name[$name] = $workflow; | $workflows_by_name[$name] = $workflow; | ||||
| } | } | ||||
| return $workflows_by_name; | return $workflows_by_name; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | final public function selectWorkflow( | ||||
| $full_alias = idx($aliases, $command, array()); | $full_alias = idx($aliases, $command, array()); | ||||
| $full_alias = implode(' ', $full_alias); | $full_alias = implode(' ', $full_alias); | ||||
| // Run shell command aliases. | // Run shell command aliases. | ||||
| if (ArcanistAliasWorkflow::isShellCommandAlias($new_command)) { | if (ArcanistAliasWorkflow::isShellCommandAlias($new_command)) { | ||||
| $shell_cmd = substr($full_alias, 1); | $shell_cmd = substr($full_alias, 1); | ||||
| $console->writeLog( | $console->writeLog( | ||||
| "[alias: 'arc %s' -> $ %s]", | "[%s: 'arc %s' -> $ %s]", | ||||
| pht('alias'), | |||||
| $command, | $command, | ||||
| $shell_cmd); | $shell_cmd); | ||||
| if ($args) { | if ($args) { | ||||
| $err = phutil_passthru('%C %Ls', $shell_cmd, $args); | $err = phutil_passthru('%C %Ls', $shell_cmd, $args); | ||||
| } else { | } else { | ||||
| $err = phutil_passthru('%C', $shell_cmd); | $err = phutil_passthru('%C', $shell_cmd); | ||||
| } | } | ||||
| exit($err); | exit($err); | ||||
| } | } | ||||
| // Run arc command aliases. | // Run arc command aliases. | ||||
| if ($new_command) { | if ($new_command) { | ||||
| $workflow = $this->buildWorkflow($new_command); | $workflow = $this->buildWorkflow($new_command); | ||||
| if ($workflow) { | if ($workflow) { | ||||
| $console->writeLog( | $console->writeLog( | ||||
| "[alias: 'arc %s' -> 'arc %s']\n", | "[%s: 'arc %s' -> 'arc %s']\n", | ||||
| pht('alias'), | |||||
| $command, | $command, | ||||
| $full_alias); | $full_alias); | ||||
| $command = $new_command; | $command = $new_command; | ||||
| return $workflow; | return $workflow; | ||||
| } | } | ||||
| } | } | ||||
| $all = array_keys($this->buildAllWorkflows()); | $all = array_keys($this->buildAllWorkflows()); | ||||
| Show All 24 Lines | final public function selectWorkflow( | ||||
| } else if (count($corrected) > 1) { | } else if (count($corrected) > 1) { | ||||
| $this->raiseUnknownCommand($command, $corrected); | $this->raiseUnknownCommand($command, $corrected); | ||||
| } | } | ||||
| $this->raiseUnknownCommand($command); | $this->raiseUnknownCommand($command); | ||||
| } | } | ||||
| private function raiseUnknownCommand($command, array $maybe = array()) { | private function raiseUnknownCommand($command, array $maybe = array()) { | ||||
| $message = pht("Unknown command '%s'. Try 'arc help'.", $command); | $message = pht("Unknown command '%s'. Try '%s'.", $command, 'arc help'); | ||||
| if ($maybe) { | if ($maybe) { | ||||
| $message .= "\n\n".pht('Did you mean:')."\n"; | $message .= "\n\n".pht('Did you mean:')."\n"; | ||||
| sort($maybe); | sort($maybe); | ||||
| foreach ($maybe as $other) { | foreach ($maybe as $other) { | ||||
| $message .= " ".$other."\n"; | $message .= " ".$other."\n"; | ||||
| } | } | ||||
| } | } | ||||
| throw new ArcanistUsageException($message); | throw new ArcanistUsageException($message); | ||||
| ▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines | |||||