Fix config wizard

This commit is contained in:
Thomas Sileo 2022-07-04 20:25:27 +02:00
parent d18bf7c7d5
commit dfa6b6de3c
5 changed files with 20 additions and 25 deletions

View file

@ -10,22 +10,24 @@ from markdown import markdown # type: ignore
from prompt_toolkit import prompt
from app.key import generate_key
from app.key import key_exists
_ROOT_DIR = Path().parent.resolve()
_KEY_PATH = _ROOT_DIR / "data" / "key.pem"
def main() -> None:
print("Welcome to microblog.pub setup wizard\n")
print("Generating key...")
if key_exists():
if _KEY_PATH.exists():
yn = ""
while yn not in ["y", "n"]:
yn = prompt(
"WARNING, a key already exists, overwrite it? (y/n): ", default="n"
).lower()
if yn == "y":
generate_key()
generate_key(_KEY_PATH)
else:
generate_key()
generate_key(_KEY_PATH)
config_file = Path("data/me.toml")