Escudo7/php-project-lvl2

View on GitHub
src/cli.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace Project\cli;

use function \Project\diff\getDiff;

function run()
{
    $doc = <<<DOC
Generate diff

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

Options:
  -h --help         Show this screen.
  --format <fmt>    Report format [default: pretty]

DOC;

    $args = Docopt::handle($doc);
    $pathToFile1 = realpath($args['<firstFile>']);
    $pathToFile2 = realpath($args['<secondFile>']);
    $format = $args['--format'];
    $diff = getDiff($pathToFile1, $pathToFile2, $format);
    echo $diff;
}