<?php
/**
* Boots JavaScript scripts based on CLI arguments for a legacy project.
*/
// Get CLI arguments
$argv = array_slice($argv, 1); // Remove script name
// Define argument mappings
$script_map = [
'script1' => 'scripts/script1.js',
'script2' => 'scripts/script2.js',
'script3' => 'scripts/script3.js',
];
// Check if arguments exist and map to scripts
foreach ($argv as $arg) {
if (isset($script_map[$arg])) {
$script_path = $script_map[$arg];
// Check if the script file exists
if (file_exists($script_path)) {
// Output the script tag
echo "<script src='" . $script_path . "'></script>\n";
} else {
echo "Error: Script file not found: " . $script_path . "\n";
}
} else {
echo "Error: Unknown script argument: " . $arg . "\n";
}
}
?>
Add your comment