8
8
use Doctrine \RST \Event \PreBuildRenderEvent ;
9
9
use Symfony \Component \Console \Command \Command ;
10
10
use Symfony \Component \Console \Helper \ProgressBar ;
11
+ use Symfony \Component \Console \Input \InputArgument ;
11
12
use Symfony \Component \Console \Input \InputInterface ;
12
13
use Symfony \Component \Console \Input \InputOption ;
13
14
use Symfony \Component \Console \Output \OutputInterface ;
@@ -54,9 +55,8 @@ protected function configure()
54
55
parent ::configure ();
55
56
56
57
$ 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 ' )
60
60
->addOption ('parse-only ' , null , InputOption::VALUE_OPTIONAL , 'Parse only given directory for PDF (directory relative from source-dir) ' , null );
61
61
}
62
62
@@ -65,17 +65,18 @@ protected function initialize(InputInterface $input, OutputInterface $output)
65
65
$ this ->io = new SymfonyStyle ($ input , $ output );
66
66
$ this ->output = $ output ;
67
67
68
- $ this ->sourceDir = rtrim ($ this ->getRealAbsolutePath ($ input ->getOption ('source-dir ' )), '/ ' );
68
+ $ this ->sourceDir = rtrim ($ this ->getRealAbsolutePath ($ input ->getArgument ('source-dir ' )), '/ ' );
69
69
if (!$ this ->filesystem ->exists ($ this ->sourceDir )) {
70
70
throw new \InvalidArgumentException (sprintf ('RST source directory "%s" does not exist ' , $ this ->sourceDir ));
71
71
}
72
72
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 ), '/ ' );
74
75
if ($ this ->filesystem ->exists ($ this ->htmlOutputDir )) {
75
76
$ this ->filesystem ->remove ($ this ->htmlOutputDir );
76
77
}
77
78
78
- $ this ->jsonOutputDir = $ this ->getRealAbsolutePath ($ input -> getOption ( ' json-output-dir ' ) );
79
+ $ this ->jsonOutputDir = $ this ->getRealAbsolutePath ($ outputDir . ' / json' );
79
80
if ($ this ->filesystem ->exists ($ this ->jsonOutputDir )) {
80
81
$ this ->filesystem ->remove ($ this ->jsonOutputDir );
81
82
}
@@ -106,7 +107,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
106
107
107
108
protected function execute (InputInterface $ input , OutputInterface $ output )
108
109
{
109
- $ this ->finder ->in ($ input ->getOption ('source-dir ' ))
110
+ $ this ->finder ->in ($ input ->getArgument ('source-dir ' ))
110
111
->exclude (['_build ' , '.github ' , '.platform ' , '_images ' ])
111
112
->notName ('*.rst.inc ' )
112
113
->name ('*.rst ' );
0 commit comments