Exemplo n.º 1
0
 public function case_dispatch_return()
 {
     $this->given($dispatcher = new \Mock\Hoa\Dispatcher(), $this->calling($dispatcher)->resolve = 42, $router = new Router\Cli(), $router->get('a', '(?<foo>foo) (?<bar>bar)'), $router->route('foo bar'))->when($result = $dispatcher->dispatch($router))->then->integer($result)->isEqualTo(42);
 }
Exemplo n.º 2
0
        $core = [dirname(__DIR__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'Core.php', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'hoa' . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'Core.php', dirname(__DIR__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'Core.php'];
        foreach ($core as $path) {
            if (file_exists($path)) {
                require_once $path;
                break;
            }
        }
    }
}
Core::enableErrorHandler();
Core::enableExceptionHandler();
/**
 * Here we go!
 */
try {
    $router = new Router\Cli();
    $router->get('g', '(?:(?<vendor>\\w+)\\s+)?(?<library>\\w+)?(?::(?<command>\\w+))?(?<_tail>.*?)', 'main', 'main', ['vendor' => 'hoa', 'library' => 'core', 'command' => 'welcome']);
    $dispatcher = new Dispatcher\ClassMethod(['synchronous.call' => '(:%variables.vendor:lU:)\\(:%variables.library:lU:)\\Bin\\(:%variables.command:lU:)', 'synchronous.able' => 'main']);
    $dispatcher->setKitName('Hoa\\Console\\Dispatcher\\Kit');
    exit((int) $dispatcher->dispatch($router));
} catch (Core\Exception $e) {
    $message = $e->raise(true);
    $code = 1;
} catch (\Exception $e) {
    $message = $e->getMessage();
    $code = 2;
}
ob_start();
Console\Cursor::colorize('foreground(white) background(red)');
echo $message, "\n";
Console\Cursor::colorize('normal');
Exemplo n.º 3
0
<?php

use Hoa\Console;
use Hoa\Dispatcher;
use Hoa\Exception;
use Hoa\Router;
Exception\Error::enableErrorHandler();
Exception::enableUncaughtHandler();
try {
    $router = new Router\Cli();
    $router->get('g', '(?<command>\\w+)?(?<_tail>.*?)', 'Main', 'Main', ['command' => 'welcome']);
    $dispatcher = new Dispatcher\ClassMethod(['synchronous.call' => 'Jekxyl\\Bin\\(:%variables.command:ls/new/_New/U:)', 'synchronous.able' => 'main']);
    $dispatcher->setKitName('Hoa\\Console\\Dispatcher\\Kit');
    exit($dispatcher->dispatch($router));
} catch (Core\Exception $e) {
    $message = $e->raise(true);
    $code = 1;
} catch (\Exception $e) {
    $message = $e->getMessage();
    $code = 2;
}
Console\Cursor::colorize('foreground(white) background(red)');
echo $message, "\n";
Console\Cursor::colorize('normal');
exit($code);