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

use Camelot\SmtpDevServer\Command\SmtpServerCommand;
use Camelot\SmtpDevServer\DependencyInjection\Kernel;
use Symfony\Component\Console\Command\HelpCommand;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;

$run = function (): int {
    require_once dirname(__DIR__) . '/config/bootstrap.php';
    $kernel = new Kernel('dev', true);
    $kernel->boot();
    $command = $kernel->getContainer()->get(SmtpServerCommand::class);

    $input = new ArgvInput(null, $command->getDefinition());
    if ($input->getOption('help')) {
        $help = new HelpCommand();
        $help->setCommand($command);

        return $help->run($input, new ConsoleOutput());
    }

    return $command->run(new ArgvInput(), new ConsoleOutput());
};

return $run();
