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

if (!ini_get('date.timezone')) {
    ini_set('date.timezone', 'UTC');
}

foreach ([__DIR__ . '/../../../autoload.php', __DIR__ . '/../../vendor/autoload.php', __DIR__ . '/../vendor/autoload.php'] as $file) {
    if (file_exists($file)) {
        define('BRANDA_COMPOSER_INSTALL', $file);

        break;
    }
}

unset($file);

if (!defined('BRANDA_COMPOSER_INSTALL')) {
    fwrite(STDERR,
        'You need to set up the project dependencies using the following commands:' . PHP_EOL .
        'wget http://getcomposer.org/composer.phar' . PHP_EOL .
        'php composer.phar install' . PHP_EOL
    );

    die(1);
}

require BRANDA_COMPOSER_INSTALL;

define('APP_NAME', 'branda');
define('APP_VERSION', '0.1.0');

$output = new Symfony\Component\Console\Output\ConsoleOutput();
$output->writeln(sprintf('Branda %s by Hendrik Maus and contributors.', APP_VERSION));

$application = new Hmaus\Branda\BrandaApplication(APP_NAME, APP_VERSION);
$application->run(null, $output);