@@ -68,7 +68,7 @@ protected function configure()
68
68
->setDefinition ([
69
69
new InputArgument ('name ' , InputArgument::OPTIONAL , 'The template name ' ),
70
70
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 ' ),
72
72
])
73
73
->setHelp (<<<'EOF'
74
74
The <info>%command.name%</info> command outputs a list of twig functions,
@@ -107,7 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
107
107
match ($ input ->getOption ('format ' )) {
108
108
'text ' => $ name ? $ this ->displayPathsText ($ io , $ name ) : $ this ->displayGeneralText ($ io , $ filter ),
109
109
'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 () ))),
111
111
};
112
112
113
113
return 0 ;
@@ -120,7 +120,7 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
120
120
}
121
121
122
122
if ($ input ->mustSuggestOptionValuesFor ('format ' )) {
123
- $ suggestions ->suggestValues ([ ' text ' , ' json ' ] );
123
+ $ suggestions ->suggestValues ($ this -> getAvailableFormatOptions () );
124
124
}
125
125
}
126
126
@@ -596,4 +596,9 @@ private function getFileLink(string $absolutePath): string
596
596
597
597
return (string ) $ this ->fileLinkFormatter ->format ($ absolutePath , 1 );
598
598
}
599
+
600
+ private function getAvailableFormatOptions (): array
601
+ {
602
+ return ['text ' , 'json ' ];
603
+ }
599
604
}
0 commit comments