tomk79/diffdir

这是一个命令,用于比较两个目录并报告检测到的差异。也可以作为库使用。

安装: 60

依赖关系: 0

建议者: 0

安全: 0

星数: 1

观察者: 2

分支: 0

开放问题: 3

语言:HTML

0.4.0 2017-05-07 15:17 UTC

This package is auto-updated.

Last update: 2024-09-25 15:35:13 UTC


README

diffdir 用于比较两个目录并提取有差异的文件。

比较的结果将被记录在CSV文件中,每行一个文件,并输出一个HTML文件,可以用来查看每个文件的差异。

安装步骤 - 安装

使用 composer 安装 diffdir。

$ cd {$yourDirectory}
$ composer create-project tomk79/diffdir ./

用法 - 用法

基本用法 - Basic usage.

$ php ./diffdir.php {$path_dirA} {$path_dirB}

示例:比较示例数据 - Example: diff of sample data.

$ php ./diffdir.php ./tests/sample_a/ ./tests/sample_b/

选项

-o 指定结果输出目录

使用 -o 选项并指定输出目录。

$ php ./diffdir.php -o ./result_sample/ ./tests/sample_a/ ./tests/sample_b/

--strip-crlf 忽略换行符

使用 --strip-crlf 选项进行比较时,将忽略仅包含换行符的差异。

$ php ./diffdir.php --strip-crlf ./tests/sample_a/ ./tests/sample_b/

-v 输出详细消息

使用 -v 选项进行比较时,将在终端上显示处理的详细信息。

$ php ./diffdir.php -v ./tests/sample_a/ ./tests/sample_b/

-q 不显示消息

使用 -q 选项进行比较时,将隐藏终端上的所有显示。

$ php ./diffdir.php -q ./tests/sample_a/ ./tests/sample_b/

在PHP脚本中使用

<?php
require_once( './vendor/autoload.php' );
$diffdir = new tomk79\diffdir(
	'/path/before/', // path before
	'/path/after/',  // path after
	array( // options
		'output'=>'/path/path_output_dir/', // -o
		'strip_crlf'=>true, // --strip-crlf
		'verbose'=>true // -v
	)
);
if( $diffdir->is_error() ){
	print 'ERROR.'."\n";
	var_dump( $diffdir->get_errors() );
}else{
	print 'success.'."\n";
	print ''."\n";
	print 'see: '.$diffdir->get_output_dir()."\n";
}

许可证 - License

MIT许可证

作者 - Author

附录 - Appendix

composer 的安装

有关 composer 的安装方法,请参阅 composer的官方站点(英文)

以下是从官方网站摘录的内容。仅供参考。

Mac 用户

Mac 用户可以使用以下命令进行全局安装。

$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer

Windows 用户

Windows 用户可以使用提供的GUI安装程序 Composer-Setup.exe 进行安装。您也可以使用以下命令进行安装,请根据您的喜好进行安装。

$ cd C:\bin
$ php -r "readfile('https://getcomposer.org/installer');" | php

开发者信息 - for Developer

测试 - Test

$ cd (project directory)
$ ./vendor/phpunit/phpunit/phpunit php/tests/diffdirTest