"""Plan one playhead move. --apply needs the reviewed project/timeline IDs and digest."""
import argparse
import json
from resolve_api_connection import connect
from resolve_api_timecode import move_playhead


def main():
    p = argparse.ArgumentParser(description=__doc__)
    p.add_argument("offset", type=int, help="Whole-frame offset from timeline start")
    p.add_argument("--rate", required=True)
    p.add_argument("--mode", choices=("ndf", "df"), required=True)
    p.add_argument("--apply", action="store_true")
    p.add_argument("--expect-project-id")
    p.add_argument("--expect-timeline-id")
    p.add_argument("--expect-plan-digest")
    a = p.parse_args()
    result = move_playhead(connect(), a.offset, a.rate, a.mode, apply=a.apply,
                           expected_project_id=a.expect_project_id,
                           expected_timeline_id=a.expect_timeline_id,
                           expected_plan_digest=a.expect_plan_digest)
    print(json.dumps(result, ensure_ascii=False, indent=2))


if __name__ == "__main__":
    main()
