From 430c6131ea832dbd484d4b04e9847d23281da51e Mon Sep 17 00:00:00 2001 From: dvnc0 Date: Sat, 26 Aug 2023 01:06:27 -0400 Subject: [PATCH] edit for single answer mc --- src/App/Tools/Input.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/App/Tools/Input.php b/src/App/Tools/Input.php index e3e5647..3391f3c 100644 --- a/src/App/Tools/Input.php +++ b/src/App/Tools/Input.php @@ -159,6 +159,12 @@ public function multipleChoice(string $message, array $options, $default = [], $ break; case "\n": // enter $out = []; + if ($single_answer_only) { + $out[] = $options[$index]; + fclose($stdin); + system('stty sane'); + return $out; + } foreach ($selected as $key) { $out[] = $options[$key]; } @@ -168,9 +174,7 @@ public function multipleChoice(string $message, array $options, $default = [], $ case " ": // space if ($single_answer_only) { $out = []; - foreach ($selected as $key) { - $out[] = $options[$key]; - } + $out[] = $options[$index]; fclose($stdin); system('stty sane'); return $out;