Beispiel #1
0
 /**
  * Fire the command
  *
  * @return void
  * @author Dan Cox
  */
 public function fire()
 {
     if (Command::exists($this->input->getArgument('name'), 'name')) {
         $command = Command::db()->first(['name' => $this->input->getArgument('name')]);
         $config = $this->DI->get('config');
         $config->load(CONFIG . $command->file);
         $cmds = $config->params()->commands;
         $this->params = $config->params()->parameters;
         // If there is a directory stated in the params, we use that, else we use input
         if (!isset($this->params['directory'])) {
             $this->params['directory'] = $this->input->getArgument('directory');
         }
         // We want to be able to test these, so load them as processes
         foreach ($cmds as $comm) {
             $p = $this->hasProcessDefinition($comm);
             try {
                 $p->mustRun();
                 $cmd = $p->getCommandLine();
                 $this->output->writeln("Ran command: {$cmd}");
             } catch (\Exception $e) {
                 $this->output->writeln("Unable to run command...");
                 $this->output->writeln($e->getMessage());
             }
         }
         $this->output->writeln("Finished running command line chain...");
         return true;
     }
     throw new \RuntimeException("The command does not exist");
 }