示例#1
0
 /**
  * Run a task
  *
  * @param mixed $data
  */
 public function run($data)
 {
     $this->task->addValues($data);
     if ($this->task->validate() === true) {
         return $this->task->run();
     }
     $errors = $this->task->getErrors();
     Env::error($this->formatErrors($errors));
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function run($data)
 {
     if (!is_array($data)) {
         throw new InvalidArgumentException("invalid value provided for 'data'; expecting in indexed array " . "of command line options (use \$argv)");
     }
     try {
         $parser = new ArgumentParser(array_slice($data, 1));
         $parser->parseInto($this->task);
     } catch (Exception $ex) {
         $cmd = Cli::getScriptName();
         Env::error($ex->getMessage() . "\n" . "use '@[bold]{$cmd} --help@[reset]' for help\n\n");
     }
     if ($this->task->validate() === false) {
         $errors = $this->task->getErrors();
         Env::error($this->formatErrors($errors));
     }
     return $this->task->run($this->task->exportValues());
 }