forked from 5nonymous/money-for-rabbit-back
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.py
27 lines (22 loc) · 714 Bytes
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from sqlite3 import IntegrityError
import click
from flask.cli import with_appcontext
from pymysql import IntegrityError
from api.models.user import UserModel
@click.command(name="createadminuser")
@with_appcontext
def create_admin_user():
username = input("Enter username : ")
email = input("Enter email : ")
password = input("Enter password : ")
try:
superuser = UserModel(
username=username,
email=email,
password=password,
email_confirmed=True,
is_admin=True,
).create_user()
except IntegrityError:
print("\033[31m" + "Error : username or email already exists.")
print(f"User created! : {email}")