php-src/pear/scripts/pear.in

66 lines
1.6 KiB
Plaintext
Raw Normal View History

#!@prefix@/bin/php -Cq
<?php // -*- C++ -*-
require_once "PEAR.php";
require_once "PEAR/Installer.php";
require_once "PEAR/Packager.php";
require_once "Console/Getopt.php";
error_reporting(7);
$stderr = fopen("php://stderr", "w");
PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "usage");
$options = Console_Getopt::getopt($argv, "hv:?");
if (PEAR::isError($options)) {
usage($options);
}
PEAR::setErrorHandling(PEAR_ERROR_PRINT);
$command = $options[1][1];
switch ($command) {
case "install":
$package = $options[1][2];
$installer =& new PEAR_Installer();
if (PEAR::isError($installer->Install($package))) {
print "\ninstall failed\n";
} else {
print "install ok\n";
}
break;
case "package":
$pkginfofile = $options[1][2];
$packager =& new PEAR_Packager();
if (PEAR::isError($packager->Package($pkginfofile))) {
print "\npackage failed\n";
} else {
print "package ok\n";
}
break;
default:
usage();
break;
}
function usage($obj = null)
{
global $stderr;
if ($obj !== null) {
fputs($stderr, $obj->getMessage());
}
fputs($stderr,
"Usage: pear [-v n] [-h] command <parameters>\n".
"Options:\n".
" -v set verbosity level to <n> (0-2, default 1)\n".
" -h display help/usage (this message)\n".
"Commands:\n".
" install <package file>\n".
" package [package info file]\n".
"\n");
exit;
}
?>