vadshevy/php-project-lvl2

View on GitHub
bin/gendiff

Summary

Maintainability
Test Coverage
#!/usr/bin/env php
<?php

use function  Gendiff\differ\gendiff;

$autoloadPath1 = __DIR__ . '/../../../autoload.php';
$autoloadPath2 = __DIR__ . '/../vendor/autoload.php';
if (file_exists($autoloadPath1)) {
    require_once $autoloadPath1;
} else {
    require_once $autoloadPath2;
}

$doc = <<<'DOC'
Generate diff.

Usage:
    gendiff (-h|--help)
    gendiff (-v|--version)
    gendiff [--format <fmt>] <firstFile> <secondFile>
Options:
    -h --help                     Show this screen
    -v --version                  Show version
    -f --format <fmt>             Report format. Available formats: pretty, plain, json

DOC;

$opts = Docopt::handle($doc, array('version' => '0.1'));


$filePath1 = $opts['<firstFile>'];
$filePath2 = $opts['<secondFile>'];
$format = $opts['--format'];

$diff = gendiff($filePath1, $filePath2, $format);
print_r($diff);