<?php

// symlink me into maintenance/
$options = array('skip');
require_once 'commandLine.inc';
if (!isset($args[0])) {
    print "Call MWUpdateDaemon remotely for status or updates.\n";
    print "Usage: php luceneUpdate.php [database] [--skip=n] {status|flush|stop|start|restart|rebuild}\n";
    exit(-1);
}
$ret = true;
switch ($args[0]) {
    case 'stop':
        try {
            MWSearchUpdater::stop();
        } catch (MWException $e) {
            $ret = $e;
        }
        break;
    case 'restart':
    case 'flushall':
    case 'flush':
        try {
            MWSearchUpdater::flushAll();
        } catch (MWException $e) {
            $ret = $e;
        }
        break;
    case 'start':
        try {
            MWSearchUpdater::start();