orbit/bin/orbit

57 lines
1.9 KiB
PHP
Executable File

#!/usr/bin/env php
<?php
// Find where the composer autoload is
// This tool was installed as a composed dependency or directly
$root = realpath(dirname(__DIR__));
$autoload_locations = array(
__DIR__ . '/../../../autoload.php',
$root . DIRECTORY_SEPARATOR . 'vendor/autoload.php'
);
foreach ($autoload_locations as $file) {
if (file_exists($file)) {
define('ORBIT_COMPOSER_AUTOLOAD', $file);
break;
}
}
// Composer autoload require guard
if (!defined('ORBIT_COMPOSER_AUTOLOAD')) {
die(
"You must run the command `composer install` from the terminal "
. "in the directory '$root' before using this tool.\n"
);
}
// Load composer autoloader
$autoload = require_once ORBIT_COMPOSER_AUTOLOAD;
// Define command line args for this client
// And fetch args passed in by invocation
$args = new \Qi_Console_ArgV(
$argv,
[
'config|c:' => 'Use specified config file (.ini) for configuration',
'host:' => 'Set host/ip address to listen on (default 0.0.0.0)',
'port|p:' => 'Set port to listen on (default 1965)',
'hostname:' => 'Set hostname of server (default localhost)',
'tls-cert:' => 'Set cert PEM file to use (default null)',
'tls-key:' => 'Set private key PEM file to use (default null)',
'tls-passphrase:' => 'Set passphrase for private key',
'root-dir:' => 'Set the file root directory',
'log:' => 'Set log filename (default orbit.log)',
'dev' => 'Allow developer server functions (default false)',
'help|h' => 'Show help',
'verbose|v' => 'Include more verbose output',
'quiet|q' => 'Print less messages',
'no-color' => 'Don\'t use color output',
'version' => 'Show version and exit',
]
);
$terminal = new \Qi_Console_Terminal();
$error_handler = new \Qi_Console_ExceptionHandler($terminal, true, true);
$console = new \Orbit\Console($args, $terminal);
$value = $console->execute();
exit($value);