示例#1
0
 /**
  * Check for an alias and replace the input with a new string command
  * if the alias exists.
  *
  * @return string New command string (for testing purposes)
  */
 public function handleAlias(CommandPreRunEvent $event)
 {
     $input = $event->getInput();
     $commandName = $input->getFirstArgument();
     $aliasConfig = $this->configManager->getConfig('alias');
     if (!isset($aliasConfig[$commandName])) {
         return;
     }
     $commandTemplate = $aliasConfig[$commandName];
     $replaces = array();
     preg_match_all('{\\{arg[0-9]+\\}}', $commandTemplate, $matches);
     $args = array();
     if (isset($matches[0])) {
         $args = $matches[0];
     }
     $tokens = $input->getTokens();
     foreach ($tokens as $i => $token) {
         if (strstr($token, ' ')) {
             $token = escapeshellarg($token);
         }
         $replaces['{arg' . $i . '}'] = $token;
     }
     $command = strtr($commandTemplate, $replaces);
     foreach ($args as $arg) {
         $command = str_replace($arg, '', $command);
     }
     $command = trim($command);
     $newInput = new StringInput($command);
     $event->setInput($newInput);
     return $command;
 }
示例#2
0
 /**
  * Check for an alias and replace the input with a new string command
  * if the alias exists.
  *
  * @return string New command string (for testing purposes)
  */
 public function handleAlias(CommandPreRunEvent $event)
 {
     $input = $event->getInput();
     $commandName = $input->getFirstArgument();
     $aliasConfig = $this->configManager->getConfig('alias');
     if (!isset($aliasConfig[$commandName])) {
         return;
     }
     $command = $aliasConfig[$commandName];
     $command = $command .= substr($input->getRawCommand(), strlen($commandName));
     $newInput = new StringInput($command);
     $event->setInput($newInput);
     return $command;
 }
示例#3
0
 public function let(ConfigManager $configManager, Filesystem $filesystem)
 {
     $configManager->getConfigDir()->willReturn(__DIR__);
     $this->beConstructedWith($configManager, $filesystem);
 }