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

use DragonCode\CodeStyler\Commands\Check;
use DragonCode\CodeStyler\Commands\Dependabot;
use DragonCode\CodeStyler\Commands\EditorConfig;
use DragonCode\CodeStyler\Commands\Fix;
use Symfony\Component\Console\Application;

error_reporting(E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED);

$possible_files = [
        __DIR__ . '/../../../autoload.php',
        __DIR__ . '/../../autoload.php',
        __DIR__ . '/../vendor/autoload.php',
];

$file = null;

foreach ($possible_files as $possible_file) {
    if (file_exists($possible_file)) {
        $file = $possible_file;
        break;
    }
}

if (is_null($file)) {
    throw new RuntimeException('Unable to locate autoload.php file.');
}

require_once $file;

$application = new Application('PHP Code Styler');

$application->add(new Check());
$application->add(new Fix());
$application->add(new Dependabot());
$application->add(new EditorConfig());

$application->run();
