hasOption() 공개 메소드

是否有某个选项
public hasOption ( string $name ) : boolean
$name string 选项名
리턴 boolean
예제 #1
0
 protected function execute(Input $input, Output $output)
 {
     if (!is_dir(RUNTIME_PATH . 'schema')) {
         @mkdir(RUNTIME_PATH . 'schema', 0755, true);
     }
     if ($input->hasOption('module')) {
         $module = $input->getOption('module');
         // 读取模型
         $list = scandir(APP_PATH . $module . DS . 'model');
         $app = App::$namespace;
         foreach ($list as $file) {
             if ('.' == $file || '..' == $file) {
                 continue;
             }
             $class = '\\' . $app . '\\' . $module . '\\model\\' . pathinfo($file, PATHINFO_FILENAME);
             $this->buildModelSchema($class);
         }
         $output->writeln('<info>Succeed!</info>');
         return;
     } else {
         if ($input->hasOption('table')) {
             $table = $input->getOption('table');
             if (!strpos($table, '.')) {
                 $dbName = Db::getConfig('database');
             }
             $tables[] = $table;
         } elseif ($input->hasOption('db')) {
             $dbName = $input->getOption('db');
             $tables = Db::getTables($dbName);
         } elseif (!\think\Config::get('app_multi_module')) {
             $app = App::$namespace;
             $list = scandir(APP_PATH . 'model');
             foreach ($list as $file) {
                 if ('.' == $file || '..' == $file) {
                     continue;
                 }
                 $class = '\\' . $app . '\\model\\' . pathinfo($file, PATHINFO_FILENAME);
                 $this->buildModelSchema($class);
             }
             $output->writeln('<info>Succeed!</info>');
             return;
         } else {
             $tables = Db::getTables();
         }
     }
     $db = isset($dbName) ? $dbName . '.' : '';
     $this->buildDataBaseSchema($tables, $db);
     $output->writeln('<info>Succeed!</info>');
 }
예제 #2
0
 protected function execute(Input $input, Output $output)
 {
     if ($input->hasOption('module')) {
         \think\Build::module($input->getOption('module'));
         $output->writeln("Successed");
         return;
     }
     if ($input->hasOption('config')) {
         $build = (include $input->getOption('config'));
     } else {
         $build = (include APP_PATH . 'build.php');
     }
     if (empty($build)) {
         $output->writeln("Build Config Is Empty");
         return;
     }
     \think\Build::run($build);
     $output->writeln("Successed");
 }
예제 #3
0
 protected function execute(Input $input, Output $output)
 {
     if ($input->hasOption('module')) {
         $module = $input->getOption('module') . DS;
     } else {
         $module = '';
     }
     $content = '<?php ' . PHP_EOL . $this->buildCacheContent($module);
     if (!is_dir(RUNTIME_PATH . $module)) {
         @mkdir(RUNTIME_PATH . $module, 0755, true);
     }
     file_put_contents(RUNTIME_PATH . $module . 'init' . EXT, $content);
     $output->writeln('<info>Succeed!</info>');
 }