示例#1
0
 public function writeTo(string $dest)
 {
     if (file_exists($dest)) {
         if ('n' == CLI::prompt('Destination exists. Overwrite?', ['y', 'n'])) {
             die;
         }
     }
     if (strpos($dest, 'user_guide_src/source/') !== false) {
         $dest = substr($dest, strlen('user_guide_src/source/'));
     }
     str_ireplace('.rst', '', $dest);
     $dest = dirname(__FILE__) . '/source/' . $dest . '.rst';
     if (!($fp = fopen($dest, 'wb'))) {
         die('Unable to write to: ' . $dest);
     }
     fwrite($fp, $this->prose . "\n");
     fclose($fp);
 }
 /**
  * Runs the specified Seeder file to populate the database
  * with some data.
  *
  * @param string $seedName
  */
 public function seed(string $seedName = null)
 {
     $seeder = new Seeder(new \Config\Database());
     if (empty($seedName)) {
         $seedName = CLI::prompt('Seeder name');
     }
     if (empty($seedName)) {
         CLI::error('You must provide a seeder name.');
         return;
     }
     try {
         $seeder->call($seedName);
     } catch (\Exception $e) {
         $this->showError($e);
     }
 }