-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash.js
32 lines (29 loc) · 785 Bytes
/
bash.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const commands = require("./commands");
process.stdout.write("prompt > ");
process.stdin.on("data", (data) => {
const cmd = data.toString().trim();
const cmdArray = cmd.split(" ");
const comando = cmdArray[0];
const argumentos = cmdArray.slice(1);
// const catContenido = cat.split(" ")
// const argumentosCat = catContenido
if (cmd === "pwd") {
commands.pwd();
} else if (cmd === "date") {
commands.date();
} else if (cmd === "ls") {
commands.ls();
} else if (comando === "echo") {
commands.echo(argumentos);
}
else if(comando === "cat"){
commands.cat(argumentos)
}
else if(comando === "head"){
commands.head(argumentos)
}
else if(comando === "tail"){
commands.tail(argumentos)
}
process.stdout.write("prompt > ");
});