#!/usr/bin/env php

<?php

declare(ticks = 1);

pcntl_signal(SIGTERM, "restore_cursor");
pcntl_signal(SIGINT, "restore_cursor");

use seregazhuk\PhpWatcher\WatcherCommand;

if (file_exists(__DIR__.'/vendor/autoload.php')) {
    require __DIR__.'/vendor/autoload.php';
} else {
    require __DIR__.'/../../autoload.php';
}

$command = new WatcherCommand();
$application = new seregazhuk\PhpWatcher\ConsoleApplication();
$application->add($command);

$application->setDefaultCommand($command->getName(), true);
$application->run();

function restore_cursor() {
  echo "\033[?25h";
  exit;
}
