Source for file pearcmd.php
Documentation is available at pearcmd.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available through the world-wide-web at the following url: |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Stig Bakken <ssb@php.net> |
// | Tomas V.V.Cox <cox@idecnet.com> |
// +----------------------------------------------------------------------+
// $Id: pearcmd.php,v 1.13.2.2 2004/12/30 05:43:18 cellog Exp $
if ('@include_path@' != '@'. 'include_path'. '@') {
ini_set('include_path', '@include_path@');
ini_set('magic_quotes_runtime', false );
$pear_package_version = "@pear_version@";
require_once 'PEAR/Config.php';
require_once 'PEAR/Command.php';
require_once 'Console/Getopt.php';
PEAR_Command ::setFrontendType ('CLI');
$all_commands = PEAR_Command ::getCommands ();
$argv = Console_Getopt ::readPHPArgv ();
/* $progname = basename($argv[0]); */
$options = Console_Getopt ::getopt2 ($argv, "c:C:d:D:Gh?sSqu:vV");
$options = Console_Getopt ::getopt ($argv, "c:C:d:D:Gh?sSqu:vV");
if (PEAR ::isError ($options)) {
if ($progname == 'gpear' || $progname == 'pear-gtk') {
foreach ($opts as $opt) {
PEAR_Command ::setFrontendType ($fetype);
$ui = &PEAR_Command ::getFrontendObject ();
$ui->outputData ('WARNING: running in safe mode requires that all files created ' .
'be the same uid as the current script. PHP reports this script is uid: ' .
$pear_system_config = '';
$store_user_config = false;
$store_system_config = false;
foreach ($opts as $opt) {
$pear_user_config = $opt[1 ];
$pear_system_config = $opt[1 ];
$config = &PEAR_Config ::singleton ($pear_user_config, $pear_system_config);
$verbose = $config->get ("verbose");
foreach ($opts as $opt) {
$param = !empty ($opt[1 ]) ? $opt[1 ] : true;
list ($key, $value) = explode('=', $param);
$config->set ($key, $value, 'user');
list ($key, $value) = explode('=', $param);
$config->set ($key, $value, 'system');
$store_user_config = true;
$store_system_config = true;
$config->remove ($param, 'user');
$config->set ('verbose', $config->get ('verbose') + 1 );
$config->set ('verbose', $config->get ('verbose') - 1 );
// all non pear params goes to the command
$cmdopts[$opt[0 ]] = $param;
if ($store_system_config) {
$config->store ('system');
if ($store_user_config) {
$command = (isset ($options[1 ][0 ])) ? $options[1 ][0 ] : null;
if (empty ($command) && ($store_user_config || $store_system_config)) {
if ($command == 'help') {
usage(null , @$options[1 ][1 ]);
$cmd = PEAR_Command ::factory ($command, $config);
PEAR ::popErrorHandling ();
if (PEAR ::isError ($cmd)) {
usage(null , @$options[1 ][1 ]);
$short_args = $long_args = null;
PEAR_Command ::getGetoptArgs ($command, $short_args, $long_args);
$tmp = Console_Getopt ::getopt2 ($options[1 ], $short_args, $long_args);
$tmp = Console_Getopt ::getopt ($options[1 ], $short_args, $long_args);
if (PEAR ::isError ($tmp)) {
list ($tmpopt, $params) = $tmp;
foreach ($tmpopt as $foo => $tmp2) {
list ($opt, $value) = $tmp2;
$value = true; // options without args
$cmdoptions = $cmd->getOptions ($command);
foreach ($cmdoptions as $o => $d) {
if (@$d['shortopt'] == $opt) {
if (substr($opt, 0 , 2 ) == '--') {
$opts[substr($opt, 2 )] = $value;
$ok = $cmd->run ($command, $opts, $params);
PEAR ::raiseError (" unknown command `$command'" );
function usage($error = null , $helpsubject = null )
global $progname, $all_commands;
$stderr = fopen('php://stderr', 'w');
if (PEAR ::isError ($error)) {
fputs($stderr, $error->getMessage () . "\n");
} elseif ($error !== null ) {
fputs($stderr, " $error\n" );
if ($helpsubject != null ) {
$formatstr = " %-{$maxlen}s %s\n";
foreach ($all_commands as $cmd => $class) {
$put .= sprintf($formatstr, $cmd, PEAR_Command ::getDescription ($cmd));
" Usage: $progname [options] command [command-options] <parameters>\n".
" Type \"$progname help options\" to list all options.\n".
" Type \"$progname help shortcuts\" to list all command shortcuts.\n".
" Type \"$progname help <command>\" to get the help for the specified command.";
fputs($stderr, " $put\n" );
global $progname, $all_commands, $config;
if ($command == "options") {
" -v increase verbosity level (default 1)\n".
" -q be quiet, decrease verbosity level\n".
" -c file find user configuration in `file'\n".
" -C file find system configuration in `file'\n".
" -d foo=bar set user config variable `foo' to `bar'\n".
" -D foo=bar set system config variable `foo' to `bar'\n".
" -G start in graphical (Gtk) mode\n".
" -s store user configuration\n".
" -S store system configuration\n".
" -u foo unset `foo' in the user configuration\n".
" -h, -? display help/usage (this message)\n".
" -V version information\n";
} elseif ($command == "shortcuts") {
$sc = PEAR_Command ::getShortcuts ();
foreach ($sc as $s => $c) {
$ret .= sprintf(" %-8s %s\n", $s, $c);
} elseif ($command == "version") {
return "PEAR Version: ". $GLOBALS['pear_package_version'].
} elseif ($help = PEAR_Command ::getHelp ($command)) {
return " $progname $command [options] $help\n";
return " $progname $command $help[0]";
return " $progname $command [options] $help[0]\n$help[1]";
return " Command '$command' is not valid, try 'pear help'";
return; // @silenced error
E_PARSE => "Parsing Error",
E_CORE_ERROR => "Core Error",
E_CORE_WARNING => "Core Warning",
E_COMPILE_ERROR => "Compile Error",
E_COMPILE_WARNING => "Compile Warning",
E_USER_ERROR => "User Error",
E_USER_WARNING => "User Warning",
E_USER_NOTICE => "User Notice"
$prefix = $errortype[$errno];
print " \n$prefix: $errmsg in $file on line $line\n";
Documentation generated on Mon, 11 Mar 2019 14:23:59 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|