"""Unified optimize command - consolidates weights, steering, and classification optimization.

Usage:
    wisent optimize weights --task coding --model Qwen/Qwen3-8B
    wisent optimize steering --task coding --model Qwen/Qwen3-8B
    wisent optimize classification --task coding --model Qwen/Qwen3-8B
"""

from wisent.core.cli.optimize_weights import execute_optimize_weights
from wisent.core.cli.optimize_steering import execute_optimize_steering
from wisent.core.cli.optimize_classification import execute_optimize_classification


def execute_optimize(args):
    """
    Execute the unified optimize command.
    
    Routes to the appropriate optimization method based on subcommand:
    - weights: Optimize weight modification parameters
    - steering: Optimize steering vector application parameters
    - classification: Optimize classification thresholds
    """
    if not hasattr(args, 'optimize_method') or args.optimize_method is None:
        print("\n✗ No optimization method specified")
        print("Available methods: weights, steering, classification")
        print("\nUsage:")
        print("  wisent optimize weights --task coding --model Qwen/Qwen3-8B")
        print("  wisent optimize steering --task coding --model Qwen/Qwen3-8B")
        print("  wisent optimize classification --task coding --model Qwen/Qwen3-8B")
        import sys
        sys.exit(1)
    
    method = args.optimize_method
    
    if method == 'weights':
        execute_optimize_weights(args)
    elif method == 'steering':
        execute_optimize_steering(args)
    elif method == 'classification':
        execute_optimize_classification(args)
    else:
        print(f"\n✗ Unknown optimization method: {method}")
        print("Available methods: weights, steering, classification")
        import sys
        sys.exit(1)
