/** * The doSize method * * @param mixed $command instance of command object * @param mixed $options the command options * @param mixed $params the command parameters (for the options) * * @access public * @return void */ public function doSize($command, $options, $params) { $altered = array(); foreach ($options as $option => $value) { $altered[] = array($option, $value); } $ar = array($altered, $params); $cli = new PEAR_Size_CLI(); $cli->setAppName('pear size'); return $cli->run($ar); }
/** * Usage * * Display either given error message, which can be in an array, or * the usage screen. * * @param mixed $error string or array of strings of error messages to display. If * null, which is the default, the usage screen is displayed. * * @access public * @return void */ public function usage($error = null) { $app = PEAR_Size_CLI::appName(); if (PEAR::isError($error)) { fputs(STDERR, $error->getMessage() . "\n"); fputs(STDERR, "\n"); } elseif ($error !== null && $error !== 'usage') { if (is_array($error)) { foreach ($error as $message) { fputs(STDERR, "{$message}\n"); } } else { fputs(STDERR, "{$error}\n"); } fputs(STDERR, "\n"); } elseif ($error === null || $error == 'usage') { fputs(STDOUT, "Usage: {$app} [OPTIONS] [PACKAGE]\n"); fputs(STDOUT, "Display information on how much space an installed "); fputs(STDOUT, "PEAR package required.\n\n"); fputs(STDOUT, " -a, --all "); fputs(STDOUT, "display information for all installed packages\n"); fputs(STDOUT, " -A, --allchannels "); fputs(STDOUT, "list packages from all channels, "); fputs(STDOUT, "not just the default one\n"); fputs(STDOUT, " -c, --channel specify which channel\n"); fputs(STDOUT, " -C, --csv output results in CSV format "); fputs(STDOUT, "(sizes are measured in bytes).\n"); fputs(STDOUT, " -h, --human-readable print sizes in human readable "); fputs(STDOUT, "format (for example: 492 B 1KB 7MB)\n"); fputs(STDOUT, " -H, --si "); fputs(STDOUT, "likewise, but use powers of 1000 not 1024\n"); fputs(STDOUT, " -t, --type "); fputs(STDOUT, "specify what type of files are required "); fputs(STDOUT, "for the report\n"); fputs(STDOUT, " by default all "); fputs(STDOUT, "types are assumed\n"); fputs(STDOUT, " -s, --summarise display channel summary view\n"); fputs(STDOUT, " -S, --fsort sort by file size\n"); fputs(STDOUT, " -v, --verbose "); fputs(STDOUT, "display more detailed information\n"); fputs(STDOUT, " --help display this help and exit\n"); fputs(STDOUT, " -V, --version "); fputs(STDOUT, "output version information and exit\n"); fputs(STDOUT, " -X, --xml output results in XML format\n"); fputs(STDOUT, " -0, --killzero do not output zero "); fputs(STDOUT, "values in verbose mode\n"); fputs(STDOUT, "\nTypes:\n"); fputs(STDOUT, "You can specify a subset of roles/file-types to be "); fputs(STDOUT, "listed in the report.\n"); fputs(STDOUT, "These roles are those as supported "); fputs(STDOUT, "by the PEAR installer.\n"); fputs(STDOUT, "These are: data, doc, ext, php, script, src, test\n"); fputs(STDOUT, "\nExamples:\n \$ {$app} --all\n \$ {$app} Console_Table\n \$ {$app} -ttest,doc Console_Table\n \$ {$app} --type=test,doc,php -h Console_Table Date_Holidays\n"); } }
<?php /** * PEAR_Size determines how much filespace is consumed by each PEAR package. * Information can be displayed on a channel-by-channel basis and can be * drilled down to the role/filetype of each installed file. * * PHP Version 5 * * @category PEAR * @package PEAR_Size * @author Ken Guest <*****@*****.**> * @license LGPL (see http://www.gnu.org/licenses/lgpl.html) * @version CVS: $Id$ * @link pearsize.php * * $ pearsize --all * $ pearsize Console_Table * $ pearsize Console_Table --type=test,doc */ /** * Neded to parse options on command line */ require 'Console/Getopt.php'; if (is_file(dirname(__FILE__) . "/../Size/Size.php") === true) { include dirname(__FILE__) . "/../Size/Size.php"; } else { include 'PEAR/Size.php'; include 'PEAR/Size/CLI.php'; } $cli = new PEAR_Size_CLI(); exit($cli->run());