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

$projectRoot = dirname(dirname(dirname(dirname(__DIR__)))) . '';
chdir($projectRoot);

if (!defined('APPLICATION_PATH')) {
    define('APPLICATION_PATH', dirname(__DIR__) . '/');
}

/**
 *  Now whit environment be this?
 */
if (!defined('APPLICATION_ENV') && getenv('APPLICATION_ENV')) {
    define('APPLICATION_ENV', (getenv('APPLICATION_ENV')
        ? getenv('APPLICATION_ENV')
        : 'production'));
}

/**
 *
 * I be autoloadin' th'composer or else shiver me timbers
 *
 */
if (!file_exists('vendor/autoload.php')) {
    throw new RuntimeException(
        'Garrrr! Unable t\'load Bone. Run `composer install` or `php composer.phar install`'
    );
}

require_once 'vendor/autoload.php';

use Bone\Console\ConsoleApplication;
use Bone\OpenApi\Console\DocGeneratorCommand;

$container = Bone\Mvc\Application::ahoy()->bootstrap();
$packages = $container->get('packages');
$app = new ConsoleApplication();
$command = new DocGeneratorCommand($packages);
$app->add($command);
$app->run();

