#!/usr/bin/env php
<?php
use Cygnite\Console\Foundation\Application as ConsoleApplication;

set_time_limit(0);

define('VERSION', 'Cygnite: Craft Console v3.x');
/*
 | ---------------------------------------------------------------
 | Define Directory Separator
 | ---------------------------------------------------------------
 */
define('DS', DIRECTORY_SEPARATOR);

/**
|---------------------------------------------------------------
| Define PHP file extension
| ---------------------------------------------------------------
 */
defined('EXT') or define('EXT', '.php');

/*---------------------------------------------------------------
| Now that we know the path, set the main path constants
| path to the packages folder.
| ---------------------------------------------------------------
*/
defined('CF_SYSTEM') or define('CF_SYSTEM', 'cygnite-package');

/* --------------------------------------------------------------
| Define application folder name
| ---------------------------------------------------------------
*/
defined('APPPATH') or define('APPPATH', 'src/Apps');

defined('APP_NS') or define('APP_NS', 'Apps');

chdir(__DIR__);

/* --------------------------------------------------------------
| Define `root` directory name
| ---------------------------------------------------------------
*/
$dir = explode(DS, realpath('../../'));

defined('ROOTDIR') or define('ROOTDIR', rtrim(end($dir)));

defined('CYGNITE_BASE') or define('CYGNITE_BASE', dirname(dirname(__DIR__)));

include CYGNITE_BASE.'/bootstrap/start.php';

/*
 | We will set default timezone constant here to use
 | for console component
 */
$config = \Cygnite\Helpers\Config::get('global.config');

//timezone constant
define('SET_TIME_ZONE', $config['timezone']);

$console = new ConsoleApplication($container, VERSION);

/*
 | We have setup the environment.
 | Create Cygnite Console instance to run application.
 */
$console = new \Apps\Console\Kernel($console, VERSION);

/*
 | Environment Setup and Boot Strapping done!
 | Lets Run Console Application.
 |
 */
$console->run();
