wx/generator.php

34 lines
582 B
PHP
Raw Normal View History

2024-04-26 01:32:06 +00:00
<?php
$base = file_get_contents(__DIR__."/src/base.sh");
$dirs = [
__DIR__.'/src/commands/*.sh',
__DIR__.'/src/commands/*/*.sh',
__DIR__.'/src/commands/*/*/*.sh'
];
$codes = [];
foreach($dirs as $dir){
foreach(glob($dir) as $file){
$codes[$file] = file_get_contents($file);
}
}
$code = str_replace("{{ COMMANDS }}", implode("\n", $codes), $base);
try {
2024-04-26 02:49:32 +00:00
$file = __DIR__.'/wx.tmp';
2024-04-26 01:32:06 +00:00
$file = fopen($file, "w");
fwrite($file, $code);
fclose($file);
echo "Status: Successful";
} catch (\Error $e) {
echo "Status: Failed";
}
?>