Added CLI exception display and moved $is_cli to a constant.

This commit is contained in:
Josh Sherman 2011-05-03 22:34:11 -04:00
parent b4ea95dde5
commit aa3427a25c
2 changed files with 152 additions and 78 deletions

View file

@ -78,11 +78,8 @@ class Config extends Object
{
$environments = $config['environments'];
// Is this a CLI script
$is_cli = !isset($_SERVER['REQUEST_METHOD']);
// If we're on the CLI, check an environment was even passed in
if ($is_cli == true && $_SERVER['argc'] < 2)
if (IS_CLI == true && $_SERVER['argc'] < 2)
{
throw new Exception('You must pass an environment (e.g. php script.php <environment>)');
}
@ -98,7 +95,7 @@ class Config extends Object
// Tries to determine the environment name
foreach ($hosts as $host)
{
if ($is_cli)
if (IS_CLI == true)
{
// Checks the first argument on the command line
if ($_SERVER['argv'][1] == $name)