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(); }
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; } }
public function getPublicName() { return RequestMapper::getPublicName($this->name); }