<?php

/*
    Asatru PHP (dnyAsatruPHP) developed by Daniel Brendel
    
    (C) 2019 - 2024 by Daniel Brendel
    
    Contact: dbrendel1988<at>gmail<dot>com
    GitHub: https://github.com/danielbrendel/
    
    Released under the MIT license
*/

//Set application root directory path
define('ASATRU_APP_ROOT', __DIR__);

//If composer is installed then utilize its autoloader
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
    require_once __DIR__ . '/vendor/autoload.php';
}

//Require constants
require_once __DIR__ . '/vendor/danielbrendel/asatru-php-framework/src/constants.php';

//Require .env config management
require_once __DIR__ . '/vendor/danielbrendel/asatru-php-framework/src/dotenv.php';

//Parse .env file if it exists
if (file_exists('.env')) {
    env_parse('.env');
}

//Require logging
require_once __DIR__ . '/vendor/danielbrendel/asatru-php-framework/src/logger.php';

//Require autoload component
require_once __DIR__ . '/vendor/danielbrendel/asatru-php-framework/src/autoload.php';

//Require config component
require_once __DIR__ . '/vendor/danielbrendel/asatru-php-framework/src/config.php';

//Require helpers
require_once __DIR__ . '/vendor/danielbrendel/asatru-php-framework/src/helper.php';

//Include CLI handler
require_once __DIR__ . '/vendor/danielbrendel/asatru-php-framework/src/console.php';

//Require database handler
require_once __DIR__ . '/vendor/danielbrendel/asatru-php-framework/src/database.php';

//Require command handler
require_once __DIR__ . '/vendor/danielbrendel/asatru-php-framework/src/commands.php';

//Process further if in debug mode
if ((isset($_ENV['APP_DEBUG'])) && ($_ENV['APP_DEBUG'])) {
    Asatru\Console\handleInput($argv);
} else {
    echo "\033[31mCLI tool is only available in debug mode\033[39m\n";
}

//Success, we can end script execution
exit(0);