const { exec } = require('child_process');
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout,
});
/**
* Teardown function for debugging HTML documents.
* Executes the specified command in the shell.
* @param {string} command The command to execute.
*/
function teardown(command) {
console.log(`Executing: ${command}`);
exec(command, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
if (stderr) {
console.error(`exec stderr: ${stderr}`);
}
console.log(`exec stdout: ${stdout}`);
});
}
/**
* CLI interface for teardown commands.
*/
function cli() {
readline.question('Enter teardown command (or "exit"): ', (command) => {
if (command === 'exit') {
readline.close();
return;
}
teardown(command);
cli(); // Continue prompting for commands
});
}
// Start the CLI
cli();
Add your comment