Playground: support ?cmd= URL parameter to run commands on load

This commit is contained in:
Sylvestre Ledru
2026-04-04 11:20:21 +02:00
parent adb9c19c51
commit 2cbd80d6fd
+9 -1
View File
@@ -748,7 +748,15 @@ async function initPlayground(containerId) {
terminal.writeln("Type \x1b[1;32mhelp\x1b[0m for available commands.");
}
prompt();
// Run command(s) from URL ?cmd= parameter if present
const urlCmd = new URLSearchParams(window.location.search).get("cmd");
if (urlCmd) {
for (const cmd of urlCmd.split("\n")) {
if (cmd.trim()) await runInTerminal(cmd.trim());
}
} else {
prompt();
}
}
/**