-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Added three state long option #11883
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
Conversation
|
||
private $name; | ||
private $shortcut; | ||
private $mode; | ||
private $default; | ||
private $set_default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the difference with $default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$default is the 'true' default value when a long option is not defined. It will always be set to false for long_options with VALUE_OPTIONULL. Just like it will always be set to false for VALUE_NONE. $set_default is the default used when an option is used but doesn't have a value set (i.e. --dev).
The problem is that InputOption is unaware of which default to use ('foo' vs 'foo --dev' vs 'foo --dev=bar') because it doesn't know the arguments the user passed.
Which resulted in me adding some smarts to InputDefinition to determine which 'default' to use. Which in turn means I need to keep both 'defaults' in InputOption.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it should be written somewhere, the difference has to be clearly defined in the docblocks of the setters.
anyone with a better name ? |
|
- renamed to camelCase setDefault
* Sets the default value. | ||
* | ||
* For VALUE_TERNARY the $default will always be set to false (for when the longoption is not used) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing space: long option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw, why talking about long option here ? It is true for shortcuts too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh ok, I'll fix that
Tests are missing for this feature |
Yes. I will start writing the tests now :-) |
I don't like |
Good point. I will change that. I'm also not very happy with the current description that I added. |
Personally, I prefer solution from this PR: #12773. It could be used for the same use-case, but it has minimal impact on other code. The only disadvantage is that it may not be as straightforward as using dedicated option type. Example usage: #12769 (comment) |
I leave it up to you guys to decide what's best. I think my solution works great, the tests show it works, but it obviously involves more code changes. It's there for you guys to use, or not. |
Hi guys, looking forward for this to be merged, i just start using Console and ran directly into this problem :s |
any news here? The PR: #12769 is closed |
Closing as #12773 make it work without having to add another configuration setting. |
[Console] Added three state long option
A three state long option, instead of the current 2 state version:
Let's say --dev
A couple of notes: