-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
Description
I'd like to have console option behaving in this way:
#1. The option is not used at all, so don't use any value of it
./app.php command
#2. Use default value of the option
./app.php command --myoption
#3. Use custom value of the option
./app.php command --myoption=myvalue
However, as far as I know, there is currently not a clean way how to do it - because if you define default value for your option, then using $input->getOption('myoption')
you will get the default value even for the case 1. (= even if the option was not passed at all).
The real-world use case is that I have an option, that is not always needed, but when you use it, you need in 95% of cases the same value (smart default), but for the remaining edge cases you must have an ability how to override the default.
This was already suggested with some workaround in issue #8135 (comment), but this issue was primarily about different topic, so I am creating a separate issue for this.