Changeset View
Changeset View
Standalone View
Standalone View
src/configuration/ArcanistConfiguration.php
| Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | final public function selectWorkflow( | ||||
| // First, try to build a workflow with the exact name provided. We always | // First, try to build a workflow with the exact name provided. We always | ||||
| // pick an exact match, and do not allow aliases to override it. | // pick an exact match, and do not allow aliases to override it. | ||||
| $workflow = $this->buildWorkflow($command); | $workflow = $this->buildWorkflow($command); | ||||
| if ($workflow) { | if ($workflow) { | ||||
| return $workflow; | return $workflow; | ||||
| } | } | ||||
| // If the user has an alias, like 'arc alias dhelp diff help', look it up | |||||
| // and substitute it. We do this only after trying to resolve the workflow | |||||
| // normally to prevent you from doing silly things like aliasing 'alias' | |||||
| // to something else. | |||||
| $aliases = ArcanistAliasWorkflow::getAliases($configuration_manager); | |||||
| list($new_command, $args) = ArcanistAliasWorkflow::resolveAliases( | |||||
| $command, | |||||
| $this, | |||||
| $args, | |||||
| $configuration_manager); | |||||
| $full_alias = idx($aliases, $command, array()); | |||||
| $full_alias = implode(' ', $full_alias); | |||||
| // Run shell command aliases. | |||||
| if (ArcanistAliasWorkflow::isShellCommandAlias($new_command)) { | |||||
| $shell_cmd = substr($full_alias, 1); | |||||
| $console->writeLog( | |||||
| "[%s: 'arc %s' -> $ %s]", | |||||
| pht('alias'), | |||||
| $command, | |||||
| $shell_cmd); | |||||
| if ($args) { | |||||
| $err = phutil_passthru('%C %Ls', $shell_cmd, $args); | |||||
| } else { | |||||
| $err = phutil_passthru('%C', $shell_cmd); | |||||
| } | |||||
| exit($err); | |||||
| } | |||||
| // Run arc command aliases. | |||||
| if ($new_command) { | |||||
| $workflow = $this->buildWorkflow($new_command); | |||||
| if ($workflow) { | |||||
| $console->writeLog( | |||||
| "[%s: 'arc %s' -> 'arc %s']\n", | |||||
| pht('alias'), | |||||
| $command, | |||||
| $full_alias); | |||||
| $command = $new_command; | |||||
| return $workflow; | |||||
| } | |||||
| } | |||||
| $all = array_keys($this->buildAllWorkflows()); | $all = array_keys($this->buildAllWorkflows()); | ||||
| // We haven't found a real command or an alias, so try to locate a command | // We haven't found a real command or an alias, so try to locate a command | ||||
| // by unique prefix. | // by unique prefix. | ||||
| $prefixes = $this->expandCommandPrefix($command, $all); | $prefixes = $this->expandCommandPrefix($command, $all); | ||||
| if (count($prefixes) == 1) { | if (count($prefixes) == 1) { | ||||
| $command = head($prefixes); | $command = head($prefixes); | ||||
| ▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines | |||||