diff --git a/silkaj/cert.py b/silkaj/cert.py index bb519f234f6f60af4868f7862bd9f41b7963f927..17ba70cfc64d8a1d067961a34c4f63684b8e5e80 100644 --- a/silkaj/cert.py +++ b/silkaj/cert.py @@ -16,7 +16,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import sys -from click import command, argument, echo, confirm +import click from time import time from tabulate import tabulate from duniterpy.api import bma @@ -33,8 +33,8 @@ from silkaj.constants import SUCCESS_EXIT_STATUS from silkaj.crypto_tools import is_pubkey_and_check -@command("cert", help="Send certification") -@argument("uid_pubkey_to_certify") +@click.command("cert", help="Send certification") +@click.argument("uid_pubkey_to_certify") @coroutine async def send_certification(uid_pubkey_to_certify): client = ClientInstance().client @@ -144,7 +144,7 @@ async def certification_confirmation( cert_begins = convert_time(time(), "date") cert_ends = convert_time(time() + params["sigValidity"], "date") cert.append(["Valid", cert_begins, "—>", cert_ends]) - echo(tabulate(cert, tablefmt="fancy_grid")) - if not confirm("Do you confirm sending this certification?"): + click.echo(tabulate(cert, tablefmt="fancy_grid")) + if not click.confirm("Do you confirm sending this certification?"): await client.close() sys.exit(SUCCESS_EXIT_STATUS) diff --git a/silkaj/tx.py b/silkaj/tx.py index 2ad42243671a3bcf22b34dee1667f405ebdadd26..837468b896bb4ba976960d6361d6891c0ffa2bd3 100644 --- a/silkaj/tx.py +++ b/silkaj/tx.py @@ -19,7 +19,7 @@ from re import compile, search import math from asyncio import sleep from tabulate import tabulate -from click import command, option, FloatRange +import click from silkaj import cli_tools from silkaj import network_tools as nt @@ -44,37 +44,37 @@ from duniterpy.documents.transaction import OutputSource, Unlock, SIGParameter MAX_COMMENT_LENGTH = 255 -@command("tx", help="Send transaction") -@option( +@click.command("tx", help="Send transaction") +@click.option( "amounts", "--amount", "-a", multiple=True, - type=FloatRange(MINIMAL_ABSOLUTE_TX_AMOUNT), + type=click.FloatRange(MINIMAL_ABSOLUTE_TX_AMOUNT), help="Quantitative amount(s):\n-a <amount>\nMinimum amount is {0}".format( MINIMAL_ABSOLUTE_TX_AMOUNT ), cls=cli_tools.MutuallyExclusiveOption, mutually_exclusive=["amountsud", "allsources"], ) -@option( +@click.option( "amountsud", "--amountUD", "-d", multiple=True, - type=FloatRange(MINIMAL_RELATIVE_TX_AMOUNT), + type=click.FloatRange(MINIMAL_RELATIVE_TX_AMOUNT), help=f"Relative amount(s):\n-d <amount_UD>\nMinimum amount is {MINIMAL_RELATIVE_TX_AMOUNT}", cls=cli_tools.MutuallyExclusiveOption, mutually_exclusive=["amounts", "allsources"], ) -@option( +@click.option( "--allSources", is_flag=True, help="Send all sources to one recipient", cls=cli_tools.MutuallyExclusiveOption, mutually_exclusive=["amounts", "amountsud"], ) -@option( +@click.option( "recipients", "--recipient", "-r", @@ -85,15 +85,23 @@ Sending to many recipients is possible:\n\ * With one amount, all will receive the amount\n\ * With many amounts (one per recipient)", ) -@option("--comment", "-c", default="", help="Comment") -@option( +@click.option("--comment", "-c", default="", help="Comment") +@click.option( "--outputBackChange", help="Pubkey recipient to send the rest of the transaction: <pubkey[:checksum]>", ) -@option("--yes", "-y", is_flag=True, help="Assume yes. Do not prompt confirmation") +@click.option( + "--yes", "-y", is_flag=True, help="Assume yes. Do not prompt confirmation" +) @tools.coroutine async def send_transaction( - amounts, amountsud, allsources, recipients, comment, outputbackchange, yes + amounts, + amountsud, + allsources, + recipients, + comment, + outputbackchange, + yes, ): """ Main function