<?php if(PHP_SAPI !== 'cli') die();
/**
 * CLI
 *
 * This file is the command-line interface (CLI) entry point for the system
 *
 * @package		MicroMVC
 * @author		David Pennington
 * @copyright	(c) 2010 MicroMVC Framework
 * @license		http://micromvc.com/license
 ********************************** 80 Columns *********************************
 */

// Include bootstrap
require('Bootstrap.php');

// Require a CLI path
if(empty($argv[1]))
{
	die("Please enter a path to the CLI file.\nExample: " . colorize('php cli file.php', 'blue') . "\n");
}

// Build path to file
$file = SP . 'Command/' . str_replace(EXT, '', trim($argv[1], '/')) . EXT;

// Does the file exist?
if( ! is_file($file)) die("Please enter a valid file path\n");

// Require a valid, safe path
if( ! preg_match('/^[\w\-~\/\.+]{1,600}/', $argv[1])) die(colorize("Invalid path given", 'red'). "\n");

try
{
	require($file);
}
catch (Exception $e)
{
	\Micro\Error::exception($e);
}

// End
