xdrm-framework/exporter/main.php

80 lines
1.6 KiB
PHP
Raw Normal View History

<?php define('__ROOT__', dirname(dirname(__FILE__)) );
require_once 'Exporter.php';
/* [1] Initialisation
=========================================================*/
/* (1) Get arguments (excepted file) */
$arguments = array_slice($argv, 1);
$arglen = $argc - 1;
// si aucun argument
if( count($arguments) === 0 ){
echo "Missing arguments.\n";
return;
}
/* (2) Load module's config */
$exporter = new Exporter();
/* [2] Commands
=========================================================*/
switch($arguments[0]){
/* (1) Modules listing
---------------------------------------------------------*/
case 'modules': {
echo "available modules:\n";
$modules = $exporter->available();
foreach($modules as $module=>$versions){
foreach($versions as $version)
echo " - $module-$version\n";
echo "\n";
}
} break;
/* (2) Enables a module and its version
---------------------------------------------------------*/
case 'enable': {
if( $arglen < 2 || !preg_match("/^(.+)-([0-9\.]+)$/i", $arguments[1], $matches) ){
echo "You must specify @module-@version.\n";
return;
}
$err = $exporter->enable($matches[1], $matches[2]);
/* (1) Managing state */
if( $err === true ) echo "success.\n";
else echo $err;
} break;
/* (3) Disabled a module
---------------------------------------------------------*/
case 'disable': {
if( $arglen < 2 ){
echo "You must specify @module.\n";
return;
}
$err = $exporter->disable($arguments[1]);
/* (1) Managing state */
if( $err === true ) echo "success.\n";
else echo $err;
} break;
}
?>