2020use Symfony \Component \Console \Output \OutputInterface ;
2121use Symfony \Component \Console \Style \SymfonyStyle ;
2222use Symfony \Component \Filesystem \Filesystem ;
23+ use Symfony \Component \Finder \Finder ;
2324use SymfonyDocsBuilder \BuildConfig ;
2425
2526class CheckDocsCommand extends Command
@@ -43,7 +44,7 @@ protected function configure()
4344 {
4445 $ this
4546 ->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. ' , [] )
4748 ->addOption ('output-format ' , null , InputOption::VALUE_REQUIRED , 'Valid options are github and console ' , 'github ' )
4849 ->addOption ('generate-baseline ' , null , InputOption::VALUE_REQUIRED , 'Generate a new baseline ' , false )
4950 ->addOption ('baseline ' , null , InputOption::VALUE_REQUIRED , 'Use a baseline ' , false )
@@ -77,6 +78,10 @@ protected function initialize(InputInterface $input, OutputInterface $output)
7778 protected function execute (InputInterface $ input , OutputInterface $ output ): int
7879 {
7980 $ files = $ input ->getArgument ('files ' );
81+ if ([] === $ files ) {
82+ $ files = $ this ->findFiles ($ input ->getArgument ('source-dir ' ));
83+ }
84+
8085 $ parseQueue = new ParseQueue ();
8186 foreach ($ files as $ filename ) {
8287 // Remove ".rst"
@@ -121,4 +126,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
121126
122127 return Command::SUCCESS ;
123128 }
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+ }
124142}
0 commit comments