<?php

if(php_sapi_name() !== 'cli') {
    echo 'Command line only' . PHP_EOL;
}

$availableCommands = [
    'cache:clear' => 'Clear all application cache',
    'cache:clear pdo' => 'Clear pdo cache',
    'cache:clear custom' => 'Clear custom cache',
    'cache:clear fast-route' => 'Clear fast route cache',
];

if(!isset($argv[1])) {
    echo 'Please enter a command' . PHP_EOL;
    return;
}

switch($argv[1]) {
    case 'cache:clear':
        include 'core/cli/clear-cache.php';
        clearCache(isset($argv[2]) ? $argv[2] : null);
    break;

    default:
        echo PHP_EOL . 'Available commands:' . PHP_EOL . PHP_EOL;
        foreach($availableCommands as $command => $description) {
            echo "php fast-mvc {$command} - {$description}" . PHP_EOL;
        }
        echo PHP_EOL;
}