#!/usr/bin/env python3
"""
CLI runner for orders seed scripts.

Usage:
    python run.py --seed             # Create test orders with stages/trips
    python run.py --list             # List existing orders with details
    python run.py --delete           # Delete all orders for team
    python run.py --delete-carriers  # Delete test carriers
"""
import argparse
import sys
from pathlib import Path

# Add parent to path for imports
sys.path.insert(0, str(Path(__file__).parent.parent / "hub"))

from client import OdooClient
from seed_orders import seed_orders, list_orders, delete_orders, delete_carriers


def main():
    parser = argparse.ArgumentParser(description="Manage test orders in Odoo")
    parser.add_argument("--seed", action="store_true", help="Create test orders with stages/trips")
    parser.add_argument("--list", action="store_true", help="List existing orders with details")
    parser.add_argument("--delete", action="store_true", help="Delete all orders for team")
    parser.add_argument("--delete-carriers", action="store_true", help="Delete test carriers")

    args = parser.parse_args()

    # If no flags, show help
    if not any([args.seed, args.list, args.delete, args.delete_carriers]):
        parser.print_help()
        return

    # Connect to Odoo
    client = OdooClient()
    client.connect()

    if args.list:
        list_orders(client)

    if args.delete:
        delete_orders(client)

    if args.delete_carriers:
        delete_carriers(client)

    if args.seed:
        seed_orders(client)

    print("\n=== DONE ===")


if __name__ == "__main__":
    main()
