diff --git a/apps/api/app/cli.py b/apps/api/app/cli.py index ee68d5c..103ce83 100644 --- a/apps/api/app/cli.py +++ b/apps/api/app/cli.py @@ -12,7 +12,16 @@ from .community_importer import stage_observations from .retention import RetentionPolicy, apply_retention from .storage import delete_screenshot from .catalog_audit import audit_catalog -from .community_scheduler import configured_sources, run_source +from .community_scheduler import run_source, configured_sources + +# Static registry for argparse choices — no DB required for --help +STATIC_SOURCE_CHOICES = [ + "rf4db", + "rf4stat-fishing", + "rf4stat-post", + "rf4map", + "rf4posts-spot", +] def main() -> int: @@ -26,7 +35,7 @@ def main() -> int: community.add_argument("--input", default="-", help="JSON array path or - for stdin") community.add_argument("--limit", type=int, default=500) fetch_community = sub.add_parser("fetch-community") - fetch_community.add_argument("source", choices=configured_sources()) + fetch_community.add_argument("source", choices=STATIC_SOURCE_CHOICES) cleanup = sub.add_parser("cleanup-retention") cleanup.add_argument("--apply", action="store_true", help="apply changes; default is dry-run") sub.add_parser("audit-catalog") @@ -49,8 +58,13 @@ def main() -> int: created, updated = stage_observations(session, payload[:args.limit]) print(f"staged: created={created} updated={updated}") elif args.command == "fetch-community": + # A09: Verify source is enabled at runtime (not just in static choices) + enabled = configured_sources() + if args.source not in enabled: + print(f"source {args.source!r} is disabled or not configured", file=sys.stderr) + return 1 started = run_source(args.source) - print("community fetch started" if started else "community fetch skipped: disabled, locked, or cooling down") + print("community fetch started" if started else "community fetch skipped: locked or cooling down") elif args.command == "cleanup-retention": policy = RetentionPolicy( submission_days=settings.retention_submission_days,