/** * Add arguments. * * @param array $arguments */ public function addArguments(array $arguments) { foreach ($arguments as $index => $arg) { $argument = $this->definition->getArgument($index); $this->argument->set($argument->getName(), $arg); } }
/** * Configure definition. */ protected function configureDefinition() { if (null === $this->definition) { $this->definition = new Definition(); $this->definition->addOption(new Option('help'))->setShortcut('h')->setDescription('Display this help message'); $this->definition->addOption(new Option('no-ansi'))->setDescription('Disable ANSI output'); } }
/** * {@inheritdoc} */ public function setDefinition(Definition $definition) { $definition->addOption(new Option('daemon', Option::NONE))->setShortcut('d')->setDescription('Run in daemon mode')->end(); return parent::setDefinition($definition); }
/** * Create definition. * * @return Definition */ private function createDefinition() { $definition = new Definition(); $definition->addArgument(new Argument('console_name', Argument::REQUIRED, 'The console name')); return $definition; }
/** * Merge definition. * * @param Definition $definition */ public function merge(Definition $definition) { foreach ($definition->getArguments() as $argument) { $this->addArgument($argument); } foreach ($definition->getOptions() as $option) { $this->addOption($option); } }
/** * Get all options. * * @return array */ public function all() { return array_merge($this->definition->getOptionDefaults(), $this->options); }
/** * Get all arguments. * * @return array */ public function all() { return array_merge($this->definition->getArgumentDefaults(), $this->arguments); }
/** * Create config definition. * * @return Definition */ private function createDefinition() { $definition = new Definition(); return $definition->addArgument(new Argument('channel', Argument::OPTIONAL, 'Listen for specified channel')); }
/** * @return Definition */ protected function createDefinition() { $definition = new Definition(); $definition->addArgument(new Argument($this->getMessageType(), Argument::REQUIRED, 'Message class'))->addArgument(new Argument('data', Argument::OPTIONAL, 'Data for message (json format).'))->addOption(new Option('factory', Option::OPTIONAL))->setShortcut('f')->setDescription('Create message with factor method.')->end()->addOption(new Option('serialize'))->setShortcut('s')->setDescription('Serialize result if possible.')->end(); return $definition; }
/** * Create definition. * * @return Definition */ private function createDefinition() { $definition = new Definition(); $definition->addOption(new Option('address', Option::OPTIONAL))->setDefault('127.0.0.1')->setShortcut('a')->setDescription('Active listen address')->end()->addOption(new Option('port', Option::OPTIONAL))->setDefault(8000)->setShortcut('p')->setDescription('Active listen port')->end(); return $definition; }