20
20
use Rector \ValueObject \Configuration ;
21
21
use Symfony \Component \Console \Command \Command ;
22
22
use Symfony \Component \Console \Helper \QuestionHelper ;
23
+ use Symfony \Component \Console \Input \InputArgument ;
23
24
use Symfony \Component \Console \Input \InputInterface ;
24
25
use Symfony \Component \Console \Input \InputOption ;
25
26
use Symfony \Component \Console \Output \OutputInterface ;
@@ -41,6 +42,7 @@ public function __construct(private readonly Cache $cache)
41
42
42
43
protected function configure (): void
43
44
{
45
+ $ this ->addArgument (Option::SOURCE , InputArgument::OPTIONAL | InputArgument::IS_ARRAY , 'Files or directories to be upgraded. ' );
44
46
$ this ->addOption (
45
47
'startOver ' ,
46
48
's ' ,
@@ -61,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
61
63
$ this ->cache ->clear ();
62
64
}
63
65
64
- $ allFiles = $ this ->getAllFiles ();
66
+ $ allFiles = $ this ->getAllFiles ($ this -> input -> getArgument (Option:: SOURCE ) );
65
67
66
68
$ chunkConfig = $ this ->parseChunkConfig ($ input ->getOption ('chunk ' ));
67
69
if ($ chunkConfig ->chunkNumber === 1 ) {
@@ -96,9 +98,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
96
98
}
97
99
98
100
/**
101
+ * @param list<string> $sources
99
102
* @return list<string>
100
103
*/
101
- private function getAllFiles (): array
104
+ private function getAllFiles (array $ sources ): array
102
105
{
103
106
$ bootstrapConfigs = (new RectorConfigsResolver ())->provide ();
104
107
@@ -107,9 +110,13 @@ private function getAllFiles(): array
107
110
$ configFunction (new RectorConfig ());
108
111
}
109
112
110
- $ paths = SimpleParameterProvider::provideArrayParameter (Option::PATHS );
111
- if (!$ paths ) {
112
- throw new InvalidArgumentException ('No paths found in configuration ' . $ bootstrapConfigs ->getMainConfigFile ());
113
+ if ($ sources ) {
114
+ $ paths = $ sources ;
115
+ } else {
116
+ $ paths = SimpleParameterProvider::provideArrayParameter (Option::PATHS );
117
+ if (!$ paths ) {
118
+ throw new InvalidArgumentException ('No paths found in configuration ' . $ bootstrapConfigs ->getMainConfigFile ());
119
+ }
113
120
}
114
121
115
122
$ rectorContainer = (new RectorContainerFactory ())->createFromBootstrapConfigs ($ bootstrapConfigs );
0 commit comments