Example #1
0
 /**
  * Override run method to internationalize error message.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return int Return code
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     // Set extra colors
     // The most problem is $output->getFormatter() don't work.
     // So create new formatter to add extra color.
     $formatter = new OutputFormatter($output->isDecorated());
     $formatter->setStyle('red', new OutputFormatterStyle('red', 'black'));
     $formatter->setStyle('green', new OutputFormatterStyle('green', 'black'));
     $formatter->setStyle('yellow', new OutputFormatterStyle('yellow', 'black'));
     $formatter->setStyle('blue', new OutputFormatterStyle('blue', 'black'));
     $formatter->setStyle('magenta', new OutputFormatterStyle('magenta', 'black'));
     $formatter->setStyle('yellow-blue', new OutputFormatterStyle('yellow', 'blue'));
     $output->setFormatter($formatter);
     \App::setLocale(\Config::get('syncle::MessageLang'));
     try {
         $result = parent::run($input, $output);
     } catch (\RuntimeException $e) {
         // All error messages were hard coded in
         // Symfony/Component/Console/Input/Input.php
         if ($e->getMessage() == 'Not enough arguments.') {
             $this->error(\Lang::get('syncle::BaseCommand.ArgumentNotEnough'));
         } elseif ($e->getMessage() == 'Too many arguments.') {
             $this->error(\Lang::get('syncle::BaseCommand.TooManyArgument'));
         } elseif (preg_match('/The "(.+)" option does not exist./', $e->getMessage(), $matches)) {
             $this->error(\Lang::get('syncle::BaseCommand.OptionNotExist', array('option' => $matches[1])));
         } else {
             $this->error($e->getMessage());
         }
         $result = 1;
     }
     return $result;
 }
 public function run(InputInterface $input, OutputInterface $output)
 {
     // Set extra colors.
     // The most problem is $output->getFormatter() don't work...
     // So create new formatter to add extra color.
     $formatter = new OutputFormatter($output->isDecorated());
     $formatter->setStyle('red', new OutputFormatterStyle('red', 'black'));
     $formatter->setStyle('green', new OutputFormatterStyle('green', 'black'));
     $formatter->setStyle('yellow', new OutputFormatterStyle('yellow', 'black'));
     $formatter->setStyle('blue', new OutputFormatterStyle('blue', 'black'));
     $formatter->setStyle('magenta', new OutputFormatterStyle('magenta', 'black'));
     $formatter->setStyle('yellow-blue', new OutputFormatterStyle('yellow', 'blue'));
     $output->setFormatter($formatter);
     return parent::run($input, $output);
 }
 /**
  * Symfonyコマンドコンポーネントにハードコードされている
  * エラーメッセージを日本語に変換する.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return int Return code
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     try {
         $result = parent::run($input, $output);
     } catch (\RuntimeException $e) {
         if ($e->getMessage() == 'Not enough arguments.') {
             throw new \RuntimeException(__('引数が足りません。'), $e->getCode(), $e->getPrevious());
         } elseif ($e->getMessage() == 'Too many arguments.') {
             throw new \RuntimeException(__('引数が多すぎます。'), $e->getCode(), $e->getPrevious());
         } elseif (preg_match('/The "(.+)" option does not exist./', $e->getMessage(), $matches)) {
             throw new \RuntimeException(__($matches[1] . 'オプションは存在していません。'), $e->getCode(), $e->getPrevious());
         } else {
             throw new \RuntimeException($e->getMessage(), $e->getCode(), $e->getPrevious());
         }
     }
     return $result;
 }
Example #4
0
 /**
  * Override run method to internationalize error message.
  *
  * @param \Symfony\Component\Console\Input\InputInterface $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @return int Return code
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     try {
         $result = parent::run($input, $output);
     } catch (\RuntimeException $e) {
         // All error messages were hard coded in
         // Symfony/Component/Console/Input/Input.php
         if ($e->getMessage() == 'Not enough arguments.') {
             $this->error(\Lang::get('StriveJobs::BaseCommand.ArgumentNotEnough'));
         } elseif ($e->getMessage() == 'Too many arguments.') {
             $this->error(\Lang::get('StriveJobs::BaseCommand.TooManyArgument'));
         } elseif (preg_match('/The "(.+)" option does not exist./', $e->getMessage(), $matches)) {
             $this->error(\Lang::get('StriveJobs::BaseCommand.OptionNotExist', array('option' => $matches[1])));
         } else {
             $this->error($e->getMessage());
         }
         $result = 1;
         // As error status code
     }
     return $result;
 }
Example #5
0
 protected function runCommand(Command $command, array $input, OutputInterface $output)
 {
     $command->setLaravel($this->app);
     return $command->run(new ArrayInput($input), $output);
 }
 /**
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return int
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     app(ConsoleOutput::class)->setOutput($this);
     return parent::run($input, $output);
 }
 /**
  * Run the command.
  * @param \Illuminate\Console\Command $command
  * @param array $input
  * @return int
  */
 protected function runCommand($command, $input = [])
 {
     return $command->run(new ArrayInput($input), new NullOutput());
 }
Example #8
0
 /**
  * run.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  *
  * @return \Symfony\Component\Console\Input\StringInput
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     $command = (string) $input;
     $command = strtr($command, [' -name' => ' -N', ' -type' => ' -T', ' -maxdepth' => ' -M', ' -delete' => ' -d true']);
     return parent::run(new StringInput($command), $output);
 }
Example #9
0
 /**
  * @param \Illuminate\Console\Command $mockedCommandObject
  * @param array $arguments
  * @return int
  */
 public function invokeCommand(Command $mockedCommandObject, $arguments = [])
 {
     $mockedCommandObject->setLaravel(app());
     return $mockedCommandObject->run(new ArrayInput($arguments), $this->getCommandOutput());
 }
Example #10
0
 public function run(InputInterface $input, OutputInterface $output)
 {
     $options = $input->__toString();
     $arr = explode(' ', $options);
     array_shift($arr);
     foreach ($arr as $i => &$option) {
         $option = trim($option, "'");
         if (strpos($option, '-') === 0) {
             $option = '{' . $option . '?}';
         } else {
             $option = '{k' . $i . '}';
         }
     }
     $this->signature = implode(' ', $arr);
     $this->configureUsingFluentDefinition();
     $this->setDescription($this->description);
     return parent::run($input, $output);
 }