#!/usr/bin/env php
<?php

if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
    // Called from local git clone.
    require __DIR__ . '/../vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/../../../autoload.php')) {
    // Called from your project's vendor dir.
    require __DIR__ . '/../../../autoload.php';
} else {
    die(
        'You need to set up the project dependencies using the following commands:' . PHP_EOL .
        'curl -s http://getcomposer.org/installer | php' . PHP_EOL .
        'php composer.phar install' . PHP_EOL
    );
}

use Symfony\Component\Console\Application;
use Symfony\Component\Finder\Finder;

$appVersion = '0.1.2';

$finder = new Finder();
$finder->files()->in(__DIR__.'/../src/Command/');

$application = new Application('php livereload', $appVersion);

foreach ($finder as $file) {
    $class = 'PHPLivereload\\Command\\'.substr($file->getFileName(), 0, - (strlen($file->getExtension())+1));
    $application->add(new $class);
}

$application->run();
