#!/usr/bin/env php
<?php
date_default_timezone_set('UTC');
set_time_limit(0);

(@include_once __DIR__ . '/../vendor/autoload.php')
    || @include_once __DIR__ . 'vendor/autoload.php';

use Symfony\Component\Console\Application;

$dir = __DIR__;
if($dir != getcwd()) {
    $dir .= '/..';
}

$app = new Application('Sample Console Component Based Application', '6.6.6');

$dir = new DirectoryIterator($dir . '/src/Command/');
foreach ($dir as $fileinfo) {
    if (!$fileinfo->isDot() && preg_match('/Command.php$/', $fileinfo->getFilename())) {
        $className = "Command\\" . rtrim(basename($fileinfo->getFilename()), ".php");
        $app->addCommands(array(
            new $className,
        ));
    }
}

$app->run();
