public static function resolveAliases($command, ArcanistConfiguration $config, array $argv, ArcanistWorkingCopyIdentity $working_copy)
 {
     $aliases = ArcanistAliasWorkflow::getAliases($working_copy);
     if (!isset($aliases[$command])) {
         return array(null, $argv);
     }
     $new_command = head($aliases[$command]);
     $workflow = $config->buildWorkflow($new_command);
     if (!$workflow) {
         return array(null, $argv);
     }
     $alias_argv = array_slice($aliases[$command], 1);
     foreach ($alias_argv as $alias_arg) {
         if (!in_array($alias_arg, $argv)) {
             array_unshift($argv, $alias_arg);
         }
     }
     return array($new_command, $argv);
 }
 public static function resolveAliases($command, ArcanistConfiguration $config, array $argv, ArcanistConfigurationManager $configuration_manager)
 {
     $aliases = self::getAliases($configuration_manager);
     if (!isset($aliases[$command])) {
         return array(null, $argv);
     }
     $new_command = head($aliases[$command]);
     if (self::isShellCommandAlias($new_command)) {
         return array($new_command, $argv);
     }
     $workflow = $config->buildWorkflow($new_command);
     if (!$workflow) {
         return array(null, $argv);
     }
     $alias_argv = array_slice($aliases[$command], 1);
     foreach (array_reverse($alias_argv) as $alias_arg) {
         if (!in_array($alias_arg, $argv)) {
             array_unshift($argv, $alias_arg);
         }
     }
     return array($new_command, $argv);
 }
Exemple #3
0
     // need to fail softly if these break because errors would prevent the user
     // from running "arc set-config" to correct them.
     arcanist_load_libraries(idx($global_config, 'load', array()), $must_load = false, $lib_source = 'the "load" setting in global config', $working_copy, $config_trace_mode);
     // Load libraries in ".arcconfig". Libraries here must load.
     arcanist_load_libraries($working_copy->getConfig('phutil_libraries'), $must_load = true, $lib_source = 'the "phutil_libraries" setting in ".arcconfig"', $working_copy, $config_trace_mode);
 }
 $user_config = ArcanistBaseWorkflow::readUserConfigurationFile();
 $config = $working_copy->getConfig('arcanist_configuration');
 if ($config) {
     $config = new $config();
 } else {
     $config = new ArcanistConfiguration();
 }
 $command = strtolower($args[0]);
 $args = array_slice($args, 1);
 $workflow = $config->buildWorkflow($command);
 if (!$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($working_copy);
     list($new_command, $args) = ArcanistAliasWorkflow::resolveAliases($command, $config, $args, $working_copy);
     $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);
         if ($config_trace_mode) {
             echo "[alias: 'arc {$command}' -> \$ {$full_alias}]\n";
         }