Exemple #1
0
def main():
    # Install the argument parser. Initiate the description with the docstring
    argparser = argparse.ArgumentParser(description=sys.modules[__name__].__doc__)
    argparser.add_argument(
        "--generate-database", action="store_true", help="Generate the databases"  # This is a binary option
    )
    argparser.add_argument(
        "--generate-keys", action="store_true", help="Generate the keys"  # This is also a binary option
    )
    argparser.add_argument(
        "--sign-key", help="sign the specified key"  # this is a option which need one extra argument
    )
    argparser.add_argument(
        "--deposit",  # this is a option which need one extra argument
        nargs=3,
        metavar=("SIGNED_CHECK.JSON", "CUSTOMER.PUBKEY", "BANK.KEY"),
        help="deposit a check",
    )
    arguments = argparser.parse_args()

    # Now do things depending of the collected arguments
    if arguments.generate_database:
        generate_database("bank.db")
    if arguments.generate_keys:
        save_rsa_keys("bank.pubkey", "bank.key")
    if arguments.sign_key:
        print(sign_key(arguments.sign_key).decode())
    if arguments.deposit:
        deposit(arguments.deposit)