Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate command option length #291

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions 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 All @@ -58,7 +58,7 @@ function () use ($filePath): void {
}
);

$this->execute(['path' => $filePath])
$this->execute(['path' => $filePath, '-f' => 'txt'])
->test(
CommandDataTester::create()
->setExpectedDisplay([
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
Loading