#!/usr/bin/env python3
"""
REPL Demo with Terminal Display - Shows how to use the REPL effect

Usage:
    python examples/repl_demo_terminal.py

This demonstrates the REPL effect with terminal display and interactive input.
"""

import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).parent.parent))

from engine.effects.plugins import discover_plugins
from engine.pipeline.hybrid_config import PipelineConfig


def main():
    """Run REPL demo with terminal display."""
    print("REPL Demo with Terminal Display")
    print("=" * 50)

    # Discover plugins
    discover_plugins()

    # Create a pipeline with REPL effect
    # Using empty source so there's content to overlay on
    config = PipelineConfig(
        source="empty",
        effects=[{"name": "repl", "intensity": 1.0}],
        display="terminal",
    )

    pipeline = config.to_pipeline(viewport_width=80, viewport_height=24)

    # Initialize pipeline
    if not pipeline.initialize():
        print("Failed to initialize pipeline")
        return

    print("\nREPL is now active!")
    print("Try typing commands:")
    print("  help - Show available commands")
    print("  status - Show pipeline status")
    print("  effects - List all effects")
    print("  pipeline - Show current pipeline order")
    print("  clear - Clear output buffer")
    print("\nPress Ctrl+C to exit")


if __name__ == "__main__":
    main()
