Пример #1
0
 static function setUpDefinition(Definition $definition, $options)
 {
     $commandDefinitions = new \stdClass();
     static::setUpCommands($definition, $commandDefinitions);
     $actions = array();
     foreach ((array) $commandDefinitions as $name => $commandDefinition) {
         $name = RequestMapper::getPublicName($name);
         $actions[] = $name;
         $definition->actions[$name] = $commandDefinition;
     }
     $options->action = Option::create()->setEnum($actions)->setDescription('Action name')->setIsRequired()->setIsUnnamed();
 }
Пример #2
0
 public function run(Request $request = null)
 {
     if (null === $request) {
         $request = Request::createAuto();
     }
     $this->request = $request;
     try {
         $this->reader = new RequestMapper();
         $this->reader->skipFirstTokens = $this->skipFirstTokens;
         $this->reader->read($request, $this->command->optionsArray());
     } catch (Exception $exception) {
         $this->response->error($exception->getMessage());
         $this->response->addContent('Use --help to show information.');
         return $this;
     }
     if (!empty($this->reader->values[self::HELP])) {
         $this->showHelp();
         return $this;
     } elseif (!empty($this->reader->values[self::VERSION])) {
         $this->showVersion();
         return $this;
     } elseif (!empty($this->reader->values[self::BASH_COMPLETION])) {
         $this->showBashCompletion();
         return $this;
     } elseif (!empty($this->reader->values[self::INSTALL])) {
         // @codeCoverageIgnoreStart
         $this->install();
         return $this;
         // @codeCoverageIgnoreEnd
     } else {
         foreach ($this->reader->values as $name => $value) {
             $this->command->{$name} = $value;
         }
         $this->command->performAction();
         return $this;
     }
 }
Пример #3
0
 public function getPublicName()
 {
     return RequestMapper::getPublicName($this->name);
 }