init(); echo "** success **\n"; } break; /* (1) Packages listing ---------------------------------------------------------*/ case 'packages': { echo "available packages:\n"; $packages = $exporter->available(); foreach($packages as $package=>$versions){ foreach($versions as $version) // if enabled if( $version['enabled'] ) echo " [*] $package:".$version['version']."\n"; else echo " [ ] $package:".$version['version']."\n"; echo "\n"; } } break; /* (2) Enables a package and its version ---------------------------------------------------------*/ case 'install': { if( $arglen < 2 || !preg_match("/^([^:]+)(:(?:[0-9\.-]+))?$/i", $arguments[1], $matches) ){ echo "You must specify @package:@version.\n"; return; } $err = $exporter->install($matches[1], count($matches) > 2 ? substr($matches[2], 1) : null); /* (1) Managing state */ if( $err === true ) echo "\n\n** success **\n"; else echo $err; } break; /* (3) Disabled a package ---------------------------------------------------------*/ case 'remove': { if( $arglen < 2 ){ echo "You must specify @package.\n"; return; } $err = $exporter->remove($arguments[1]); /* (1) Managing state */ if( $err === true ) echo "\n\n** success **\n"; else echo $err; } break; /* (3) Builds a project ---------------------------------------------------------*/ case 'build': { if( $arglen < 2 || !is_dir($arguments[1]) ){ echo "You must specify your project root's @path.\n"; return; } // Removes the optional final '/' $arguments[1] = preg_replace('/^(.+)\/$/', '$1', $arguments[1]); $err = $exporter->build($arguments[1]); /* (1) Managing state */ if( $err === true ) echo "\n\n** success **\n"; else echo $err; } break; } ?>