コード例 #1
0
 /**
  * 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);
     }
 }
コード例 #2
0
 /**
  * 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');
     }
 }
コード例 #3
0
 /**
  * {@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);
 }
コード例 #4
0
 /**
  * Create definition.
  *
  * @return Definition
  */
 private function createDefinition()
 {
     $definition = new Definition();
     $definition->addArgument(new Argument('console_name', Argument::REQUIRED, 'The console name'));
     return $definition;
 }
コード例 #5
0
 /**
  * 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);
     }
 }
コード例 #6
0
 /**
  * Get all options.
  *
  * @return array
  */
 public function all()
 {
     return array_merge($this->definition->getOptionDefaults(), $this->options);
 }
コード例 #7
0
 /**
  * Get all arguments.
  *
  * @return array
  */
 public function all()
 {
     return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
 }
コード例 #8
0
 /**
  * Create config definition.
  *
  * @return Definition
  */
 private function createDefinition()
 {
     $definition = new Definition();
     return $definition->addArgument(new Argument('channel', Argument::OPTIONAL, 'Listen for specified channel'));
 }
コード例 #9
0
 /**
  * @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;
 }
コード例 #10
0
 /**
  * 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;
 }