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()