summaryrefslogtreecommitdiff
path: root/pear/scripts/pear.in
blob: 7025befba148cb4b0348b651855842c80dac37a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!@prefix@/bin/php -q
<?php // -*- C++ -*-

require_once "PEAR.php";
require_once "PEAR/Installer.php";

error_reporting(7);

$stderr = fopen("php://stderr", "w");

$debug = 1;
$optind = 1;

while ($optind < $argc && $argv[$optind][0] == "-") {
    switch (substr($argv[$optind], 1)) {
        case "v":
            $debug = (int)$argv[++$optind];
            break;
        case "-":
            $optind++;
            break 2;
        default:
            fputs($stderr, "Unknown option: $argv[$optind]\n");
            /* fall through */
        case "?":
        case "h":
            usage();
            break;
    }
    
    $optind++;
}

$pkgfile = $argv[$optind];

if (!$pkgfile) {
    usage();
}

$p = new PEAR_Installer();
$p->debug = $debug;
$p->install($pkgfile);

function usage()
{
    global $stderr;
    fputs($stderr,
          "Usage: pear [-v n] [-h] <package>\n".
          "Options:\n".
          "     -v   set verbosity level to <n> (0-2, default 1)\n".
          "     -h   display help/usage (this message)\n");
    fclose($stderr);
    exit;
}

?>