From 713949d35f8b6e7caa3f66620eb90350fce5afb6 Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Fri, 14 Oct 2022 16:36:19 +0200 Subject: [PATCH] added an interactive demo --- src/metadata.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/metadata.py b/src/metadata.py index cfd5b5b..a066f7e 100644 --- a/src/metadata.py +++ b/src/metadata.py @@ -180,6 +180,24 @@ def automated_demo(): print(search.get_previous_options()) print(search.choose(6)) +def interactive_demo(): + search = Search(query=input("initial query: ")) + print(search.options) + while True: + input_ = input("q to quit, .. for previous options, . for current options, int for this element: ").lower() + input_.strip() + if input_ == "q": + break + if input_ == ".": + print(search.options) + continue + if input_ == "..": + print(search.get_previous_options()) + continue + if input_.isdigit(): + print(search.choose(int(input_))) + continue + if __name__ == "__main__": - automated_demo() + interactive_demo()