#!/usr/bin/env php
<?php

use function \Project\getDiff\getDiff;
use function \Project\getDiff\example;
use function \Project\getData\getData;

$path1 = __DIR__ . '/../vendor/autoload.php';
$path2 = __DIR__ . '/../../../autoload.php';
if (file_exists($path1)) {
  require $path1;
} else {
  require $path2;
}

$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 = file_exists($args['<firstFile>']) ? $args['<firstFile>'] : __DIR__ . "/" . $args['<firstFile>'];
$pathToFile2 = file_exists($args['<secondFile>']) ? $args['<secondFile>'] : __DIR__ . "/" . $args['<secondFile>'];
$data1 = getData($pathToFile1);
$data2 = getData($pathToFile2);
$diff = getDiff($data1, $data2);
echo($diff);
