Exemplo n.º 1
0
 /**
  * @param Query $query
  * @param string $name
  * @param bool $force
  * @return void
  * @throws \Exception
  */
 protected function download(Query $query, $name, $force)
 {
     if (!$force && $query->exists()) {
         $this->stdout("use exist {$name} file or api.\n", Console::FG_YELLOW);
     } else {
         $this->stdout("download {$name} file:\n", Console::FG_GREEN);
         $query->init(function ($url) {
             return file_get_contents($url, false, $this->createStreamContext());
         });
         $this->stdout(" completed!\n", Console::FG_GREEN);
     }
 }
Exemplo n.º 2
0
 /**
  * @param OutputInterface $output
  * @param Query $query
  * @param string $name
  * @param bool $force
  * @param bool $noProgress
  * @return void
  * @throws \Exception
  */
 protected function generate(OutputInterface $output, Query $query, $name, $force, $noProgress)
 {
     $use = implode(', ', $query->getProviders());
     if (!$force && $query->exists()) {
         $output->writeln("<comment>use exist {$name} table.</comment>", OutputInterface::VERBOSITY_VERBOSE);
     } else {
         $output->writeln("<info>generate {$name} table with {$use}:</info>");
         if (!$noProgress) {
             $query->init(function ($code, $n) use($output) {
                 switch ($code) {
                     case 0:
                         $this->progress = new ProgressBar($output, $n);
                         $this->progress->start();
                         break;
                     case 1:
                         $this->progress->setProgress($n);
                         break;
                     case 2:
                         $this->progress->finish();
                         break;
                 }
             });
         } else {
             $query->init();
         }
         $output->writeln('<info> completed!</info>');
     }
 }