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