#!/usr/bin/php -q
<?php

require_once __DIR__ . '/../vendor/autoload.php';

$config = new \Gvera\Helpers\config\Config(__DIR__ . '/../config/config.yml');
\Gvera\Cache\Cache::setConfig($config);
$cache = \Gvera\Cache\Cache::getCache();

if (count($argv) < 2){
    echo 'wrong amount of parameters for this command';?>

    usage example: clear-cache 1
    <?php
    echo "Please select the option: \n";
    echo "--------------------------\n";
    echo "1 - Flush all\n";
    echo "2 - Flush DI Objects\n";
    echo "3 - Flush routes\n";
    echo "4 - Flush translations\n";
    echo "5 - Flush controller names\n";
    echo "--------------------------\n";
    exit(0);
}

switch ($argv[1]) {
    case 1:
        $cache->deleteAll();
        break;
    case 2:
        $cache->delete("gv_di");
        break;
    case 3:
        $cache->delete("gv_routes");
        break;
    case 4:
        if(!isset($argv[2])) {
            echo 'For flushing translations, please add the language parameter. i.e.: clear-cache 4 en';
            exit(0);
        }
        $cache->delete($argv[2] . "_gv_locale");
        break;
    case 5:
        $cache->delete("gv_controllers");
        break;
}

