From: Marcus Boerger Date: Wed, 16 May 2007 20:48:41 +0000 (+0000) Subject: - Add ability to extract a single value from info command X-Git-Tag: RELEASE_1_2_0~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e40ed58b017694a44436be4d3b4ced54af08b36a;p=php - Add ability to extract a single value from info command --- diff --git a/ext/phar/phar/pharcommand.inc b/ext/phar/phar/pharcommand.inc index 3ded80069f..975f9b0b05 100755 --- a/ext/phar/phar/pharcommand.inc +++ b/ext/phar/phar/pharcommand.inc @@ -743,17 +743,19 @@ class PharCommand extends CLICommand function cli_cmd_inf_info() { - return "Get information about a PHAR package."; + return "Get information about a PHAR package.\n" + . "Using -k it is possible to return a single value."; } function cli_cmd_arg_info() { - return self::phar_args('F', 'phar'); + return self::phar_args('Fk', 'phar'); } function cli_cmd_run_info($args) { $phar = $this->args['f']['val']; + $index = $this->args['k']['val']; $hash = $phar->getsignature(); $infos = array(); @@ -815,6 +817,16 @@ class PharCommand extends CLICommand $infos['Metadata-global'] = $phar->hasMetadata(); $infos['Metadata-files'] = $mcount; + if (isset($index)) + { + if (!isset($infos[$index])) + { + echo "Requested value does not exist."; + exit(1); + } + echo $infos[$index]; + exit(0); + } $l = 0; foreach($infos as $which => $val) {