added while loop for top level config menu, updated delete question to standard we are using

This commit is contained in:
2022-09-06 20:39:56 -04:00
parent 7d9e4fa428
commit 5958bfdd55

View File

@@ -113,44 +113,46 @@ if __name__ == "__main__":
sys.exit(0)
else:
print("This value must be one of the following characters: n, q.")
config = configparser.ConfigParser()
config.read(secrets_ini_file)
accounts = config.sections()
print("Current Bitwarden accounts:")
for account in accounts:
print(account)
print(" ")
print("e) Edit account")
print("n) New account")
print("d) Delete account")
print("q) Quit config")
while True:
user_input = input("e/n/d/q> ")
if user_input.casefold() == "e":
print("")
elif user_input.casefold() == "n":
account_details = ask_for_account_details()
config.add_section(account_details["account_email_address"])
for key in account_details.keys():
if not key == "account_email_address":
config.set(account_details["account_email_address"], key, account_details[key])
with open(secrets_ini_file, "w") as configfile:
config.write(configfile)
break
elif user_input.casefold() == "d":
account_section_to_delete = select_account(accounts, "delete")
confirmation = input("Are you sure you wish to delete {} account?".format(account_section_to_delete))
if not confirmation.casefold() in ["y","yes"]:
config = configparser.ConfigParser()
config.read(secrets_ini_file)
accounts = config.sections()
print("Current Bitwarden accounts:")
print(" ")
for account in accounts:
print(account)
print(" ")
print("e) Edit account")
print("n) New account")
print("d) Delete account")
print("q) Quit config")
while True:
user_input = input("e/n/d/q> ")
if user_input.casefold() == "e":
account_section_to_edit = select_account(accounts)
elif user_input.casefold() == "n":
account_details = ask_for_account_details()
config.add_section(account_details["account_email_address"])
for key in account_details.keys():
if not key == "account_email_address":
config.set(account_details["account_email_address"], key, account_details[key])
with open(secrets_ini_file, "w") as configfile:
config.write(configfile)
break
config.remove_section(account_section_to_delete)
with open(secrets_ini_file, "w") as configfile:
config.write(configfile)
break
elif user_input.casefold() == "q":
sys.exit(0)
else:
print("This value must be one of the following characters: e, n, d, q.")
elif user_input.casefold() == "d":
account_section_to_delete = select_account(accounts, "delete")
print("Are you sure you wish to delete {} account? ".format(account_section_to_delete))
confirmation = input("y/n> ")
if not confirmation.casefold() in ["y","yes"]:
break
config.remove_section(account_section_to_delete)
with open(secrets_ini_file, "w") as configfile:
config.write(configfile)
break
elif user_input.casefold() == "q":
sys.exit(0)
else:
print("This value must be one of the following characters: e, n, d, q.")
sys.exit(0)