From 9bee3510eaf3d8bfc198ff1bcb22cdacf6f41690 Mon Sep 17 00:00:00 2001 From: "Tomas V.V.Cox" Date: Thu, 21 Mar 2002 11:33:54 +0000 Subject: [PATCH] readd the "list" command --- pear/PEAR/Command/List.php | 89 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 pear/PEAR/Command/List.php diff --git a/pear/PEAR/Command/List.php b/pear/PEAR/Command/List.php new file mode 100644 index 0000000000..489a4bc6d6 --- /dev/null +++ b/pear/PEAR/Command/List.php @@ -0,0 +1,89 @@ + | +// +----------------------------------------------------------------------+ +// +// $Id$ + +require_once "PEAR/Command/Common.php"; +require_once "PEAR/Registry.php"; + +/** + * PEAR commands for managing configuration data. + * + */ +class PEAR_Command_List extends PEAR_Command_Common +{ + // {{{ properties + // }}} + + // {{{ constructor + + /** + * PEAR_Command_Config constructor. + * + * @access public + */ + function PEAR_Command_List(&$ui, &$config) + { + parent::PEAR_Command_Common($ui, $config); + } + + // }}} + + // {{{ getCommands() + + /** + * Return a list of all the commands defined by this class. + * @return array list of commands + * @access public + */ + function getCommands() + { + return array('list'); + } + + // }}} + // {{{ run() + + function run($command, $params) + { + $reg = new PEAR_Registry(); // XXX Use config here + $installed = $reg->packageInfo(); + $i = $j = 0; + ob_start(); + heading("Installed packages:"); + foreach ($installed as $package) { + if ($i++ % 20 == 0) { + if ($j++ > 0) { + print "\n"; + } + printf("%-20s %-10s %s\n", + "Package", "Version", "State"); + print str_repeat("-", 75)."\n"; + } + printf("%-20s %-10s %s\n", $package['package'], + $package['version'], $package['release_state']); + } + $output = ob_get_contents(); + ob_end_clean(); + $lines = explode("\n", $output); + foreach ($lines as $line) { + $this->ui->displayLine($line); + } + } +} +?> \ No newline at end of file -- 2.40.0