55use Illuminate \Container \Container ;
66use Illuminate \Database \DatabaseManager ;
77use Illuminate \Log \LogManager ;
8+ use MilesChou \Codegener \Writer ;
89use MilesChou \Schemarkdown \CodeBuilder ;
9- use MilesChou \Schemarkdown \CodeWriter ;
1010use MilesChou \Schemarkdown \Commands \Concerns \DatabaseConnection ;
1111use MilesChou \Schemarkdown \Commands \Concerns \Environment ;
1212use Symfony \Component \Console \Command \Command ;
@@ -63,7 +63,8 @@ protected function configure()
6363 ->addOption ('--env ' , null , InputOption::VALUE_REQUIRED , '.env file ' , '.env ' )
6464 ->addOption ('--config-file ' , null , InputOption::VALUE_REQUIRED , 'Config file ' , 'config/database.php ' )
6565 ->addOption ('--connection ' , null , InputOption::VALUE_REQUIRED , 'Connection name will only build ' , null )
66- ->addOption ('--output-dir ' , null , InputOption::VALUE_REQUIRED , 'Relative path with getcwd() ' , 'generated ' );
66+ ->addOption ('--output-dir ' , null , InputOption::VALUE_REQUIRED , 'Relative path with getcwd() ' , 'generated ' )
67+ ->addOption ('--overwrite ' , null , InputOption::VALUE_NONE , 'Overwrite the exist file ' );
6768 }
6869
6970 protected function execute (InputInterface $ input , OutputInterface $ output )
@@ -72,6 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7273 $ configFile = $ input ->getOption ('config-file ' );
7374 $ connection = $ input ->getOption ('connection ' );
7475 $ outputDir = $ input ->getOption ('output-dir ' );
76+ $ overwrite = $ input ->getOption ('overwrite ' );
7577
7678 $ this ->loadDotEnv ($ this ->normalizePath ($ env ));
7779
@@ -88,7 +90,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
8890
8991 $ logger ->info ('All document build success, next will write files ' );
9092
91- $ this ->container ->make (CodeWriter::class)->generate ($ code , $ outputDir );
93+ /** @var Writer $writer */
94+ $ writer = $ this ->container ->make (Writer::class);
95+ $ writer ->writeMass ($ code , $ outputDir , $ overwrite );
9296
9397 $ logger ->info ('All document write success ' );
9498
0 commit comments