88use Doctrine \RST \Event \PreBuildRenderEvent ;
99use Symfony \Component \Console \Command \Command ;
1010use Symfony \Component \Console \Helper \ProgressBar ;
11+ use Symfony \Component \Console \Input \InputArgument ;
1112use Symfony \Component \Console \Input \InputInterface ;
1213use Symfony \Component \Console \Input \InputOption ;
1314use Symfony \Component \Console \Output \OutputInterface ;
@@ -54,9 +55,8 @@ protected function configure()
5455 parent ::configure ();
5556
5657 $ this
57- ->addOption ('source-dir ' , null , InputOption::VALUE_REQUIRED , 'RST files Source directory ' , __DIR__ .'/../../.. ' )
58- ->addOption ('html-output-dir ' , null , InputOption::VALUE_REQUIRED , 'HTML files output directory ' , __DIR__ .'/../../html ' )
59- ->addOption ('json-output-dir ' , null , InputOption::VALUE_REQUIRED , 'JSON files output directory ' , __DIR__ .'/../../json ' )
58+ ->addArgument ('source-dir ' , null , InputArgument::REQUIRED , 'RST files Source directory ' )
59+ ->addArgument ('output-dir ' , null , InputArgument::OPTIONAL , 'HTML files output directory ' )
6060 ->addOption ('parse-only ' , null , InputOption::VALUE_OPTIONAL , 'Parse only given directory for PDF (directory relative from source-dir) ' , null );
6161 }
6262
@@ -65,17 +65,18 @@ protected function initialize(InputInterface $input, OutputInterface $output)
6565 $ this ->io = new SymfonyStyle ($ input , $ output );
6666 $ this ->output = $ output ;
6767
68- $ this ->sourceDir = rtrim ($ this ->getRealAbsolutePath ($ input ->getOption ('source-dir ' )), '/ ' );
68+ $ this ->sourceDir = rtrim ($ this ->getRealAbsolutePath ($ input ->getArgument ('source-dir ' )), '/ ' );
6969 if (!$ this ->filesystem ->exists ($ this ->sourceDir )) {
7070 throw new \InvalidArgumentException (sprintf ('RST source directory "%s" does not exist ' , $ this ->sourceDir ));
7171 }
7272
73- $ this ->htmlOutputDir = rtrim ($ this ->getRealAbsolutePath ($ input ->getOption ('html-output-dir ' )), '/ ' );
73+ $ outputDir = $ input ->getArgument ('output-dir ' ) ?? $ this ->sourceDir . '/html ' ;
74+ $ this ->htmlOutputDir = rtrim ($ this ->getRealAbsolutePath ($ outputDir ), '/ ' );
7475 if ($ this ->filesystem ->exists ($ this ->htmlOutputDir )) {
7576 $ this ->filesystem ->remove ($ this ->htmlOutputDir );
7677 }
7778
78- $ this ->jsonOutputDir = $ this ->getRealAbsolutePath ($ input -> getOption ( ' json-output-dir ' ) );
79+ $ this ->jsonOutputDir = $ this ->getRealAbsolutePath ($ outputDir . ' / json' );
7980 if ($ this ->filesystem ->exists ($ this ->jsonOutputDir )) {
8081 $ this ->filesystem ->remove ($ this ->jsonOutputDir );
8182 }
@@ -106,7 +107,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
106107
107108 protected function execute (InputInterface $ input , OutputInterface $ output )
108109 {
109- $ this ->finder ->in ($ input ->getOption ('source-dir ' ))
110+ $ this ->finder ->in ($ input ->getArgument ('source-dir ' ))
110111 ->exclude (['_build ' , '.github ' , '.platform ' , '_images ' ])
111112 ->notName ('*.rst.inc ' )
112113 ->name ('*.rst ' );
0 commit comments