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

use ArtARTs36\MergeRequestLinter\Console\DumpCommand;
use ArtARTs36\MergeRequestLinter\Console\InstallCommand;
use ArtARTs36\MergeRequestLinter\Console\LintCommand;
use Symfony\Component\Console\Application;

if (isset($_composer_autoload_path)) {
    require $_composer_autoload_path;
}

$loaded = false;

foreach (['../../..', '../..', '..', 'vendor', '../vendor', '../../vendor'] as $path) {
    if (\is_file($autoload_file = __DIR__ . '/' . $path . '/autoload.php')) {
        require $autoload_file;
        $loaded = true;
        break;
    }
}

if ($loaded === false) {
    fwrite(\STDERR, 'Composer autoload.php not found');

    exit(1);
}

$application = new Application('Merge Request Linter', '0.1.0');

$application->add(new LintCommand());
$application->add(new InstallCommand());
$application->add(new DumpCommand());

$application->run();
