#!/usr/bin/env php
<?php

namespace think;
use Kcloze\Jobs\Command\AppCommand;
use Kcloze\Jobs\Command\HttpCommand;
use Symfony\Component\Console\Application;

// 加载基础文件
require __DIR__ . '/thinkphp/base.php';

// 应用初始化
Container::get('app')->path(__DIR__ . '/application/')->initialize();
$config = require_once __DIR__ . '/application/swoole-jobs.php';
$application    = new Application();
$appCommand     = new AppCommand($config);
$application->add($appCommand);
$option=$argv[1] ?? '';
if (isset($config['httpServer']) && $option==='http') {
    $httpCommand    = new HttpCommand($config);
    $application->add($httpCommand);
    $application->setDefaultCommand($appCommand->getName());
} else {
    $application->setDefaultCommand($appCommand->getName(), true);
}

$application->run();