-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbash.js
More file actions
30 lines (27 loc) · 728 Bytes
/
bash.js
File metadata and controls
30 lines (27 loc) · 728 Bytes
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
const VSISSTUPID = require('./pwd.js');
const ls = require('./ls.js');
const cat = require('./cat.js');
const curl = require('./curl.js');
process.stdout.write('prompt > ');
process.stdin.on('data', (data) => {
const cmd = data.toString().trim();
process.stdout.write('You typed: ' + cmd + '\n');
if (cmd === 'pwd') {
VSISSTUPID();
} else if (cmd === 'ls') {
ls(done);
} else if (cmd.slice(0, 3) === 'cat') {
const file = cmd.slice(4);
cat(file, done);
} else if (cmd.includes('http')){
const file = cmd.slice(5);
curl(file);
}
else {
process.stdout.write('\nprompt > ');
}
});
function done(output){
process.stdout.write(output);
process.stdout.write('\nprompt > ');
}