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

use Phpactor\Container\PhpactorContainer;
use Phpactor\Extension\Console\ConsoleExtension;
use Symfony\Component\Console\Application;
use DTL\Extension\Fink\FinkExtension;

if (is_file(__DIR__ . '/../vendor/autoload.php')) {
    $autoloader = require __DIR__ . '/../vendor/autoload.php';
} elseif (is_file(__DIR__ . '/../../../autoload.php')) {
    $autoloader = require __DIR__ . '/../../../autoload.php';
} else {
    echo 'Cannot find the vendor directory, have you executed composer install?' . PHP_EOL;
    echo 'See https://getcomposer.org to get Composer.' . PHP_EOL;
    exit(1);
}

$container = PhpactorContainer::fromExtensions([
    ConsoleExtension::class,
    FinkExtension::class
], []);

$title = 'Fink Link Checker';
cli_set_process_title($title);
$application = new Application($title, '@git_version@ (@datetime@)');
$application->setCommandLoader(
    $container->get(ConsoleExtension::SERVICE_COMMAND_LOADER)
);
$application->setDefaultCommand('fink', true);
$application->run();
