-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add failing test regarding missing input #78
base: master
Are you sure you want to change the base?
Conversation
Added my attempt of fixing it. |
Pondered some more, the obvious solution is to check if the option is VALUE_NONE and handle that. See the latest revision. It should make sense, the tests are passing and InspectableArgvInput can be removed. |
The code below works as well. The issue with the bug is that we set all arguments and options in the Interestingly enough, I looked at the code of
Here's a fix that makes your test pass without having to use the public function merge(InputInterface $input, Configuration $config)
{
foreach ($input->getArguments() as $argument => $value) {
if ($input->hasArgumentSet($argument)) {
$config->set($argument, $value);
} else {
$value = $config->get($argument);
if ($value) {
$input->setArgument($argument, $value);
}
}
}
foreach ($input->getOptions() as $option => $value) {
if ($input->hasOptionSet($option)) {
$config->set($option, $value);
} else {
$value = $config->get($option);
if ($value) {
$input->setOption($option, $value);
}
}
}
} Edit: I just saw your second commit is exactly this code. I guess it doesn't cover all cases? (at least it covers the one given in the test...) |
The 2nd commit is OK, however the 3rd should be more clear. It's checking for the actual root cause instead of using InspectableArgvInput to get around the existing behaviour. IMO you should clearly define the desired behaviour first. "Overriding VALUE_NONE options" is tricky in itself. IMO they should simply not be used as it's confusing: I can NOT override a VALUE_NONE from the CLI the way we want to use it with Configuration. Not the first time there's confusion surrounding symfony/console arguments/options though :/ |
I'm not sure I'm following you. Can't a InputOption::VALUE_NONE be set to true/false, thus allowing us to override them via the configuration? If not, could you provide an example/test case? |
Sadly this reopens #75
Given no configuration and no CLI input, Symfony will happily validate the InputDefinition.
Caused by removing the
array_filter
usingis_null
while fixing the InputOption>config issue.