Cue interpreter for regRename

This commit is contained in:
斟酌 鵬兄 2017-02-27 13:23:21 +08:00
parent d22fc76b30
commit e1a8fd4822

View File

@ -1,46 +1,47 @@
<?php #!/usr/bin/env php
error_reporting ( E_ALL^E_NOTICE ) ; <?php
require_once dirname( __FILE__ ) . '/astropenguin/package.php'; error_reporting ( E_ALL^E_NOTICE ) ;
require_once dirname( __FILE__ ) . '/astropenguin/package.php';
use astropenguin\botanical\RegRename;
use astropenguin\botanical\Args; use astropenguin\botanical\RegRename;
use astropenguin\botanical\Args;
//----------- Usage -----------
//----------- Usage -----------
if ( !$argv[1] )
die (<<<__USAGE__ if ( !$argv[1] )
Usage: php {$argv[0]} [options] [-d directory] [-p patterns] [-s "first match" "second" ...] [...args] die (<<<__USAGE__
Usage: php {$argv[0]} [options] [-d directory] [-p patterns] [-s "first match" "second" ...] [...args]
-d <paths> Directories to look over
-p <patterns> Define RegEx patterns -d <paths> Directories to look over
-r Rename file recursively -p <patterns> Define RegEx patterns
-s <str ...> Strings that will replace the matches -r Rename file recursively
-s <str ...> Strings that will replace the matches
Optional:
-e <patterns> Exclude defined pattern Optional:
-l <File> Output log file -e <patterns> Exclude defined pattern
-t Test without modifying anything -l <File> Output log file
-t Test without modifying anything
Example:
php regRename.php -d ~/ -p "/(.+)_.+/" -s "\\1" Example:
php regRename.php -d ~/ -p "/(.+)_.+/" -s "\\1"
Result:
R File ".mysql_history" will be renamed to ".mysql" Result:
R File ".db_pass" will be renamed to ".db" R File ".mysql_history" will be renamed to ".mysql"
R File ".bash_logout" will be renamed to ".bash" R File ".db_pass" will be renamed to ".db"
R File ".mysql_pass" will be renamed to ".mysql" R File ".bash_logout" will be renamed to ".bash"
R File ".bash_history" will be renamed to ".bash" R File ".mysql_pass" will be renamed to ".mysql"
R File ".bash_history" will be renamed to ".bash"
php regRename.php -d ~/ -p "/(.+)_.+/" -s "\\1"
php regRename.php -d ~/ -p "/(.+)_.+/" -s "\\1"
__USAGE__
) ; __USAGE__
) ;
//------- End Usage -----------
//------- End Usage -----------
$rrgr = new RegRename();
Args::PARSE ( $argv, array($rrgr, 'setOption') ); $rrgr = new RegRename();
$rrgr->begin(); Args::PARSE ( $argv, array($rrgr, 'setOption') );
$rrgr->begin();