@openxiaobu/codexl 0.1.9 → 0.1.11
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/dist/cli.js +21 -6
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -72,14 +72,27 @@ async function handleInteractiveToggle() {
|
|
|
72
72
|
const accounts = [...config.accounts].sort((a, b) => a.name.localeCompare(b.name));
|
|
73
73
|
let cursor = 0;
|
|
74
74
|
let changed = false;
|
|
75
|
+
let renderedLines = 0;
|
|
75
76
|
const render = () => {
|
|
76
|
-
|
|
77
|
+
const lines = [];
|
|
78
|
+
lines.push("空格切换选中账号启用状态,回车确认,q 退出:");
|
|
77
79
|
for (let i = 0; i < accounts.length; i += 1) {
|
|
78
80
|
const account = accounts[i];
|
|
79
81
|
const prefix = i === cursor ? ">" : " ";
|
|
80
82
|
const checkbox = account.enabled ? "[x]" : "[ ]";
|
|
81
|
-
|
|
83
|
+
lines.push(`${prefix} ${checkbox} ${account.name} (${account.codex_home})`);
|
|
82
84
|
}
|
|
85
|
+
// 首次渲染时先换一行,避免粘在上一行输出后面。
|
|
86
|
+
if (renderedLines === 0) {
|
|
87
|
+
process.stdout.write("\n");
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
// 将光标移动到上一轮渲染块的起始行。
|
|
91
|
+
process.stdout.write(`\x1b[${renderedLines}A`);
|
|
92
|
+
}
|
|
93
|
+
renderedLines = lines.length;
|
|
94
|
+
process.stdout.write(lines.join("\n"));
|
|
95
|
+
process.stdout.write("\n");
|
|
83
96
|
};
|
|
84
97
|
const applyChanges = () => {
|
|
85
98
|
if (!changed)
|
|
@@ -112,10 +125,12 @@ async function handleInteractiveToggle() {
|
|
|
112
125
|
return;
|
|
113
126
|
}
|
|
114
127
|
if (key.name === "return" || key.name === "enter") {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
128
|
+
if (changed) {
|
|
129
|
+
applyChanges();
|
|
130
|
+
changed = false;
|
|
131
|
+
render();
|
|
132
|
+
console.log("\n已保存账号启用状态变更(按 q 退出)。");
|
|
133
|
+
}
|
|
119
134
|
return;
|
|
120
135
|
}
|
|
121
136
|
if (key.name === "q" || (key.ctrl && key.name === "c")) {
|