#!/usr/bin/env python
import sys
import optparse
from src.debugger import *
from src.ui import CursesUI

if __name__ == "__main__":
    parser = optparse.OptionParser(description="DBGP debugger for PHP scripts")
    parser.add_option('--host', action='store', default='127.0.0.1', help='Host (defaults to 127.0.0.1)')
    parser.add_option('--port', action='store', default=9000, help='Port (defaults to 9000)')
    options, args = parser.parse_args()
    if len(args) < 1:
        parser.error("You need to specify a path")
    debugger = Debugger(args[0], CursesUI(), options.port, options.host)
    try:
        debugger.start()
        debugger.ui.start()
    except KeyboardInterrupt:
        pass
    finally:
        debugger.stop()
