22
33namespace PHPSemVerChecker \Console \Command ;
44
5- use File_Iterator_Facade ;
65use PHPSemVerChecker \Analyzer \Analyzer ;
76use PHPSemVerChecker \Configuration \Configuration ;
87use PHPSemVerChecker \Configuration \LevelMapping ;
98use PHPSemVerChecker \Filter \SourceFilter ;
9+ use PHPSemVerChecker \Finder \Finder ;
1010use PHPSemVerChecker \Reporter \JsonReporter ;
1111use PHPSemVerChecker \Reporter \Reporter ;
1212use PHPSemVerChecker \Scanner \Scanner ;
@@ -24,10 +24,14 @@ protected function configure()
2424 ->setName ('compare ' )
2525 ->setDescription ('Compare a set of files to determine what semantic versioning change needs to be done ' )
2626 ->setDefinition ([
27- new InputArgument ('source-before ' , InputArgument::REQUIRED , 'A directory to check ' ),
28- new InputArgument ('source-after ' , InputArgument::REQUIRED , 'A directory to check against ' ),
27+ new InputArgument ('source-before ' , InputArgument::REQUIRED , 'A base directory to check (ex my-test) ' ),
28+ new InputArgument ('source-after ' , InputArgument::REQUIRED , 'A base directory to check against (ex my-test) ' ),
29+ new InputOption ('include-before ' , null , InputOption::VALUE_OPTIONAL , 'List of paths to include <info>(comma separated)</info> ' ),
30+ new InputOption ('include-after ' , null , InputOption::VALUE_OPTIONAL , 'List of paths to include <info>(comma separated)</info> ' ),
31+ new InputOption ('exclude-before ' , null , InputOption::VALUE_REQUIRED , 'List of paths to exclude <info>(comma separated)</info> ' ),
32+ new InputOption ('exclude-after ' , null , InputOption::VALUE_REQUIRED , 'List of paths to exclude <info>(comma separated)</info> ' ),
2933 new InputOption ('full-path ' , null , InputOption::VALUE_NONE , 'Display the full path to the file instead of the relative path ' ),
30- new InputOption ('config ' , ' c ' , InputOption::VALUE_REQUIRED , 'A configuration file to configure php-semver-checker ' ),
34+ new InputOption ('config ' , null , InputOption::VALUE_REQUIRED , 'A configuration file to configure php-semver-checker ' ),
3135 new InputOption ('to-json ' , null , InputOption::VALUE_REQUIRED , 'Output the result to a JSON file ' )
3236 ]);
3337 }
@@ -42,15 +46,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
4246 // Set overrides
4347 LevelMapping::setOverrides ($ configuration ->getLevelMapping ());
4448
45- $ fileIterator = new File_Iterator_Facade ;
49+ $ finder = new Finder () ;
4650 $ scannerBefore = new Scanner ();
4751 $ scannerAfter = new Scanner ();
4852
4953 $ sourceBefore = $ input ->getArgument ('source-before ' );
50- $ sourceBefore = $ fileIterator ->getFilesAsArray ($ sourceBefore , '.php ' );
54+ $ includeBefore = $ input ->getOption ('include-before ' );
55+ $ excludeBefore = $ input ->getOption ('exclude-before ' );
5156
5257 $ sourceAfter = $ input ->getArgument ('source-after ' );
53- $ sourceAfter = $ fileIterator ->getFilesAsArray ($ sourceAfter , '.php ' );
58+ $ includeAfter = $ input ->getOption ('include-after ' );
59+ $ excludeAfter = $ input ->getOption ('exclude-after ' );
60+
61+ $ sourceBefore = $ finder ->findFromString ($ sourceBefore , $ includeBefore , $ excludeBefore );
62+ $ sourceAfter = $ finder ->findFromString ($ sourceAfter , $ includeAfter , $ excludeAfter );
5463
5564 $ sourceFilter = new SourceFilter ();
5665 $ identicalCount = $ sourceFilter ->filter ($ sourceBefore , $ sourceAfter );
0 commit comments