public static function run(Event $event) { $args = $event->getArguments(); define('BASEPATH', 'foobar'); /* for old school file protector */ define('ROOTPATH', realpath('.')); define('ENVIRONMENT', $_SERVER['SERVER_ENVIRONMENT']); define('DEBUG', $_SERVER['SERVER_DEBUG']); require __DIR__ . '/includes/compat.php'; require __DIR__ . '/includes/functions.php'; require __DIR__ . '/includes/output.php'; $output = new \output(true); $func = new \func(); $methods = get_class_methods($func); if (!isset($args[0])) { $methods[] = 'cli +{any codeigniter cli command}'; sort($methods); $actions = ''; foreach ($methods as $m) { if ($m[0] != '_') { $actions .= str_replace('_', ' ', $m) . chr(10); } } $output->e('<blue>Please provide action:<off>' . chr(10) . trim($actions), true); } if ($args[0] == 'cli') { /* shift off cli */ array_shift($args); /* call codeigniter cli script passthru */ passthru('cd ' . ROOTPATH . '/public;php index.php ' . implode(' ', $args)); exit(0); } /* is the command there? */ $command = implode('_', $args); if (!in_array($command, $methods)) { $output->e('<red>Unknown Command: ' . $command, true); } /* load setup json */ $setup_file = __DIR__ . '/setup.json'; $output->e('<yellow>Setup File ' . $setup_file); if (!file_exists($setup_file)) { $output->e('<red>Setup File Missing?', true); } $setup = json_decode(file_get_contents($setup_file), true); /* start the party */ $output->e('<green>Start ' . $args[0]); $func->_process($command, $setup, $output); $output->e('<green>Finished'); }