chore: show friendly message when config missing 'apps' section
This commit is contained in:
parent
49bfbf4e6b
commit
db0cf656fc
@ -63,7 +63,10 @@ async def cli(ctx: Context, config, app) -> None:
|
|||||||
add_src_path(src_folder)
|
add_src_path(src_folder)
|
||||||
tortoise_config = get_tortoise_config(ctx, tortoise_orm)
|
tortoise_config = get_tortoise_config(ctx, tortoise_orm)
|
||||||
if not app:
|
if not app:
|
||||||
apps_config = cast(dict, tortoise_config.get("apps"))
|
try:
|
||||||
|
apps_config = cast(dict, tortoise_config["apps"])
|
||||||
|
except KeyError:
|
||||||
|
raise UsageError('Config must define "apps" section')
|
||||||
app = list(apps_config.keys())[0]
|
app = list(apps_config.keys())[0]
|
||||||
command = Command(tortoise_config=tortoise_config, app=app, location=location)
|
command = Command(tortoise_config=tortoise_config, app=app, location=location)
|
||||||
ctx.obj["command"] = command
|
ctx.obj["command"] = command
|
||||||
|
Loading…
x
Reference in New Issue
Block a user