Open
Description
Context
Symfony Console and Annotated Command support negateable options. An example can be found in the Drush cache:rebuild
command which offers the --cache-clear
and --no-cache-clear
options.
Negateable options are expected to be in balance, if --cache-clear
is set (and therefore TRUE), then --no-cache-clear
should be FALSE.
The options documentation describes the behaviour where a default of true
is provided
If the user adds --no-foo on the commandline, then the value of foo will be false.
https://github.com/consolidation/annotated-command#option-default-values
Steps to reproduce
- Create a command class with an option "foo" whose default value is set to TRUE.
- Verify that the
--help
output demonstrates a--foo
and a--no-foo
option. - Run the command with a
--no-foo
parameter.
Expected behavior
Tell us what should happen
- The option value for
--no-foo
(acquired using$input->getOption()
) should be set to TRUE. - The option value for
--foo
(acquired using$input->getOption()
) should be set to FALSE.
Actual behavior
Tell us what happens instead
- ✓ The option value for
--no-foo
(acquired using$input->getOption()
) is set to TRUE. - ❌ The option value for
--foo
(acquired using$input->getOption()
) is also set to TRUE.
System Configuration
Which O.S. and PHP version are you using?
- PHP 8.2.12
- Alpine Linux (container)
Metadata
Metadata
Assignees
Labels
No labels