diff --git a/alla.py b/alla.py index 578241c..d84858c 100755 --- a/alla.py +++ b/alla.py @@ -134,11 +134,19 @@ if __name__ == '__main__': data = read_file(cfg) # Open the data file if not args.site: # Show a menu if no input - menu(data) - site = input("Key #: ") - if site: - print_OTP(data[site-1]["secret"]) # -1 since index start with 0 and the menu with 1 - exit(0) + while True: + menu(data) + site = raw_input("Key #: ") + try: + site = int(site) + except: + print("Enter a number, not text.") + + if site > len(data): + raw_input("Incorrect menu choice, press Enter to try again") + else: + print_OTP(data[site-1]["secret"]) # -1 since index start with 0 and the menu with 1 + exit(0) for p in data: # Try to find a matching site if p["label"].strip().lower() == args.site[0].lower():