-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
62 lines (57 loc) · 2.29 KB
/
index.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const functions = require("./functions.js");
const settings = require("./settings.json");
const readline = require("readline");
const colors = require("colors");
const fs = require("fs");
require("./module/update/index.js");
require("cache-require-paths");
//create manage terminal
let rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
//welcome
console.log("\x1b[36m" + require("figlet").textSync(settings.welcome.name));
console.log("Выход с консоли командой exit".grey);
console.log("Авторы: Котик#9821 & E'ilas#9117".grey);
console.log("----------[Дополнительная информация]----------".gray);
if(settings["welcome"].size_byte == false && settings["language"].list == false) console.log("(Отсутствует)".gray);
if(settings["welcome"].size_byte == true){
console.log(`Размер ядра: ${size_byte(FileSize("."))}`.gray);
};
if(settings["language"].list == true){
console.log("There is no language support, only Russian".red);
settings["language"].list = false;
fs.writeFileSync("./settings.json",JSON.stringify(settings,null,4));
};
//press ctrl+C the exit or command exit
process.openStdin().on("keypress",function(chunk,key){
if(key && key.name === "c" && key.ctrl){
console.log(`Вы вышли с ${"Panel".green.bold}`);
process.exit(0);
};
});
const readLine = () => {
rl.question(`[${time()}]`.gray + "> ", (line) => {
if(line.startsWith("exit")){
console.log(`Вы вышли с ${"Panel".green.bold}`);
setTimeout(() => {
process.exit(1);
}, 1000);
return rl.close();
};
let command = line.split(" ")[0];
let args = line.split(" ").slice(1);
let commands = fs.readdirSync("./cmds/").map(fileName => fileName.slice(0, -3));
if(!line) return readLine();
if(!commands.includes(command)) console.log(`Команда ${command.bold} не найдена!`.red);
commands.forEach(fileName => {
if(command == fileName){
const temp = require(`./cmds/${fileName}`).run(args);
temp ? console.log(temp) : "";
};
});
setTimeout(() => readLine(), 10);
});
};
readLine();