@@ -68,7 +68,7 @@ protected function configure()
6868 ->setDefinition ([
6969 new InputArgument ('name ' , InputArgument::OPTIONAL , 'The template name ' ),
7070 new InputOption ('filter ' , null , InputOption::VALUE_REQUIRED , 'Show details for all entries matching this filter ' ),
71- new InputOption ('format ' , null , InputOption::VALUE_REQUIRED , 'The output format (text or json) ' , 'text ' ),
71+ new InputOption ('format ' , null , InputOption::VALUE_REQUIRED , sprintf ( 'The output format ("%s") ' , implode ( ' ", " ' , $ this -> getAvailableFormatOptions ())) , 'text ' ),
7272 ])
7373 ->setHelp (<<<'EOF'
7474The <info>%command.name%</info> command outputs a list of twig functions,
@@ -107,7 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
107107 match ($ input ->getOption ('format ' )) {
108108 'text ' => $ name ? $ this ->displayPathsText ($ io , $ name ) : $ this ->displayGeneralText ($ io , $ filter ),
109109 'json ' => $ name ? $ this ->displayPathsJson ($ io , $ name ) : $ this ->displayGeneralJson ($ io , $ filter ),
110- default => throw new InvalidArgumentException (sprintf ('The format "%s" is not supported. ' , $ input -> getOption ( ' format ' ))),
110+ default => throw new InvalidArgumentException (sprintf ('Supported formats are "%s". ' , implode ( ' ", " ' , $ this -> getAvailableFormatOptions () ))),
111111 };
112112
113113 return 0 ;
@@ -120,7 +120,7 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
120120 }
121121
122122 if ($ input ->mustSuggestOptionValuesFor ('format ' )) {
123- $ suggestions ->suggestValues ([ ' text ' , ' json ' ] );
123+ $ suggestions ->suggestValues ($ this -> getAvailableFormatOptions () );
124124 }
125125 }
126126
@@ -596,4 +596,9 @@ private function getFileLink(string $absolutePath): string
596596
597597 return (string ) $ this ->fileLinkFormatter ->format ($ absolutePath , 1 );
598598 }
599+
600+ private function getAvailableFormatOptions (): array
601+ {
602+ return ['text ' , 'json ' ];
603+ }
599604}
0 commit comments