@noobdemon/noob-cli 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/repl.js +11 -2
package/package.json
CHANGED
package/src/repl.js
CHANGED
|
@@ -20,6 +20,14 @@ export async function startRepl(opts = {}) {
|
|
|
20
20
|
yolo: !!opts.yolo,
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
// Prompt = dòng trạng thái sống. Luôn phản ánh yolo + version theo thời gian
|
|
24
|
+
// thực (vẽ lại mỗi lượt và ngay khi Shift+Tab), nên không cần gõ /status.
|
|
25
|
+
const promptStr = (lead = true) => {
|
|
26
|
+
const nl = lead ? "\n" : "";
|
|
27
|
+
const yolo = state.yolo ? c.err("⚡ yolo ") : "";
|
|
28
|
+
return c.user(nl + t.promptYou) + yolo + c.dim("v" + CURRENT + " › ");
|
|
29
|
+
};
|
|
30
|
+
|
|
23
31
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout, prompt: "" });
|
|
24
32
|
let closed = false;
|
|
25
33
|
const queue = []; // lines typed/piped, consumed in order
|
|
@@ -64,7 +72,8 @@ export async function startRepl(opts = {}) {
|
|
|
64
72
|
process.stdin.on("keypress", (_str, key) => {
|
|
65
73
|
if (!key || key.name !== "tab" || !key.shift) return;
|
|
66
74
|
state.yolo = !state.yolo;
|
|
67
|
-
console.log(state.yolo ? c.err("
|
|
75
|
+
console.log(state.yolo ? c.err(" " + t.yoloOn) : c.ok(" " + t.yoloOff));
|
|
76
|
+
rl.setPrompt(promptStr(false)); // cập nhật dòng trạng thái ngay lập tức
|
|
68
77
|
rl.prompt(true);
|
|
69
78
|
});
|
|
70
79
|
}
|
|
@@ -126,7 +135,7 @@ export async function startRepl(opts = {}) {
|
|
|
126
135
|
|
|
127
136
|
// Main loop — runs until /exit, double Ctrl+C, or EOF. Never exits after a task.
|
|
128
137
|
while (true) {
|
|
129
|
-
const raw = await ask(
|
|
138
|
+
const raw = await ask(promptStr());
|
|
130
139
|
if (raw == null) break; // stdin fully closed and drained
|
|
131
140
|
const input = raw.trim();
|
|
132
141
|
if (!input) continue;
|