beer_data/src/flask/add_user.py
Andrew Ridgway 56ff1a7247
All checks were successful
Build and Push Image / Build and push image (push) Has been skipped
fix up to get running and some feature add
2024-09-11 05:45:21 +00:00

30 lines
886 B
Python

import os
import click
import mongo.user_db as user_db
@click.command()
@click.option('--username', type=str, help="Username to be added or updated")
@click.option('--password', type=str, help="Password to be added or updated")
def main(username, password):
"""
little cli program to update the
user table in mongo
this rightly should eventually be
and admin tool but right now this will dow
"""
user_collection = user_db.user_data()
new_record = {
"username" : f"{username}",
"password" : f"{password}"
}
if user_collection.user_exists(new_record["username"]):
user_collection.update_user(user_collection.existing_record["_id"], new_record["password"])
else:
user_collection.add_user(new_record["username"], new_record["password"])
if __name__ == "__main__":
main()