Added forever loop and way to quit

This commit is contained in:
LunaChocken
2025-06-07 16:54:30 +01:00
parent 7db63e2c7d
commit dd536a5fc4
2 changed files with 14 additions and 6 deletions
+8 -2
View File
@@ -1,5 +1,6 @@
import prompt_toolkit as pt
from prompt_toolkit.completion import WordCompleter, FuzzyCompleter
import sys
def generate_completer(game_list):
g_list = [x['name'] for x in game_list] + [x['appid'] for x in game_list]
@@ -14,16 +15,21 @@ class PromptHelper:
for game in self.game_list:
if game['name'] == game_name:
return game
def find_game_num(self, appid: int):
def find_game_num(self, appid: str):
for game in self.game_list:
if game['appid'] == appid:
return game
print("Game not found")
return None
def prompt_game(self, text, default="None"):
response = pt.prompt(text, completer=self.completer, complete_while_typing=True)
if response == "":
return None
elif response == "q" or response == "quit":
print("Goodbye!")
sys.exit(0)
elif response[0].isalpha():
return self.find_game_str(response)
else:
return self.find_game_num(int(response))
return self.find_game_num(response)