-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Console] Added the ability to return the default answer in a question #11975
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ class Question | |
| private $autocompleterValues; | ||
| private $validator; | ||
| private $default; | ||
| private $showDefault = false; | ||
| private $normalizer; | ||
|
|
||
| /** | ||
|
|
@@ -46,6 +47,10 @@ public function __construct($question, $default = null) | |
| */ | ||
| public function getQuestion() | ||
| { | ||
| if ($this->showDefault) { | ||
| return sprintf('%s [%s]', $this->question, $this->default); | ||
| } | ||
|
|
||
| return $this->question; | ||
| } | ||
|
|
||
|
|
@@ -59,6 +64,20 @@ public function getDefault() | |
| return $this->default; | ||
| } | ||
|
|
||
| /** | ||
| * Sets whether the default answer should be shown to the user in the question | ||
| * | ||
| * @param bool $showDefault | ||
| * | ||
| * @return Question The current instance | ||
| */ | ||
| public function setShowDefault($showDefault) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about setting a default of true?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if we should be more explicit and require true to be passed. Another opinion please?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wouterj You mean line 28 not the method parameter, don't you? |
||
| { | ||
| $this->showDefault = (bool) $showDefault; | ||
|
|
||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Returns whether the user response must be hidden. | ||
| * | ||
|
|
||
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.
Thinking about usability, should the default be shown by default?