/** * 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"); } }