Exemplo n.º 1
0
<?php

$autoload = (require getcwd() . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'sauce.php';
require __DIR__ . DIRECTORY_SEPARATOR . 'functions.php';
\Sauce\Base::bind(function ($bootstrap) {
    die($bootstrap());
});
run(function () {
    \Sauce\Shell\CLI::initialize();
    $xargs = \Sauce\Shell\CLI::values();
    $command = array_shift($xargs);
    $paths = array();
    $paths[] = path(__DIR__, 'tasks');
    is_dir($app_tasks = path(APP_PATH, 'tasks')) && ($paths[] = $app_tasks);
    \IO\Dir::open($paths, function ($file) {
        if (is_dir($file)) {
            require path($file, 'initialize.php');
        } else {
            require $file;
        }
    });
    if (!$command) {
        help(arg('help'));
    } else {
        try {
            \Sauce\Shell\Task::exec($command, $xargs);
        } catch (\Exception $e) {
            \Sauce\Shell\CLI::error("\n  \\cred,black({$e->getMessage()})\\c\n");
        }
    }
Exemplo n.º 2
0
function run(\Closure $lambda)
{
    echo \Sauce\Base::initialize($lambda);
}
Exemplo n.º 3
0
// OS temp path
if (function_exists('sys_get_temp_dir')) {
    $temporary_files = @sys_get_temp_dir();
} else {
    $temporary_files = getenv('TMP') ?: getenv('TEMP');
    if (!is_dir($temporary_files)) {
        $old = @tempnam('E', '');
        $temporary_files = @dirname($old);
        @unlink($old);
    }
}
define('TMP', @is_dir($temporary_files) && @is_writable($temporary_files) ? rtrim($temporary_files, '\\/') : '/tmp');
is_dir(TMP) or mkdir(TMP, 0777, TRUE);
// default error and exception handlers
set_error_handler(function ($errno, $errmsg, $file, $line, $trace) {
    if (($errno & error_reporting()) == $errno) {
        \Sauce\Base::raise("{$errmsg} ({$file}#{$line})", $trace);
        return TRUE;
    }
    return FALSE;
});
set_exception_handler(function ($E) {
    \Sauce\Base::raise($E);
});
// helpers
require __DIR__ . DIRECTORY_SEPARATOR . 'runtime.php';
require __DIR__ . DIRECTORY_SEPARATOR . 'conditions.php';
require __DIR__ . DIRECTORY_SEPARATOR . 'functions.php';
require __DIR__ . DIRECTORY_SEPARATOR . 'routing.php';
require __DIR__ . DIRECTORY_SEPARATOR . 'actions.php';
require __DIR__ . DIRECTORY_SEPARATOR . 'assets.php';