#!/usr/bin/env python3
"""Daftar seluruh job di cron/jobs.json: id, nama, jadwal, skrip, status."""
import json

P = "/home/mantapman/.hermes/profiles/atun/cron/jobs.json"
d = json.load(open(P))
jobs = d if isinstance(d, list) else d.get("jobs", [])
print(f"total job di jobs.json: {len(jobs)}")
print("contoh struktur jadwal:", json.dumps(jobs[0].get("schedule"), ensure_ascii=False)[:200], "\n")
for j in jobs:
    sch = j.get("schedule")
    if isinstance(sch, dict):
        sch = (sch.get("cron") or sch.get("expr") or sch.get("interval") or
               sch.get("value") or json.dumps(sch, ensure_ascii=False)[:26])
    aktif = j.get("enabled")
    if aktif is None:
        aktif = not j.get("paused", False)
    print(f"{j.get('id')} | {'AKTIF ' if aktif else 'JEDA  '} | {str(sch):<14} | "
          f"script={str(j.get('script'))[:26]:<28} | {str(j.get('name'))[:50]}")
