from __future__ import annotations

import sys
from pathlib import Path

from openpyxl import load_workbook


ROOT = Path(__file__).resolve().parents[1]
EXCEL_PATH = ROOT / "测试用例" / "SaaS_订阅邀请登录_测试功能点.xlsx"


def main() -> None:
    if len(sys.argv) != 3:
        raise SystemExit("usage: read_specific_excel_case.py <sheet> <case_id>")
    sheet_name = sys.argv[1]
    case_id = sys.argv[2]
    wb = load_workbook(EXCEL_PATH, read_only=True)
    ws = wb[sheet_name]
    headers = [cell.value for cell in ws[1]]
    for row in ws.iter_rows(min_row=2, values_only=True):
        if row[0] != case_id:
            continue
        for header, value in zip(headers, row):
            print(f"{header}: {value}")
        return
    raise SystemExit(f"case not found: {case_id}")


if __name__ == "__main__":
    main()
