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

namespace Gazelle;

require __DIR__ . '/../lib/bootstrap.php';

$twig = Util\Twig::factory(new Manager\User());

// there is no dump() in production
$twig->addFunction(new \Twig\TwigFunction('dump', function ($value) { return ''; }));

$exitcode = 0;

array_shift($argv);
foreach ($argv as $arg) {
    try {
        $twig->parse($twig->tokenize(new \Twig\Source(file_get_contents($arg), $arg)));
    } catch (\Twig\Error\SyntaxError $e) {
        echo "$arg: {$e->getMessage()}\n";
        $exitcode = 1;
    }
}

exit($exitcode);
