20
20
use Symfony \Component \Console \Output \OutputInterface ;
21
21
use Symfony \Component \Console \Style \SymfonyStyle ;
22
22
use Symfony \Component \Filesystem \Filesystem ;
23
+ use Symfony \Component \Finder \Finder ;
23
24
use SymfonyDocsBuilder \BuildConfig ;
24
25
25
26
class CheckDocsCommand extends Command
@@ -43,7 +44,7 @@ protected function configure()
43
44
{
44
45
$ this
45
46
->addArgument ('source-dir ' , InputArgument::REQUIRED , 'RST files Source directory ' )
46
- ->addArgument ('files ' , InputArgument::IS_ARRAY + InputArgument:: REQUIRED , 'RST files that should be verified. ' )
47
+ ->addArgument ('files ' , InputArgument::IS_ARRAY , 'RST files that should be verified. ' , [] )
47
48
->addOption ('output-format ' , null , InputOption::VALUE_REQUIRED , 'Valid options are github and console ' , 'github ' )
48
49
->addOption ('generate-baseline ' , null , InputOption::VALUE_REQUIRED , 'Generate a new baseline ' , false )
49
50
->addOption ('baseline ' , null , InputOption::VALUE_REQUIRED , 'Use a baseline ' , false )
@@ -77,6 +78,10 @@ protected function initialize(InputInterface $input, OutputInterface $output)
77
78
protected function execute (InputInterface $ input , OutputInterface $ output ): int
78
79
{
79
80
$ files = $ input ->getArgument ('files ' );
81
+ if ([] === $ files ) {
82
+ $ files = $ this ->findFiles ($ input ->getArgument ('source-dir ' ));
83
+ }
84
+
80
85
$ parseQueue = new ParseQueue ();
81
86
foreach ($ files as $ filename ) {
82
87
// Remove ".rst"
@@ -121,4 +126,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
121
126
122
127
return Command::SUCCESS ;
123
128
}
129
+
130
+ private function findFiles (string $ directory ): array
131
+ {
132
+ $ files = [];
133
+ $ finder = new Finder ();
134
+ $ finder ->in ($ directory )
135
+ ->name ('*.rst ' );
136
+ foreach ($ finder as $ file ) {
137
+ $ files [] = $ file ->getRelativePathname ();
138
+ }
139
+
140
+ return $ files ;
141
+ }
124
142
}
0 commit comments