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

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

define('RELEASE_TOOLS_ROOT', dirname(__FILE__) . DIRECTORY_SEPARATOR . '..');
define('PROJECT_ROOT', getcwd());

function dd(...$arguments)
{
    dump(func_get_args());
    die;
}

$dispatcher = new Symfony\Component\EventDispatcher\EventDispatcher();
$application = new Symfony\Component\Console\Application("ReleaseTools", '@package_version@');

/**
 * Event Listners
 */
$listener = new \DALTCORE\ReleaseTools\Events\PreflightChecks();
$dispatcher->addListener('preflightchecks.begin', [$listener, 'begin']);

/**
 * Modules
 */
$application->add(new \DALTCORE\ReleaseTools\Modules\Init());
$application->add(new \DALTCORE\ReleaseTools\Modules\Prepare());
$application->add(new \DALTCORE\ReleaseTools\Modules\Changelog());
$application->add(new \DALTCORE\ReleaseTools\Modules\BuildChangelog());
$application->add(new \DALTCORE\ReleaseTools\Modules\Status());
$application->add(new \DALTCORE\ReleaseTools\Modules\ListChangelog());
$application->add(new \DALTCORE\ReleaseTools\Modules\Playbook());

/**
 * Special hooks
 */
$application->add(new \DALTCORE\ReleaseTools\Modules\Hooks\MadeChangelog());

$application->run();

