remove asyncclick
This commit is contained in:
@@ -1 +1 @@
|
||||
__version__ = "0.2.4"
|
||||
__version__ = "0.2.5"
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from configparser import ConfigParser
|
||||
from functools import wraps
|
||||
|
||||
import asyncclick as click
|
||||
from asyncclick import Context, UsageError
|
||||
import click
|
||||
from click import Context, UsageError
|
||||
from tortoise import Tortoise, generate_schema_for_client
|
||||
from tortoise.exceptions import OperationalError
|
||||
from tortoise.transactions import in_transaction
|
||||
@@ -20,6 +22,14 @@ from .models import Aerich
|
||||
parser = ConfigParser()
|
||||
|
||||
|
||||
def coro(f):
|
||||
@wraps(f)
|
||||
def wrapper(*args, **kwargs):
|
||||
return asyncio.run(f(*args, **kwargs))
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
@click.group(context_settings={"help_option_names": ["-h", "--help"]})
|
||||
@click.version_option(__version__, "-V", "--version")
|
||||
@click.option(
|
||||
@@ -34,6 +44,7 @@ parser = ConfigParser()
|
||||
help="Name of section in .ini file to use for aerich config.",
|
||||
)
|
||||
@click.pass_context
|
||||
@coro
|
||||
async def cli(ctx: Context, config, app, name):
|
||||
ctx.ensure_object(dict)
|
||||
ctx.obj["config_file"] = config
|
||||
@@ -63,6 +74,7 @@ async def cli(ctx: Context, config, app, name):
|
||||
@cli.command(help="Generate migrate changes file.")
|
||||
@click.option("--name", default="update", show_default=True, help="Migrate name.")
|
||||
@click.pass_context
|
||||
@coro
|
||||
async def migrate(ctx: Context, name):
|
||||
config = ctx.obj["config"]
|
||||
location = ctx.obj["location"]
|
||||
@@ -76,6 +88,7 @@ async def migrate(ctx: Context, name):
|
||||
|
||||
@cli.command(help="Upgrade to latest version.")
|
||||
@click.pass_context
|
||||
@coro
|
||||
async def upgrade(ctx: Context):
|
||||
config = ctx.obj["config"]
|
||||
app = ctx.obj["app"]
|
||||
@@ -102,6 +115,7 @@ async def upgrade(ctx: Context):
|
||||
|
||||
@cli.command(help="Downgrade to previous version.")
|
||||
@click.pass_context
|
||||
@coro
|
||||
async def downgrade(ctx: Context):
|
||||
app = ctx.obj["app"]
|
||||
config = ctx.obj["config"]
|
||||
@@ -124,6 +138,7 @@ async def downgrade(ctx: Context):
|
||||
|
||||
@cli.command(help="Show current available heads in migrate location.")
|
||||
@click.pass_context
|
||||
@coro
|
||||
async def heads(ctx: Context):
|
||||
app = ctx.obj["app"]
|
||||
versions = Migrate.get_all_version_files()
|
||||
@@ -138,6 +153,7 @@ async def heads(ctx: Context):
|
||||
|
||||
@cli.command(help="List all migrate items.")
|
||||
@click.pass_context
|
||||
@coro
|
||||
async def history(ctx: Context):
|
||||
versions = Migrate.get_all_version_files()
|
||||
for version in versions:
|
||||
@@ -157,6 +173,7 @@ async def history(ctx: Context):
|
||||
"--location", default="./migrations", show_default=True, help="Migrate store location."
|
||||
)
|
||||
@click.pass_context
|
||||
@coro
|
||||
async def init(
|
||||
ctx: Context, tortoise_orm, location,
|
||||
):
|
||||
@@ -188,6 +205,7 @@ async def init(
|
||||
show_default=True,
|
||||
)
|
||||
@click.pass_context
|
||||
@coro
|
||||
async def init_db(ctx: Context, safe):
|
||||
config = ctx.obj["config"]
|
||||
location = ctx.obj["location"]
|
||||
@@ -220,4 +238,4 @@ async def init_db(ctx: Context, safe):
|
||||
|
||||
def main():
|
||||
sys.path.insert(0, ".")
|
||||
cli(_anyio_backend="asyncio")
|
||||
cli()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import importlib
|
||||
|
||||
from asyncclick import BadOptionUsage, Context
|
||||
from click import BadOptionUsage, Context
|
||||
from tortoise import BaseDBAsyncClient, Tortoise
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user