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

// This is the main entry point for the CoreFlux CLI.
// Its only purpose is to bootstrap the application and run the CLI Kernel.

// Define core paths
define('FS_ROOT_PATH', dirname(__DIR__));
define('APP_PATH' ,  FS_ROOT_PATH . DIRECTORY_SEPARATOR . 'app');
// define('APP_PATH', FS_ROOT_PATH . DIRECTORY_SEPARATOR . 'app');
// define('CORE_PATH', FS_ROOT_PATH . DIRECTORY_SEPARATOR . 'core');
// define('STORAGE_PATH', FS_ROOT_PATH . DIRECTORY_SEPARATOR . 'storage');
// define('CONFIG_PATH', APP_PATH . DIRECTORY_SEPARATOR . 'config');

// Load Composer's autoloader
require_once FS_ROOT_PATH . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';

require_once APP_PATH . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . 'bootstrap.php';

// Load environment variables from .env file
if (file_exists(ROOT_PATH . DIRECTORY_SEPARATOR . '.env')) {
    $dotenv = \Dotenv\Dotenv::createImmutable(ROOT_PATH);
    $dotenv->load();
}

// Instantiate and run the CLI Kernel, which handles all command logic.
use Core\CLI\Kernel;
$kernel = new Kernel();
$kernel->run($_SERVER['argv']);