Source for file Cli.php
Documentation is available at Cli.php
* CLI Script to generate text phpinfo() style PEAR information
* LICENSE: This source file is subject to version 3.01 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_01.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version CVS: $Id: Cli.php,v 1.2 2008/03/28 14:25:10 farell Exp $
* @link http://pear.php.net/package/PEAR_Info
* @since File available since Release 1.8.0
require_once 'PEAR/Info.php';
require_once 'Console/Getargs.php';
* CLI Script to display information about your PEAR installation
* require_once 'PEAR/Info/Cli.php';
* $cli = new PEAR_Info_Cli();
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.php.net/license/3_01.txt PHP License 3.01
* @version Release: 1.8.0
* @link http://pear.php.net/package/PEAR_Info
* @since Class available since Release 1.8.0
* @var array Current CLI Flags
* @var string error message
* @var object Console_Getargs instance
'desc' => 'PEAR directory',
'min' => 0 , 'max' => 1 ),
'desc' => 'User Configuration File',
'min' => 0 , 'max' => 1 ),
'desc' => 'System Configuration File',
'min' => 0 , 'max' => 1 ),
'desc' => 'HTTP Proxy Server Address',
'min' => 0 , 'max' => 1 ),
'desc' => 'Display informations for installed packages',
'min' => 0 , 'max' => 1 ),
'desc' => 'List packages from all channels, '
. 'not just the default one',
'desc' => 'Specify which channel',
'min' => 0 , 'max' => 1 ),
'desc' => 'Print version information',
'desc' => 'Show this help',
$this->args = & Console_Getargs ::factory ($this->opts);
if (PEAR ::isError ($this->args)) {
if ($this->args->getCode () === CONSOLE_GETARGS_HELP ) {
$options = array ('channels' => array ('pear.php.net'),
if ($this->args->isDefined ('pd')) {
$pear_dir = $this->args->getValue ('pd');
if ($this->args->isDefined ('uc')) {
$user_file = $this->args->getValue ('uc');
$this->error = 'Failed opening PEAR user configuration file "'
. '". Please check your spelling and try again.';
if ($this->args->isDefined ('sc')) {
$system_file = $this->args->getValue ('sc');
$this->error = 'Failed opening PEAR system configuration file "'
. '". Please check your spelling and try again.';
if ($this->args->isDefined ('hp')) {
$proxy = $this->args->getValue ('hp');
$this->error = 'Failed define Proxy Server Address.'
. ' Please check your spelling and try again.';
if ($this->args->isDefined ('a')) {
$a = $this->args->getValue ('a');
$options['resume'] = intval($a);
$this->error = "No valid 'resume' option for argument all."
. ' Please check your spelling and try again.';
$A = $this->args->getValue ('A');
$options['channels'] = array ();
if ($this->args->isDefined ('c')) {
$chan = $this->args->getValue ('c');
$options['channels'] = explode(',', $chan);
$this->error = 'No valid channel list provided.'
. ' Please check your spelling and try again.';
$V = $this->args->getValue ('V');
$this->error = 'PEAR_Info (cli) version 1.8.0'
. ' (http://pear.php.net/package/PEAR_Info)';
parent ::__construct ($pear_dir, $user_file, $system_file, $options);
* ZE1 PHP4 Compatible Constructor
if (isset ($this->error)) {
$this->_printUsage ($this->error);
// when Version asked, do not print help usage
foreach ($lines as $line) {
if (strlen($line) == 0 && $tdeps === false ) {
} elseif ($line == '<br />') {
} elseif (substr($line, 0 , 6 ) == '<a id=') {
} elseif (substr($line, 0 , 4 ) == '<h1>') {
// skip PEAR credits link
} elseif (substr($line, 0 , 4 ) == '<h2>') {
if (substr($line, 4 , 10 ) == '<a id="top') {
echo PHP_EOL . $td . PHP_EOL;
} elseif ($skip_table == 0 && $line == '<table>') {
} elseif ($line == '</table>') {
$td = PHP_EOL . implode(PHP_EOL , $deps);
} elseif ($skip_table == 0 && $line == '<tr>') {
} elseif ($skip_table == 0 && substr($line, 0 , 3 ) == '<tr') {
$tr_class = substr($line, 11 , 1 );
} elseif ($tr_class == 'h') {
} elseif ($skip_table == 0 && $line == '</tr>' && $tr_class != '') {
if ($tr_w[0 ] != 'Required') {
$td = $tr_w[1 ] . ' '. $tr_w[3 ] . ' '. $tr_w[4 ];
if ($tr_w[3 ] == 'has' || $tr_w[3 ] == 'not') {
$td = $tr_w[3 ] . ' '. $tr_w[2 ] . ' '. $tr_w[1 ] . ' '.
$td = $tr_w[2 ] . ' '. $tr_w[1 ] . ' '. $tr_w[3 ] . ' '.
echo $td[0 ] . ' => ' . $td[1 ] . PHP_EOL;
} elseif ($skip_table == 0 && $line == '</td>') {
} elseif ($skip_table == 0 && $line == '<td>') {
} elseif ($skip_table == 0 && substr($line, 0 , 3 ) == '<td') {
} elseif ($tr_class == 'v') {
if ($line == '<td class="e">') {
preg_match('`\<td(.*)\>(.*)\</td\>`', $line, $matches);
if (empty ($matches[2 ])) {
if (empty ($matches[1 ])) {
if ($line == '<table class="d">') {
* Show full help information
* @param string $footer (optional) page footer content
function _printUsage ($footer = '')
. basename($_SERVER['SCRIPT_NAME']) . " [options]\n\n";
echo Console_Getargs ::getHelp ($this->opts, $header,
" \n$footer\n" , 78 , 2 ). "\n";
Documentation generated on Fri, 18 Apr 2008 16:30:05 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|