Merge pull request 'clan_cli: create key directory' (#521) from a-kenji-mkdir/clan/cli into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/521
This commit is contained in:
lassulus
2023-11-16 11:18:33 +00:00

View File

@@ -10,6 +10,8 @@ def generate_key() -> str:
if path.exists(): if path.exists():
raise ClanError(f"Key already exists at {path}") raise ClanError(f"Key already exists at {path}")
priv_key, pub_key = generate_private_key() priv_key, pub_key = generate_private_key()
if not (parent := path.parent).exists():
parent.mkdir(parents=True, exist_ok=True)
path.write_text(priv_key) path.write_text(priv_key)
return pub_key return pub_key