#!/usr/bin/env php
<?php
declare(strict_types=1);

/**
 * Portal CLI
 *
 * Command line interface for Portal framework operations.
 */

define('PORTAL_CLI', true);
define('PORTAL_PATH', __DIR__);

// Bootstrap
if (file_exists(__DIR__ . '/core/boot.php')) {
    require_once __DIR__ . '/core/boot.php';
}

// Load helpers and bootstrap container
require_once __DIR__ . '/core/Helpers/functions.php';

use Portal\Container\Container;
use Portal\Console\Application;
use Portal\Console\Commands\CacheClearCommand;
use Portal\Console\Commands\QueueWorkCommand;
use Portal\Console\Commands\MigrateCommand;
use Portal\Console\Commands\MigrateRollbackCommand;

// Get container
$container = Container::getInstance();

// Create CLI application
$app = new Application($container, 'Portal', '1.0.0');

// Register commands
$app->add($container->make(CacheClearCommand::class));
$app->add($container->make(QueueWorkCommand::class));
$app->add($container->make(MigrateCommand::class));
$app->add($container->make(MigrateRollbackCommand::class));

// Run
exit($app->run());
