Add Question.multiline and associated handling
[quizzer.git] / quizzer / ui / cli.py
index 513fddc2dac67f09c061a3cfd36f92beef496ede..d6590409eddfd415a4fe687f71c2d21593865ef6 100644 (file)
@@ -13,6 +13,8 @@ class CommandLineInterface (UserInterface):
             if not question:
                 break
             print(question.prompt)
+            if question.multiline:
+                answers = []
             while True:
                 try:
                     answer = input('? ')
@@ -27,7 +29,14 @@ class CommandLineInterface (UserInterface):
                     print(question.prompt)
                     print(question.help)
                     continue
-                break
+                if question.multiline:
+                    answers.append(answer)
+                    if not a:
+                        break
+                else:
+                    break
+            if question.multiline:
+                answer = answers
             correct = self.process_answer(question=question, answer=answer)
             if correct:
                 print('correct\n')