]> granicus.if.org Git - php/commitdiff
- Add ability to extract a single value from info command
authorMarcus Boerger <helly@php.net>
Wed, 16 May 2007 20:48:41 +0000 (20:48 +0000)
committerMarcus Boerger <helly@php.net>
Wed, 16 May 2007 20:48:41 +0000 (20:48 +0000)
ext/phar/phar/pharcommand.inc

index 3ded80069f327af90251cb532eb76f0adfe50de8..975f9b0b05605cbd697e5921877c5ab9abd9361f 100755 (executable)
@@ -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)
                {