Skip to content

Commit

Permalink
Validate command option length
Browse files Browse the repository at this point in the history
  • Loading branch information
DumitracheAdrian committed Aug 27, 2024
1 parent 05acdff commit 3ef15b1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/console/Command/GenerateDocumentationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function configure(): void
$this
->setDescription('Generate a documentation for all the command of the application.')
->addArgument('path', InputArgument::REQUIRED, 'The path where the documentation will be generated.')
->addOption('format', null, InputArgument::OPTIONAL, 'The format of the documentation (txt|md|json|xml).', 'txt');
->addOption('format', 'f', InputArgument::OPTIONAL, 'The format of the documentation (txt|md|json|xml).', 'txt');
}

protected function execute(InputInterface $input, OutputInterface $output): int
Expand Down
4 changes: 4 additions & 0 deletions packages/tester/Application/CommandTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public function testOptions(): void
$definition = $command->getDefinition();
$realCommandOptions = [];
foreach ($definition->getOptions() as $option) {
if (null !== $shortcut = $option->getShortcut()) {
TestCase::assertEquals(1, \strlen($shortcut));
}

$realCommandOptions[$option->getName()] = $option;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Console/Command/GenerateDocumentationCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function provideTestOption(): iterable
{
yield [
'format',
null,
'f',
InputOption::VALUE_REQUIRED,
'txt',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Arguments:
path The path where the documentation will be generated.

Options:
--format=FORMAT The format of the documentation (txt|md|json|xml). [default: "txt"]
-f, --format=FORMAT The format of the documentation (txt|md|json|xml). [default: "txt"]
--aws-newest-instance-role=AWS-NEWEST-INSTANCE-ROLE The instance role the server must be the newest of to run the command.
--draw-execution-id=DRAW-EXECUTION-ID The existing execution id of the command. Use internally by the DrawCommandBundle.
--draw-execution-ignore Flag to ignore login of the execution to the databases.
Expand Down

0 comments on commit 3ef15b1

Please sign in to comment.