Skip to content

Commit 799d22b

Browse files
committed
Fix invalid default value of Choose::one
1 parent 3001e1d commit 799d22b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Component/Interact/Choose.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,16 @@ public static function one(string $description, $options, $default = null, bool
5555
$text .= "\n <info>$key</info>) $value";
5656
}
5757

58-
$defaultText = $default ? "[default:<comment>$default</comment>]" : '';
58+
$defaultText = $default ? "[default:<info>$default</info>]" : '';
5959
Console::write($text);
6060

6161
beginChoice:
6262
$r = Console::readln("Your choice$defaultText : ");
6363

64+
if (empty($r) && $default !== null) {
65+
return $default;
66+
}
67+
6468
// error, allow try again once.
6569
if (!array_key_exists($r, $options)) {
6670
goto beginChoice;

0 commit comments

Comments
 (0)