#!/usr/bin/env php
<?php
/**
 * @copyright	Copyright (C) 2007 - 2015 Johan Janssens and Timble CVBA. (http://www.timble.net)
 * @license		Mozilla Public License, version 2.0
 * @link		http://github.com/joomlatools/joomlatools-console for the canonical source repository
 */

if (version_compare(PHP_VERSION, '7.3.0', '<'))
{
	echo "This command requires at least PHP version 7.3.0 to run. Exiting.";
	exit(1);
} 

$dirs = explode(DIRECTORY_SEPARATOR, __DIR__);
for ($i = count($dirs); $i >= 0; $i--)
{
	$dir = implode(DIRECTORY_SEPARATOR, array_slice($dirs, 0, $i));
	$autoload = $dir . DIRECTORY_SEPARATOR . 'autoload.php';
	$vendored = $dir . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';

	if (file_exists($vendored))
	{
		require $vendored;
		break;
	}
	else if (file_exists($autoload))
	{
		require $autoload;
		break;
	}
}

$application = new Joomlatools\Console\Application();
$application->run();
