Skip to content

Commit f60e331

Browse files
alamiraultfabpot
authored andcommitted
Harmonize command formats and ensure autocompletion is same
1 parent 6eada4e commit f60e331

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Command/DebugCommand.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function configure()
6464
new InputArgument('class', InputArgument::OPTIONAL, 'The form type class'),
6565
new InputArgument('option', InputArgument::OPTIONAL, 'The form type option'),
6666
new InputOption('show-deprecated', null, InputOption::VALUE_NONE, 'Display deprecated options in form types'),
67-
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt or json)', 'txt'),
67+
new InputOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'txt'),
6868
])
6969
->setHelp(<<<'EOF'
7070
The <info>%command.name%</info> command displays information about form types.
@@ -261,8 +261,7 @@ public function complete(CompletionInput $input, CompletionSuggestions $suggesti
261261
}
262262

263263
if ($input->mustSuggestOptionValuesFor('format')) {
264-
$helper = new DescriptorHelper();
265-
$suggestions->suggestValues($helper->getFormats());
264+
$suggestions->suggestValues($this->getAvailableFormatOptions());
266265
}
267266
}
268267

@@ -283,4 +282,9 @@ private function completeOptions(string $class, CompletionSuggestions $suggestio
283282
$resolvedType = $this->formRegistry->getType($class);
284283
$suggestions->suggestValues($resolvedType->getOptionsResolver()->getDefinedOptions());
285284
}
285+
286+
private function getAvailableFormatOptions(): array
287+
{
288+
return (new DescriptorHelper())->getFormats();
289+
}
286290
}

0 commit comments

Comments
 (0)