let chatReturn = '';
function initialize(user) {
console.log('==============================');
console.log(`Hello, ${user}; Using made JS OS`);
console.log('Type help to show command list');
console.log('==============================');
}
function cmd() {
chatReturn = prompt('>');
const args = chatReturn.split(' ');
const command = args[0];
switch (command) {
case 'help':
showHelp();
break;
case 'var':
handleVar(args);
break;
// Add more cases for other commands
default:
console.log('Unknown command. Type "help" to see the list of available commands.');
}
}
function showHelp() {
console.log('help => show this');
console.log('create [filename] => create new file');
console.log('edit [filename] => edit created file');
console.log('math [figure 1] [figure 2] [operator] => return math operation');
console.log('var [variable] => creates new variable');
console.log('set [variable] => edit variable value');
console.log('time => show time since the launch');
console.log('import => imports library from source code');
console.log('run [filename] => starts-up js code file');
console.log('log [message] => outputs message to console');
console.log('alc [var1 ] [var 2] [operator] => return variable math operation');
console.log('rnd => outputs random number (within 1) to console');
console.log('clr => clears console');
}
function handleVar(args) {
if (args.length < 2) {
console.log('Usage: var [variable]');
return;
}
console.log(`Creating variable: ${args[1]}`);
// Add logic to create/set the variable
}
function update() {
while (true) {
cmd();
}
}
initialize('TestUser');
update();