-
Notifications
You must be signed in to change notification settings - Fork 3
/
manage.py
45 lines (32 loc) · 952 Bytes
/
manage.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import subprocess # nosec
import typer
import uvicorn
from core.settings import settings
cmd = typer.Typer(no_args_is_help=True)
@cmd.command(name="run")
def run():
"""run application"""
uvicorn.run(
app="app.main:app", reload=True, port=settings.APP_PORT, host=settings.APP_HOST
)
@cmd.command(name="migrate")
def migrate():
process = subprocess.Popen(
["alembic", "upgrade", "head"], stdout=subprocess.PIPE, shell=False
) # nosec
print(process.communicate()[0])
@cmd.command(name="makemigrations")
def makemigrations(
msg: str = typer.Option("autogenerate", "--msg", "-m", help="message")
):
process = subprocess.Popen(
["alembic", "revision", "--autogenerate", "-m", f"{msg}"],
stdout=subprocess.PIPE,
shell=False,
) # nosec
print(process.communicate()[0])
@cmd.command(name="createuser")
def createuser():
pass
if __name__ == "__main__":
cmd()