#!/usr/bin/env php
<?php
$appName = 'phpReflect';

if (\Phar::running()) {
    $vendorDir = 'phar://' . strtolower($appName) . '.phar/vendor';
} else {
    $baseDir   = dirname(__DIR__);
    $vendorDir = $baseDir . '/vendor';

    if (!file_exists($vendorDir . '/autoload.php')) {
        $vendorDir = dirname(dirname($baseDir));
    }

    if (!getenv("BARTLETTRC")) {
        putenv("BARTLETTRC=" . strtolower($appName) . '.json');
    }
}
$loader = require_once $vendorDir . '/autoload.php';
$loader->setUseIncludePath(true);

if (\Phar::running()) {
    if ($home) {
        // when optional resources are not embedded in phar distribution,
        // avoid PHP Warnings, and lookup first in global vendor dir (COMPOSER_HOME) if exists
        $classMapfiltered = $fallbackClassMap($loader->getClassMap(), 'Net_Growl');
        $loader->addClassMap($classMapfiltered);

        // try to find PEAR Net_Growl classes package in folder $fallbackNetGrowlDir (see phar-stub.php)
        $loader->add(false, $fallbackNetGrowlDir);
    }
}

if (PHP_SAPI !== 'cli') {
    return;
}

use Bartlett\Reflect\Environment;
use Bartlett\Reflect\Console\Application;

Environment::setScanDir();

$application = new Application($appName, '3.1');
$application->run();
