add hint to use --force when a key already exists

This commit is contained in:
Jörg Thalheim 2024-03-22 16:33:32 +01:00
parent bc75c637ef
commit cd9db02db0

View File

@ -202,7 +202,7 @@ def write_key(path: Path, publickey: str, overwrite: bool) -> None:
flags |= os.O_EXCL flags |= os.O_EXCL
fd = os.open(path / "key.json", flags) fd = os.open(path / "key.json", flags)
except FileExistsError: except FileExistsError:
raise ClanError(f"{path.name} already exists in {path}") raise ClanError(f"{path.name} already exists in {path}. Use --force to overwrite.")
with os.fdopen(fd, "w") as f: with os.fdopen(fd, "w") as f:
json.dump({"publickey": publickey, "type": "age"}, f, indent=2) json.dump({"publickey": publickey, "type": "age"}, f, indent=2)