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

$vendorDir = '';

foreach (array(__DIR__ . '/../../../', __DIR__ . '/../vendor/', __DIR__ . '/vendor/') as $dir) {
    if (file_exists($dir . 'autoload.php')) {
        $vendorDir = $dir;
        break;
    }
}

if (is_file($vendorDir . 'autoload.php') === true) {
    require $vendorDir . 'autoload.php';
} else {
    throw new Exception('Cannot find autoloader');
}

use Elsevier\JSONSchemaPHPGenerator\Console\GenerateCommand;
use Symfony\Component\Console\Application;

$application = new Application();

$command = new GenerateCommand();
$command->setSchemaDraftFileLocation($vendorDir . 'justinrainbow/json-schema/dist/schema/json-schema-draft-04.json');
$application->add($command);
$application->setDefaultCommand($command->getName(), true);

$application->run();
