<?php
require_once(dirname(__FILE__) . '/controllers/GapsXmlController.php');
require_once(dirname(__FILE__) . '/controllers/MailController.php');

$config = parse_ini_file(dirname(__FILE__) . "/../../GAPS.ini");

if (substr($argv[1], -4) == ".csv") {
	$mailCtrl = new MailController($config);
	$mailCtrl->sendFiles($argv[1]);

} else {
	$generate = array('', 'generate', $argv[1]);
	if (count($argv) > 3) $generate[] = $argv[3];
	if (count($argv) > 4) $generate[] = $argv[4];

	GapsXmlController::Duration($config, array('', 'duration', $argv[1]));
	GapsXmlController::Generate($config, $generate);
	GapsXmlController::Summary($config, array('', 'summary', $argv[1], $argv[2]));
}

