<?php

if(php_sapi_name() !== 'cli')
{
	die("This tool is only for use in the command line");
}

define('DS', DIRECTORY_SEPARATOR);

define('CPATH', __DIR__.DS);

define('ROOTPATH', __DIR__.DS);

chdir(CPATH);

$action = $argv[1] ?? 'help';

require 'app'.DS.'thunder'.DS.'init.php';

$thunder = new \Thunder\Thunder;

if(empty($action))
{
	call_user_func_array([$thunder,'help'], []);
}else
{
	$parts = explode(":", $action);

	if(is_callable([$thunder,$parts[0]]))
	{
		call_user_func_array([$thunder,$parts[0]], [$argv]);
	}else{
		echo "\n\rThat command was not recognised. Please see below for commands";
		call_user_func_array([$thunder,'help'], []);
	}
}
