Example #1
0
 /**
  * Configure the console command using a fluent definition.
  *
  * @return void
  */
 protected function configureUsingFluentDefinition()
 {
     list($name, $arguments, $options) = Parser::parse($this->signature);
     parent::__construct($name);
     foreach ($arguments as $argument) {
         $this->getDefinition()->addArgument($argument);
     }
     foreach ($options as $option) {
         $this->getDefinition()->addOption($option);
     }
 }
 protected function bindSignature()
 {
     $signatureParts = new SignatureParts($this->signature);
     $signature = $signatureParts->getSignatureWithoutCommandName();
     list($name, $arguments, $options) = Parser::parse($signature);
     $this->name = $name;
     $inputDefinition = new InputDefinition();
     foreach ($arguments as $argument) {
         $inputDefinition->addArgument($argument);
     }
     foreach ($options as $option) {
         $inputDefinition->addOption($option);
     }
     $inputWithoutHandlerName = explode(' ', $this->request->text, 2)[1] ?? '';
     $this->input = new StringInput($inputWithoutHandlerName);
     $this->inputDefinition = $inputDefinition;
     try {
         $this->input->bind($inputDefinition);
     } catch (RuntimeException $exception) {
         return false;
     }
     return true;
 }