Skip to content
Snippets Groups Projects
Commit 4daefaba authored by Moul's avatar Moul
Browse files

v1 authentication: stop reading default './authfile' (#420)

It has to be specified as an argument and no longer as an option
Pass Path directly (#469)
Rename variable
parent 4df5d044
No related branches found
No related tags found
1 merge request!240Drop auth-file default path #420, Use click.prompt(), click_context testing
Pipeline #32455 passed
......@@ -51,19 +51,20 @@ def has_auth_method(ctx: click.Context) -> bool:
@click.command("authentication", help="Generate authentication file")
@click.option("--file", default="authfile", show_default=True, help="Path file")
def generate_auth_file(file: str) -> None:
@click.argument(
"auth_file",
type=click.Path(dir_okay=False, writable=True, path_type=Path),
)
def generate_auth_file(auth_file: Path) -> None:
key = auth_method()
authfile = Path(file)
pubkey_cksum = gen_pubkey_checksum(key.pubkey)
if authfile.is_file():
message = f"Would you like to erase {file} by an authfile corresponding \n\
if auth_file.is_file():
message = f"Would you like to erase {auth_file} with an authentication file corresponding \n\
to following pubkey `{pubkey_cksum}`?"
click.confirm(message, abort=True)
key.save_seedhex_file(file)
key.save_seedhex_file(auth_file)
print(
f"Authentication file 'authfile' generated and stored in current\
folder for following public key: {pubkey_cksum}",
f"Authentication file '{auth_file}' generated and stored for public key: {pubkey_cksum}",
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment