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

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

if (!isset($argv[1])) {
    exit("You're missing a token");
}

// Check to see if we have an access.log we can parse
if (!file_exists($argv[2])) {
    echo 'We cannot find file file: '.$argv[2]."\n";
    exit;
}

$token = $argv[1];
$format = null;

$traffic = new \Grafite\MissionControl\TrafficService($token);

// Check if this has a custom format (apache)
if (isset($argv[3])) {
    $format = $argv[3];
}

$traffic->sendTraffic($argv[2], $format);
