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

declare(strict_types=1);

use ByTIC\Console\Support\SetRequestForConsole;

try {
    require dirname(__DIR__) . '/bootstrap/autoload.php';

    /** @var \ByTIC\Console\Application $application */
    $application = require dirname(__DIR__) . '/bootstrap/app.php';
    if ($application->getContainer()->has('app')) {
        SetRequestForConsole::bootstrap($application->getContainer());
    }

    exit($application->run());
} catch (Throwable $exception) {
    fwrite(STDERR, $exception->getMessage() . PHP_EOL);
    exit(1);
}
