init(); echo "** success **\n"; } break; /* (1) Packages listing ---------------------------------------------------------*/ case 'packages': case 'p': { 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': case 'i': { 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': case 'r': { 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': case 'b': { 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; /* (4) Help message ---------------------------------------------------------*/ default: { echo "xfw: xdrm framework\n"; echo "\n"; echo "COMMANDS\n"; echo "\tinit\n"; echo "\t\tInitialize a new framework environment.\n"; echo "\n"; echo "\tpackages\n"; echo "\t\tList all available packages and its versions.\n"; echo "\n"; echo "\tinstall @pkg_name:@version\n"; echo "\t\tAdd the version @version of the package @pkg_name to the environment.\n"; echo "\n"; echo "\tremove @pkg_name\n"; echo "\t\tRemove the package @pkg_name from the environment.\n"; echo "\n"; echo "\tbuild @root_path\n"; echo "\t\tBuild from the environment at the location @root_path.\n"; echo "\n"; } break; } ?>