@@ -57,7 +57,7 @@ protected function configure()
57
57
{
58
58
$ this
59
59
->addArgument ('filename ' , InputArgument::IS_ARRAY , 'A file, a directory or "-" for reading from STDIN ' )
60
- ->addOption ('format ' , null , InputOption::VALUE_REQUIRED , 'The output format ' )
60
+ ->addOption ('format ' , null , InputOption::VALUE_REQUIRED , sprintf ( 'The output format ("%s") ' , implode ( ' ", " ' , $ this -> getAvailableFormatOptions ())) )
61
61
->addOption ('exclude ' , null , InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY , 'Path(s) to exclude ' )
62
62
->addOption ('parse-tags ' , null , InputOption::VALUE_NEGATABLE , 'Parse custom tags ' , null )
63
63
->setHelp (<<<EOF
@@ -154,7 +154,7 @@ private function display(SymfonyStyle $io, array $files): int
154
154
'txt ' => $ this ->displayTxt ($ io , $ files ),
155
155
'json ' => $ this ->displayJson ($ io , $ files ),
156
156
'github ' => $ this ->displayTxt ($ io , $ files , true ),
157
- default => throw new InvalidArgumentException (sprintf ('The format "%s" is not supported. ' , $ this ->format )),
157
+ default => throw new InvalidArgumentException (sprintf ('Supported formats are "%s". ' , implode ( ' ", " ' , $ this ->getAvailableFormatOptions ()) )),
158
158
};
159
159
}
160
160
@@ -265,7 +265,12 @@ private function isReadable(string $fileOrDirectory): bool
265
265
public function complete (CompletionInput $ input , CompletionSuggestions $ suggestions ): void
266
266
{
267
267
if ($ input ->mustSuggestOptionValuesFor ('format ' )) {
268
- $ suggestions ->suggestValues ([ ' txt ' , ' json ' , ' github ' ] );
268
+ $ suggestions ->suggestValues ($ this -> getAvailableFormatOptions () );
269
269
}
270
270
}
271
+
272
+ private function getAvailableFormatOptions (): array
273
+ {
274
+ return ['txt ' , 'json ' , 'github ' ];
275
+ }
271
276
}
0 commit comments