import clawd_notion as notion
import sys
import json
import os
from datetime import datetime

SESSION_FILE = ".dev_session/SESSION_INFO"

def main():
    if len(sys.argv) < 2:
        print("Usage: python select_task.py <task_id>")
        return

    task_id = sys.argv[1]
    
    # Set status to Doing
    notion.update_page(task_id, {"Status": {"status": {"name": "Doing"}}})
    
    # Save Session
    os.makedirs(os.path.dirname(SESSION_FILE), exist_ok=True)
    with open(SESSION_FILE, "w") as f:
        json.dump({
            "task_id": task_id,
            "start_time": datetime.now().isoformat()
        }, f)
    
    print(f"Session gestartet für Task {task_id}. Status auf 'Doing' gesetzt.")

if __name__ == "__main__":
    main()
