00001 <?php
00002
00015
00016
00017 require(dirname(__FILE__) . '/bootstrap.inc.php');
00018
00019 class importExport extends CommandLineTool {
00020
00021 var $command;
00022 var $plugin;
00023 var $parameters;
00024
00029 function importExport($argv = array()) {
00030 parent::CommandLineTool($argv);
00031 $this->command = array_shift($this->argv);
00032 $this->parameters = $this->argv;
00033 }
00034
00038 function usage() {
00039 echo "Command-line tool for import/export tasks\n"
00040 . "Usage:\n"
00041 . "\t{$this->scriptName} list: List available plugins\n"
00042 . "\t{$this->scriptName} [pluginName] usage: Display usage information for a plugin\n"
00043 . "\t{$this->scriptName} [pluginName] [params...]: Invoke a plugin\n";
00044 }
00045
00049 function execute() {
00050 $plugins = PluginRegistry::loadCategory('importexport');
00051 if ($this->command === 'list') {
00052 echo "Available plugins:\n";
00053 if (empty($plugins)) echo "\t(None)\n";
00054 else foreach ($plugins as $plugin) {
00055 echo "\t" . $plugin->getName() . "\n";
00056 }
00057 return;
00058 }
00059 if ($this->command == 'usage' || $this->command == 'help' || $this->command == '' || ($plugin = PluginRegistry::getPlugin('importexport', $this->command))===null) {
00060 $this->usage();
00061 return;
00062 }
00063
00064 return $plugin->executeCLI($this->scriptName, $this->parameters);
00065 }
00066
00067 }
00068
00069 $tool = new importExport(isset($argv) ? $argv : array());
00070 $tool->execute();
00071 ?>