From 865cda6f7bbb752b6766a1c43e2fe91dbf4eb25a Mon Sep 17 00:00:00 2001
From: Moul <moul@moul.re>
Date: Mon, 5 Jun 2023 22:59:56 +0200
Subject: [PATCH] auth: import top-level click

---
 silkaj/auth.py | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/silkaj/auth.py b/silkaj/auth.py
index f488274d..e913d945 100644
--- a/silkaj/auth.py
+++ b/silkaj/auth.py
@@ -18,7 +18,7 @@ import sys
 from getpass import getpass
 from pathlib import Path
 
-from click import Context, command, confirm, option, pass_context
+import click
 from duniterpy.key import SigningKey
 from duniterpy.key.scrypt_params import ScryptParams
 
@@ -30,8 +30,8 @@ PUBSEC_PUBKEY_PATTERN = f"pub: ({PUBKEY_PATTERN})"
 PUBSEC_SIGNKEY_PATTERN = "sec: ([1-9A-HJ-NP-Za-km-z]{87,90})"
 
 
-@pass_context
-def auth_method(ctx: Context) -> SigningKey:
+@click.pass_context
+def auth_method(ctx: click.Context) -> SigningKey:
     if "AUTH_SEED" in ctx.obj and ctx.obj["AUTH_SEED"]:
         return auth_by_seed()
     if "AUTH_FILE" in ctx.obj and ctx.obj["AUTH_FILE"]:
@@ -41,8 +41,8 @@ def auth_method(ctx: Context) -> SigningKey:
     return auth_by_scrypt()
 
 
-@pass_context
-def has_auth_method(ctx: Context) -> bool:
+@click.pass_context
+def has_auth_method(ctx: click.Context) -> bool:
     return (
         ("AUTH_SCRYPT" in ctx.obj and ctx.obj["AUTH_SCRYPT"])
         or ("AUTH_FILE" in ctx.obj and ctx.obj["AUTH_FILE"])
@@ -51,8 +51,8 @@ def has_auth_method(ctx: Context) -> bool:
     )
 
 
-@command("authentication", help="Generate authentication file")
-@option("--file", default="authfile", show_default=True, help="Path file")
+@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:
     key = auth_method()
     authfile = Path(file)
@@ -60,7 +60,7 @@ def generate_auth_file(file: str) -> None:
     if authfile.is_file():
         message = f"Would you like to erase {file} by an authfile corresponding \n\
 to following pubkey `{pubkey_cksum}`?"
-        confirm(message, abort=True)
+        click.confirm(message, abort=True)
     key.save_seedhex_file(file)
     print(
         f"Authentication file 'authfile' generated and stored in current\
@@ -68,8 +68,8 @@ to following pubkey `{pubkey_cksum}`?"
     )
 
 
-@pass_context
-def auth_by_auth_file(ctx: Context) -> SigningKey:
+@click.pass_context
+def auth_by_auth_file(ctx: click.Context) -> SigningKey:
     """
     Uses an authentication file to generate the key
     Authfile can either be:
@@ -106,8 +106,8 @@ def auth_by_seed() -> SigningKey:
         sys.exit(FAILURE_EXIT_STATUS)
 
 
-@pass_context
-def auth_by_scrypt(ctx: Context) -> SigningKey:
+@click.pass_context
+def auth_by_scrypt(ctx: click.Context) -> SigningKey:
     salt = getpass("Please enter your Scrypt Salt (Secret identifier): ")
     password = getpass("Please enter your Scrypt password (masked): ")
 
-- 
GitLab