MT-cod/php-project-lvl2

View on GitHub
bin/gendiff

Summary

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

namespace Differ\Differ;

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

$doc = <<<'DOCOPT'
Compares two configuration files and shows a difference.

Usage:
  gendiff (-h|--help)
  gendiff (-v|--version)
  gendiff [-f|--format <fmt>] <firstFile> <secondFile>

Options:
  -h --help                     Show this screen
  -v --version                  Show version
  -f --format <fmt>             Report format [default: stylish]
DOCOPT;

$startingParams = \Docopt::handle($doc, array('version'=>'v1.0.1'));

$pathToFile1 = $startingParams['<firstFile>'];
$pathToFile2 = $startingParams['<secondFile>'];
//['--format'][0] - ключ значения формата вывода результата работы gendiff по Docopt-у
$outputFormat = $startingParams['--format'][0];

echo(genDiff($pathToFile1, $pathToFile2, $outputFormat));