diff --git a/cli.php b/cli.php index 3624c98..7540939 100644 --- a/cli.php +++ b/cli.php @@ -68,19 +68,52 @@ function cli__users($args) { echo $msg."\n"; } +function cli__cache($args) { + $help = function() { + cli__help(false); + echo ' cache prune|purge|delete Delete all application caches'."\n"; + die; + }; + $msg = null; + switch ($args[0]) { + case 'prune': + case 'purge': + case 'delete': + foreach (scandir(filedb_getdir('cache')) as $fil) { + if (in_array($fil, ['.','..'])) + continue; + filedb_del('cache', $fil); + } + $msg = 'Application cache has been succesfully purged'; + break; + case 'help': + default: + $help(); + } + if ($msg != nulL) + echo $msg."\n"; +} + function cli__help($full=true) { echo 'APub Control cli.php 1.0 author: bofh@nogafam.es'."\n"; echo "\n"; echo ' Parameters:'."\n"; if ($full === false) return; echo ' users Add/delete/modify web application users'."\n"; + echo ' cache Handle all the web application caches'."\n"; die; } +if (count($argv) <= 1) + cli__help(); + switch ($argv[1]) { case 'users': cli__users(array_slice($argv, 2)); break; + case 'cache': + cli__cache(array_slice($argv, 2)); + break; case 'help': cli__help(); break;