啟用 Market Intel seed writer CLI gate
All checks were successful
CD Pipeline / deploy (push) Successful in 57s
All checks were successful
CD Pipeline / deploy (push) Successful in 57s
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Market intelligence seed writer CLI skeleton.
|
||||
"""Market intelligence seed writer CLI.
|
||||
|
||||
This script intentionally refuses real writes in the current phase. It prints a
|
||||
JSON execution plan and never creates a DB session or commits seed rows.
|
||||
By default this script prints a JSON execution plan. Real writes require
|
||||
--execute, --apply-real-write, and a confirmation token.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
@@ -35,24 +35,32 @@ def parse_args(argv=None):
|
||||
parser.add_argument(
|
||||
"--execute",
|
||||
action="store_true",
|
||||
help="Request real execution. This skeleton will still block it.",
|
||||
help="Request real execution.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--apply-real-write",
|
||||
action="store_true",
|
||||
help="Allow the guarded market_platforms seed upsert transaction.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--approval-token",
|
||||
default=None,
|
||||
help=f"One-time approval token. May also be set via {APPROVAL_ENV_VAR}.",
|
||||
help=f"One-time approval token. Defaults to {APPROVAL_ENV_VAR} when omitted.",
|
||||
)
|
||||
return parser.parse_args(argv)
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
args = parse_args(argv)
|
||||
approval_token = args.approval_token or os.getenv(APPROVAL_ENV_VAR)
|
||||
approval_token_secret = os.getenv(APPROVAL_ENV_VAR)
|
||||
approval_token = args.approval_token or approval_token_secret
|
||||
service = MarketIntelService()
|
||||
plan = service.build_seed_writer_cli_status(
|
||||
platform_code=args.platform,
|
||||
execute_requested=args.execute,
|
||||
apply_real_write=args.apply_real_write,
|
||||
approval_token=approval_token,
|
||||
approval_token_secret=approval_token_secret,
|
||||
)
|
||||
print(json.dumps(plan, ensure_ascii=False, indent=2, sort_keys=True))
|
||||
return int(plan.get("exit_code", 2))
|
||||
|
||||
Reference in New Issue
Block a user