Closed tacman closed 1 year ago
When using the standard symfony syntax, is there a way to display the default? If not, we should add upstream.
I also don't think negatable options are intended to have a non null default. I believe the intention is if it hasn't been set, it's null, detect the default from another source. In your example above, there's no way for the value of those options to be null. I think you'd be better off not using the negatable options.
Hmm. I have lots of these options, and depending on where I am in the development cycle, I turn on and off the defaults. And these scripts (processing specific sets of data) are in turned called by another script, which also turns on and off the options (download, refresh-cache, process, validate, translate, etc.), so it's nice to simply prepend the "no-" when I want to explicitly turn off an option, rather than not passing the option if it's to be turned off.
It seems like I should be able to have it all -- indeed, it works while setting a default, it just doesn't display the default value in the help.
Ok, fair enough. Then let's confirm symfony console does indeed show these defaults. If so, I think we need to change something here: https://github.com/zenstruck/console-extra/blob/87c43ae871436ff93123434ae3d7619b9d0ff3c8/src/Attribute/Option.php#L69
For instance, if you remove $value->mode ^ InputOption::VALUE_NONE
from that if statement, does the default show?
Alas, no. :-(
I got this error:
Cannot set a default value when using InputOption::VALUE_NONE mode.
A quick check tells me it isn't possible for a negatable option to display the default. You could try and suggest this upstream in Symfony.
Thanks.
I have 3 nullable (negatable) boolean options defined:
I like having the ability to prefix with --no-
How I can configure this so that the default value is displayed in the help?