コード例 #1
0
ファイル: Option.php プロジェクト: weew/console-arguments
 /**
  * @param string $alias
  *
  * @return IOption
  *
  * @throws InvalidOptionAliasException
  */
 public function setAlias($alias)
 {
     if ($alias !== null && !$this->argumentsParser->isOptionAlias($alias)) {
         throw new InvalidOptionAliasException(s('A option alias must have this format: "-f", got: "%s"', $alias));
     }
     $this->alias = $alias;
     return $this;
 }
コード例 #2
0
 /**
  * @param IOption $option
  * @param array $groupedArgs
  * @param bool $strict
  *
  * @return array
  * @throws InvalidOptionValueException
  * @throws MissingOptionValueException
  */
 public function matchOption(IOption $option, array $groupedArgs, $strict = true)
 {
     $groupedArgs = $this->argumentsParser->mergeNameAndAlias($groupedArgs, $option->getName(), $option->getAlias());
     if ($option->isIncremental()) {
         $groupedArgs = $this->matchIncrementalOption($option, $groupedArgs, $strict);
     } else {
         if ($option->isBoolean()) {
             $groupedArgs = $this->matchBooleanOption($option, $groupedArgs, $strict);
         } else {
             $groupedArgs = $this->matchRegularOption($option, $groupedArgs, $strict);
         }
     }
     return $groupedArgs;
 }
コード例 #3
0
ファイル: Console.php プロジェクト: weew/console
 /**
  * @param array $args
  *
  * @throws Exception
  */
 protected function handleArgs(array $args)
 {
     $groupedArgs = $this->argumentsParser->group($args);
     list($groupedArgs, $continue) = $this->runGlobalCommands($groupedArgs);
     if ($continue === false) {
         return;
     }
     try {
         list($command, $groupedArgs) = $this->argumentsMatcher->matchCommands($this->getNotGlobalCommands(), $groupedArgs);
         $command = clone $command;
         $this->runCommand($command);
     } catch (MissingCommandNameException $ex) {
         array_unshift($args, $this->getDefaultCommandName());
         $this->parseArgs($args);
     } catch (Exception $ex) {
         if ($this->getCatchErrors()) {
             $widget = new ExceptionWidget($this->input, $this->output);
             $widget->render($ex);
         } else {
             throw $ex;
         }
     }
 }