<?php

include __DIR__ . '/../vendor/autoload.php';
use Processman\Driver\File\Json;
use Processman\Driver\File\Text;
$resqueman = new Processman\Processman(new Text(__DIR__ . '/resqueman.conf'), new Json(__DIR__ . '/pid.json'));
switch ($_SERVER['argv'][1]) {
    case 'run':
        $resqueman->run();
        break;
    case 'list':
        echo PHP_EOL;
        foreach ($resqueman->listRunning() as $pid => $running) {
            echo PHP_EOL . "\t" . $pid . "\t\t " . $running . PHP_EOL;
        }
        echo PHP_EOL;
        break;
    case 'add':
        $resqueman->addCommand($_SERVER['argv'][2]);
        break;
    case 'remove':
        $resqueman->removeCommand($_SERVER['argv'][2]);
        break;
}