#!/usr/bin/env python3
"""
CMPM (Claude Multi-Agent PM) CLI Wrapper
========================================

Basic CLI wrapper for the Claude PM Framework.

Usage:
    cmpm init              # Initialize framework
    cmpm status            # Check framework health
    cmpm help              # Show help information
"""

import sys
import os
from pathlib import Path

# Add the framework path to Python path
framework_path = Path(__file__).parent.parent
sys.path.insert(0, str(framework_path))

from claude_pm.cmpm_commands import main as cmpm_main
from rich.console import Console

console = Console()


def show_help():
    """Show CMPM help information."""
    help_text = """
[bold cyan]CMPM (Claude Multi-Agent PM) Commands[/bold cyan]
=====================================

[bold green]Available Commands:[/bold green]
  [cyan]init[/cyan]               - Initialize Claude PM Framework
  [cyan]status[/cyan]             - Check framework health status
  [cyan]help[/cyan]               - Show this help message

[bold yellow]Examples:[/bold yellow]
  cmpm init
  cmpm status
  cmpm help

[bold blue]Framework Info:[/bold blue]
  Version: 1.4.3
  Core Commands: init, status, help
    """
    console.print(help_text)


def main():
    """Main entry point for CMPM CLI wrapper."""
    try:
        if len(sys.argv) < 2:
            show_help()
            return
        
        command = sys.argv[1]
        
        if command == "help" or command == "--help" or command == "-h":
            show_help()
            return
        
        # Handle basic commands by delegating to the Click-based cmpm_commands
        if command in ["init", "status"]:
            # Delegate to the actual Click-based command implementation
            sys.argv[0] = "cmpm"  # Set proper program name
            cmpm_main()
        else:
            console.print(f"[red]Unknown CMPM command: {command}[/red]")
            console.print("Run 'cmpm help' for available commands")
            sys.exit(1)
    
    except KeyboardInterrupt:
        console.print("\n[yellow]Operation cancelled by user[/yellow]")
        sys.exit(1)
    except Exception as e:
        console.print(f"[red]Error: {str(e)}[/red]")
        console.print("[yellow]Run 'cmpm help' for usage information[/yellow]")
        sys.exit(1)


if __name__ == "__main__":
    main()