Skip to content

Commit ff6d684

Browse files
bug #60914 [Console] Fix command option mode (InputOption::VALUE_REQUIRED) (gharlan)
This PR was merged into the 6.4 branch. Discussion ---------- [Console] Fix command option mode (InputOption::VALUE_REQUIRED) | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no <!-- if yes, also update src/**/CHANGELOG.md --> | Deprecations? | no <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md --> | Issues | <!-- prefix each issue number with "Fix #"; no need to create an issue if none exists, explain below --> | License | MIT I think in all given cases it was a mistake to use `InputOption::VALUE_OPTIONAL` instead of `InputOption::VALUE_REQUIRED`. It is a common mistake to think that you have to use `VALUE_OPTIONAL` to make the option optional. But options are always optional. 😉 Commits ------- dde6dfa Fix command option mode (InputOption::VALUE_REQUIRED)
2 parents 6265ba0 + dde6dfa commit ff6d684

File tree

8 files changed

+18
-18
lines changed

8 files changed

+18
-18
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function configure(): void
7979
->setDefinition([
8080
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
8181
new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages'),
82-
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'The messages domain'),
82+
new InputOption('domain', null, InputOption::VALUE_REQUIRED, 'The messages domain'),
8383
new InputOption('only-missing', null, InputOption::VALUE_NONE, 'Display only missing messages'),
8484
new InputOption('only-unused', null, InputOption::VALUE_NONE, 'Display only unused messages'),
8585
new InputOption('all', null, InputOption::VALUE_NONE, 'Load messages from all registered bundles'),

src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ protected function configure(): void
8484
->setDefinition([
8585
new InputArgument('locale', InputArgument::REQUIRED, 'The locale'),
8686
new InputArgument('bundle', InputArgument::OPTIONAL, 'The bundle name or directory where to load the messages'),
87-
new InputOption('prefix', null, InputOption::VALUE_OPTIONAL, 'Override the default prefix', '__'),
88-
new InputOption('format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format', 'xlf12'),
87+
new InputOption('prefix', null, InputOption::VALUE_REQUIRED, 'Override the default prefix', '__'),
88+
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'Override the default output format', 'xlf12'),
8989
new InputOption('dump-messages', null, InputOption::VALUE_NONE, 'Should the messages be dumped in the console'),
9090
new InputOption('force', null, InputOption::VALUE_NONE, 'Should the extract be done'),
9191
new InputOption('clean', null, InputOption::VALUE_NONE, 'Should clean not found messages'),
92-
new InputOption('domain', null, InputOption::VALUE_OPTIONAL, 'Specify the domain to extract'),
92+
new InputOption('domain', null, InputOption::VALUE_REQUIRED, 'Specify the domain to extract'),
9393
new InputOption('sort', null, InputOption::VALUE_OPTIONAL, 'Return list of messages sorted alphabetically (only works with --dump-messages)', 'asc'),
94-
new InputOption('as-tree', null, InputOption::VALUE_OPTIONAL, 'Dump the messages as a tree-like structure: The given value defines the level where to switch to inline YAML'),
94+
new InputOption('as-tree', null, InputOption::VALUE_REQUIRED, 'Dump the messages as a tree-like structure: The given value defines the level where to switch to inline YAML'),
9595
])
9696
->setHelp(<<<'EOF'
9797
The <info>%command.name%</info> command extracts translation strings from templates

src/Symfony/Component/Mailer/Command/MailerTestCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ protected function configure(): void
3535
{
3636
$this
3737
->addArgument('to', InputArgument::REQUIRED, 'The recipient of the message')
38-
->addOption('from', null, InputOption::VALUE_OPTIONAL, 'The sender of the message', 'from@example.org')
39-
->addOption('subject', null, InputOption::VALUE_OPTIONAL, 'The subject of the message', 'Testing transport')
40-
->addOption('body', null, InputOption::VALUE_OPTIONAL, 'The body of the message', 'Testing body')
41-
->addOption('transport', null, InputOption::VALUE_OPTIONAL, 'The transport to be used')
38+
->addOption('from', null, InputOption::VALUE_REQUIRED, 'The sender of the message', 'from@example.org')
39+
->addOption('subject', null, InputOption::VALUE_REQUIRED, 'The subject of the message', 'Testing transport')
40+
->addOption('body', null, InputOption::VALUE_REQUIRED, 'The body of the message', 'Testing body')
41+
->addOption('transport', null, InputOption::VALUE_REQUIRED, 'The transport to be used')
4242
->setHelp(<<<'EOF'
4343
The <info>%command.name%</info> command tests a Mailer transport by sending a simple email message:
4444

src/Symfony/Component/Messenger/Command/FailedMessagesRemoveCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function configure(): void
3535
new InputArgument('id', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'Specific message id(s) to remove'),
3636
new InputOption('all', null, InputOption::VALUE_NONE, 'Remove all failed messages from the transport'),
3737
new InputOption('force', null, InputOption::VALUE_NONE, 'Force the operation without confirmation'),
38-
new InputOption('transport', null, InputOption::VALUE_OPTIONAL, 'Use a specific failure transport', self::DEFAULT_TRANSPORT_OPTION),
38+
new InputOption('transport', null, InputOption::VALUE_REQUIRED, 'Use a specific failure transport', self::DEFAULT_TRANSPORT_OPTION),
3939
new InputOption('show-messages', null, InputOption::VALUE_NONE, 'Display messages before removing it (if multiple ids are given)'),
4040
])
4141
->setHelp(<<<'EOF'

src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function configure(): void
6363
->setDefinition([
6464
new InputArgument('id', InputArgument::IS_ARRAY, 'Specific message id(s) to retry'),
6565
new InputOption('force', null, InputOption::VALUE_NONE, 'Force action without confirmation'),
66-
new InputOption('transport', null, InputOption::VALUE_OPTIONAL, 'Use a specific failure transport', self::DEFAULT_TRANSPORT_OPTION),
66+
new InputOption('transport', null, InputOption::VALUE_REQUIRED, 'Use a specific failure transport', self::DEFAULT_TRANSPORT_OPTION),
6767
])
6868
->setHelp(<<<'EOF'
6969
The <info>%command.name%</info> retries message in the failure transport.

src/Symfony/Component/Messenger/Command/FailedMessagesShowCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function configure(): void
3535
->setDefinition([
3636
new InputArgument('id', InputArgument::OPTIONAL, 'Specific message id to show'),
3737
new InputOption('max', null, InputOption::VALUE_REQUIRED, 'Maximum number of messages to list', 50),
38-
new InputOption('transport', null, InputOption::VALUE_OPTIONAL, 'Use a specific failure transport', self::DEFAULT_TRANSPORT_OPTION),
38+
new InputOption('transport', null, InputOption::VALUE_REQUIRED, 'Use a specific failure transport', self::DEFAULT_TRANSPORT_OPTION),
3939
new InputOption('stats', null, InputOption::VALUE_NONE, 'Display the message count by class'),
4040
new InputOption('class-filter', null, InputOption::VALUE_REQUIRED, 'Filter by a specific class name'),
4141
])

src/Symfony/Component/Translation/Command/TranslationPullCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ protected function configure(): void
9292
new InputArgument('provider', null !== $defaultProvider ? InputArgument::OPTIONAL : InputArgument::REQUIRED, 'The provider to pull translations from.', $defaultProvider),
9393
new InputOption('force', null, InputOption::VALUE_NONE, 'Override existing translations with provider ones (it will delete not synchronized messages).'),
9494
new InputOption('intl-icu', null, InputOption::VALUE_NONE, 'Associated to --force option, it will write messages in "%domain%+intl-icu.%locale%.xlf" files.'),
95-
new InputOption('domains', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Specify the domains to pull.'),
96-
new InputOption('locales', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Specify the locales to pull.'),
97-
new InputOption('format', null, InputOption::VALUE_OPTIONAL, 'Override the default output format.', 'xlf12'),
98-
new InputOption('as-tree', null, InputOption::VALUE_OPTIONAL, 'Write messages as a tree-like structure. Needs --format=yaml. The given value defines the level where to switch to inline YAML'),
95+
new InputOption('domains', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Specify the domains to pull.'),
96+
new InputOption('locales', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Specify the locales to pull.'),
97+
new InputOption('format', null, InputOption::VALUE_REQUIRED, 'Override the default output format.', 'xlf12'),
98+
new InputOption('as-tree', null, InputOption::VALUE_REQUIRED, 'Write messages as a tree-like structure. Needs --format=yaml. The given value defines the level where to switch to inline YAML'),
9999
])
100100
->setHelp(<<<'EOF'
101101
The <info>%command.name%</> command pulls translations from the given provider. Only

src/Symfony/Component/Translation/Command/TranslationPushCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ protected function configure(): void
8383
new InputArgument('provider', null !== $defaultProvider ? InputArgument::OPTIONAL : InputArgument::REQUIRED, 'The provider to push translations to.', $defaultProvider),
8484
new InputOption('force', null, InputOption::VALUE_NONE, 'Override existing translations with local ones (it will delete not synchronized messages).'),
8585
new InputOption('delete-missing', null, InputOption::VALUE_NONE, 'Delete translations available on provider but not locally.'),
86-
new InputOption('domains', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Specify the domains to push.'),
87-
new InputOption('locales', null, InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Specify the locales to push.', $this->enabledLocales),
86+
new InputOption('domains', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Specify the domains to push.'),
87+
new InputOption('locales', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Specify the locales to push.', $this->enabledLocales),
8888
])
8989
->setHelp(<<<'EOF'
9090
The <info>%command.name%</> command pushes translations to the given provider. Only new

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy