added caching read function

This commit is contained in:
Bryan Joshua Pedini 2021-04-25 22:28:26 +02:00
parent 7e33582e4d
commit d3deaeffdc
1 changed files with 7 additions and 0 deletions

View File

@ -63,6 +63,13 @@ ENDHELP;
function set_cache(array $modules): void {
file_put_contents(".cache", json_encode($modules));
}
function load_cache(): array|bool {
if(!is_file(".cache")) {
return FALSE;
}
$modules = json_decode(file_get_contents(".cache"), TRUE);
return $modules;
}
if(sizeof($argv) < 2 || !required_argument($argv[1])) _help($argv[0], "No <command> provided!\n\n"); // check for user input presence
switch($argv[1]) { // act according to said input