Skip to content

Commit f1c58df

Browse files
Purifier Html, Dev and confirm CLI fix
1 parent b7480b2 commit f1c58df

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/Capsule/CommandHelper.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,14 +338,23 @@ protected function extractTableName($migration = null)
338338
*/
339339
protected function confirm(string $question, bool $default = false): bool
340340
{
341-
$yesNo = $default ? 'y/n' : 'Y/N';
342-
$answer = readline("{$question} ({$yesNo}): ");
341+
$yesNo = $default ? 'y/n' : 'Y/N';
342+
343+
while (true) {
344+
$answer = readline("{$question} ({$yesNo}): ");
343345

344-
if (empty($answer)) {
345-
return $default;
346-
}
346+
if (!empty($answer)) {
347+
$answer = Str::lower(trim($answer));
348+
349+
if (in_array($answer, ['y', 'yes'], true)) {
350+
return true;
351+
}
347352

348-
return in_array(Str::lower($answer), ['y', 'yes'], true);
353+
if (in_array($answer, ['n', 'no'], true)) {
354+
return false;
355+
}
356+
}
357+
}
349358
}
350359

351360
/**

0 commit comments

Comments
 (0)