-
Jared Hancock authored
Include all the modules for `php manage.php --help` invocation. Also, pass the parsed arguments and options to the Module::run() implementation.
Jared Hancock authoredInclude all the modules for `php manage.php --help` invocation. Also, pass the parsed arguments and options to the Module::run() implementation.
manage.php 1.51 KiB
#!/usr/bin/env php
<?php
require_once "modules/class.module.php";
class Manager extends Module {
var $prologue =
"Manage one or more osTicket installations";
var $arguments = array(
'action' => "Action to be managed"
);
var $usage = '$script action [options] [arguments]';
var $autohelp = false;
function showHelp() {
foreach (glob(dirname(__file__).'/modules/*.php') as $script)
include_once $script;
global $registered_modules;
$this->epilog =
"Currently available modules follow. Use 'manage.php <module>
--help' for usage regarding each respective module:";
parent::showHelp();
echo "\n";
foreach ($registered_modules as $name=>$mod)
echo str_pad($name, 20) . $mod->prologue . "\n";
}
function run() {
if ($this->getOption('help') && !$this->getArgument('action'))
$this->showHelp();
else {
$action = $this->getArgument('action');
global $argv;
foreach ($argv as $idx=>$val)
if ($val == $action)
unset($argv[$idx]);
foreach (glob(dirname(__file__).'/modules/*.php') as $script)
include_once $script;
$module = Module::getInstance($action);
$module->_run();
}
}
}
if (php_sapi_name() != "cli")
die("Management only supported from command-line\n");
$manager = new Manager();
$manager->parseOptions();
$manager->run();
?>