Fix section name
This commit is contained in:
parent
b1521c4cc7
commit
6f7893d376
@ -29,8 +29,6 @@ Options:
|
|||||||
-V, --version Show the version and exit.
|
-V, --version Show the version and exit.
|
||||||
-c, --config TEXT Config file. [default: pyproject.toml]
|
-c, --config TEXT Config file. [default: pyproject.toml]
|
||||||
--app TEXT Tortoise-ORM app name.
|
--app TEXT Tortoise-ORM app name.
|
||||||
-n, --name TEXT Name of section in .ini file to use for aerich config.
|
|
||||||
[default: tool.aerich]
|
|
||||||
-h, --help Show this message and exit.
|
-h, --help Show this message and exit.
|
||||||
|
|
||||||
Commands:
|
Commands:
|
||||||
|
@ -47,19 +47,11 @@ def coro(f):
|
|||||||
help="Config file.",
|
help="Config file.",
|
||||||
)
|
)
|
||||||
@click.option("--app", required=False, help="Tortoise-ORM app name.")
|
@click.option("--app", required=False, help="Tortoise-ORM app name.")
|
||||||
@click.option(
|
|
||||||
"-n",
|
|
||||||
"--name",
|
|
||||||
default="tool.aerich",
|
|
||||||
show_default=True,
|
|
||||||
help="Name of section in .ini file to use for aerich config.",
|
|
||||||
)
|
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
@coro
|
@coro
|
||||||
async def cli(ctx: Context, config, app, name):
|
async def cli(ctx: Context, config, app):
|
||||||
ctx.ensure_object(dict)
|
ctx.ensure_object(dict)
|
||||||
ctx.obj["config_file"] = config
|
ctx.obj["config_file"] = config
|
||||||
ctx.obj["name"] = name
|
|
||||||
|
|
||||||
invoked_subcommand = ctx.invoked_subcommand
|
invoked_subcommand = ctx.invoked_subcommand
|
||||||
if invoked_subcommand != "init":
|
if invoked_subcommand != "init":
|
||||||
@ -69,9 +61,10 @@ async def cli(ctx: Context, config, app, name):
|
|||||||
content = f.read()
|
content = f.read()
|
||||||
doc = tomlkit.parse(content)
|
doc = tomlkit.parse(content)
|
||||||
try:
|
try:
|
||||||
location = doc[name]["location"]
|
tool = doc["tool"]["aerich"]
|
||||||
tortoise_orm = doc[name]["tortoise_orm"]
|
location = tool["location"]
|
||||||
src_folder = doc[name].get("src_folder", CONFIG_DEFAULT_VALUES["src_folder"])
|
tortoise_orm = tool["tortoise_orm"]
|
||||||
|
src_folder = tool.get("src_folder", CONFIG_DEFAULT_VALUES["src_folder"])
|
||||||
except NonExistentKey:
|
except NonExistentKey:
|
||||||
raise UsageError("You need run aerich init again when upgrade to 0.6.0+")
|
raise UsageError("You need run aerich init again when upgrade to 0.6.0+")
|
||||||
add_src_path(src_folder)
|
add_src_path(src_folder)
|
||||||
@ -190,7 +183,6 @@ async def history(ctx: Context):
|
|||||||
@coro
|
@coro
|
||||||
async def init(ctx: Context, tortoise_orm, location, src_folder):
|
async def init(ctx: Context, tortoise_orm, location, src_folder):
|
||||||
config_file = ctx.obj["config_file"]
|
config_file = ctx.obj["config_file"]
|
||||||
name = ctx.obj["name"]
|
|
||||||
|
|
||||||
if os.path.isabs(src_folder):
|
if os.path.isabs(src_folder):
|
||||||
src_folder = os.path.relpath(os.getcwd(), src_folder)
|
src_folder = os.path.relpath(os.getcwd(), src_folder)
|
||||||
@ -209,7 +201,7 @@ async def init(ctx: Context, tortoise_orm, location, src_folder):
|
|||||||
table["tortoise_orm"] = tortoise_orm
|
table["tortoise_orm"] = tortoise_orm
|
||||||
table["location"] = location
|
table["location"] = location
|
||||||
table["src_folder"] = src_folder
|
table["src_folder"] = src_folder
|
||||||
doc[name] = table
|
doc["tool"]["aerich"] = table
|
||||||
|
|
||||||
with open(config_file, "w") as f:
|
with open(config_file, "w") as f:
|
||||||
f.write(tomlkit.dumps(doc))
|
f.write(tomlkit.dumps(doc))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user