Assume that a book with >3 stars was always finished
authorAlex Chan <alex@alexwlchan.net>
Sun, 2 Feb 2020 23:28:37 +0000 (23:28 +0000)
committerAlex Chan <alex@alexwlchan.net>
Sun, 2 Feb 2020 23:28:37 +0000 (23:28 +0000)
scripts/add_book.py

index 134709b..a32de96 100755 (executable)
@@ -86,21 +86,32 @@ def get_review_info():
             choices=["★★★★★", "★★★★☆", "★★★☆☆", "★★☆☆☆", "★☆☆☆☆"],
         ),
         inquirer.Text("format", message="What format did you read it in?"),
-        inquirer.List(
-            "did_you_finish", message="Did you finish the book?", choices=["yes", "no"]
-        ),
     ]
 
     answers = inquirer.prompt(other_questions)
+    format = answers["format"]
 
     rating = int(answers["rating"].count("★"))
     assert 1 <= rating <= 5
 
+    if rating > 3:
+        did_not_finish = False
+    else:
+        questions = [
+            inquirer.List(
+                "did_you_finish",
+                message="Did you finish the book?",
+                choices=["yes", "no"],
+            ),
+        ]
+
+        answers["did_you_finish"] = inquirer.prompt(questions)["did_you_finish"] == "no"
+
     return {
         "date_read": date_read,
         "rating": rating,
-        "format": answers["format"],
-        "did_not_finish": answers["did_you_finish"] == "no",
+        "format": format,
+        "did_not_finish": did_not_finish,
     }