-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepl.ts
More file actions
39 lines (31 loc) · 803 Bytes
/
repl.ts
File metadata and controls
39 lines (31 loc) · 803 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
31
32
33
34
35
36
37
38
39
import repl from "repl";
import chalk from "chalk";
import modules from "./modules";
import constants from "./constants";
console.log(chalk.blue(
`Welcome to Archnet!
Type .help to check what I can do for you.`
));
const replServer = repl.start({
prompt: "archnet > ",
input: process.stdin,
output: process.stdout,
});
replServer.on(constants.commands.exit, () => {
console.log(chalk.blue("Come back whenever you want to!"));
process.exit();
});
replServer.defineCommand(constants.commands.cls, {
help: "Using .cls will clear the console.",
action() {
console.clear();
this.displayPrompt();
}
});
replServer.defineCommand(constants.commands.ip, {
help: "Check your current IP address.",
async action() {
await modules.ip.getIp();
this.displayPrompt();
}
});