From 1ab5a5e9cf115bcdf86df310409b0c6472be96de Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Sat, 12 May 2007 11:55:26 +0000 Subject: [PATCH] - Add get/setstub commands to phar.phar --- ext/phar/phar/pharcommand.inc | 55 +++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/ext/phar/phar/pharcommand.inc b/ext/phar/phar/pharcommand.inc index f949bf26b9..14788bfc59 100755 --- a/ext/phar/phar/pharcommand.inc +++ b/ext/phar/phar/pharcommand.inc @@ -16,9 +16,14 @@ */ class PharCommand extends CLICommand { - function cli_get_SP2($l1, $l2, $arg_inf) + function cli_get_SP2($l1, $arg_inf) { - return str_repeat(' ', $l1 + 2 + 17); + return str_repeat(' ', $l1 + 2 + 4 + 9); + } + + function cli_get_SP3($l1, $l2, $arg_inf) + { + return str_repeat(' ', $l1 + 2 + 4 + 9 + 2 + $l2 + 2); } static function phar_args($which, $phartyp) @@ -28,7 +33,7 @@ class PharCommand extends CLICommand 'c' => array('typ'=>'select', 'val'=>NULL, 'inf'=>' Compression algorithmus.', 'select'=>array('gz'=>'GZip compression','gzip'=>'GZip compression','bzip2'=>'BZip2 compression','bz'=>'BZip2 compression','bz2'=>'BZip2 compression','0'=>'No compression','none'=>'No compression')), 'f' => array('typ'=>$phartyp, 'val'=>NULL, 'inf'=>' Specifies the phar file to work on.'), 'i' => array('typ'=>'regex', 'val'=>NULL, 'inf'=>' Specifies a regular expression for input files.'), - 's' => array('typ'=>'file', 'val'=>NULL, 'inf'=>' Select the stub file (excluded from list of input files/dirs).'), + 's' => array('typ'=>'file', 'val'=>NULL, 'inf'=>' Select the stub file.'), 'x' => array('typ'=>'regex', 'val'=>NULL, 'inf'=>' Regular expression for input files to exclude.'), ); $args = array(); @@ -107,13 +112,15 @@ class PharCommand extends CLICommand static function cli_cmd_inf_pack() { - return "Pack files into a PHAR archive."; + return "Pack files into a PHAR archive.\n" + . "When using -s , then the stub file is being excluded from the list of input files/dirs." + ; } static function cli_cmd_arg_pack() { - $args = self::phar_args('AcFrsx', 'pharnew'); - $args[''] = array('typ'=>'any', 'val'=>NULL, 'required'=>1, 'inf'=>' Any number of input files and directories.'); + $args = self::phar_args('AcFisx', 'pharnew'); + $args[''] = array('typ'=>'any', 'val'=>NULL, 'required'=>1, 'inf'=>' Any number of input files and directories. If -i is in use then ONLY files and matching thegiven regular expression are being packed. If -x is given then files matching that regular expression are NOT being packed.'); return $args; } @@ -329,6 +336,42 @@ class PharCommand extends CLICommand echo " ...ok\n"; } } + + function cli_cmd_inf_setstub() + { + return "Set the stub of a PHAR file.\n"; + } + + function cli_cmd_arg_setstub() + { + return self::phar_args('Fs', 'phar'); + } + + function cli_cmd_run_setstub() + { + $phar = $args['f']['val']; + $stub = $this->args['s']['val']; + + $phar->setStub(file_get_contents($stub)); + } + + function cli_cmd_inf_getstub() + { + return "Get the stub of a PHAR file.\n"; + } + + function cli_cmd_arg_getstub() + { + return self::phar_args('Fs', 'phar'); + } + + function cli_cmd_run_getstub() + { + $phar = $args['f']['val']; + $stub = $this->args['s']['val']; + + file_put_contents($stub, $phar->getStub()); + } } ?> \ No newline at end of file -- 2.40.0