Skip to content

Commit 909a304

Browse files
committed
feat: add pretty error when no flows registered in server command
1 parent 8da2e7a commit 909a304

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

python/cocoindex/cli.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,25 @@ def _run_server(
645645
"""Helper function to run the server with specified settings."""
646646
_load_user_app(app_ref)
647647

648+
# Check if any flows are registered
649+
if not flow.flow_names():
650+
click.secho(
651+
f"\nError: No flows registered in '{app_ref}'.\n",
652+
fg="red",
653+
bold=True,
654+
err=True,
655+
)
656+
click.secho(
657+
"To use CocoIndex server, you need to define at least one flow.",
658+
err=True,
659+
)
660+
click.secho(
661+
"See https://cocoindex.io/docs for more information.\n",
662+
fg="cyan",
663+
err=True,
664+
)
665+
raise click.Abort()
666+
648667
server_settings = setting.ServerSettings.from_env()
649668
cors_origins: set[str] = set(server_settings.cors_origins or [])
650669
if cors_origin is not None:

0 commit comments

Comments
 (0)