aigroup-workflow 1.1.2 → 1.1.3
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/cli/utils/prompts.mjs +14 -9
- package/package.json +1 -1
package/cli/utils/prompts.mjs
CHANGED
|
@@ -88,19 +88,22 @@ export async function multiSelect(message, choices) {
|
|
|
88
88
|
return ` ${C.dim}↑↓ 移动${C.reset} ${C.dim}空格 选择${C.reset} ${C.dim}a 全选/取消${C.reset} ${C.dim}回车 确认${C.reset}`
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// 总行数 = 选项行 + 提示行
|
|
92
|
+
const totalLines = choices.length + 1
|
|
93
|
+
|
|
91
94
|
function render(isFirst) {
|
|
92
95
|
if (!isFirst) {
|
|
93
|
-
//
|
|
94
|
-
process.stdout.write(`\x1b[${
|
|
96
|
+
// 光标在提示行末尾,先回到行首,再回退所有行,清除下方
|
|
97
|
+
process.stdout.write(`\r\x1b[${totalLines}A\x1b[0J`)
|
|
95
98
|
}
|
|
96
99
|
for (const [i, c] of choices.entries()) {
|
|
97
|
-
|
|
100
|
+
process.stdout.write(renderLine(c, i) + '\n')
|
|
98
101
|
}
|
|
99
102
|
process.stdout.write(renderHint())
|
|
100
103
|
}
|
|
101
104
|
|
|
102
|
-
//
|
|
103
|
-
|
|
105
|
+
// 标题行
|
|
106
|
+
process.stdout.write(`\n ${C.cyan}?${C.reset} ${C.bold}${message}${C.reset} ${C.dim}(空格选择, 回车确认)${C.reset}\n`)
|
|
104
107
|
process.stdout.write(C.hideCursor)
|
|
105
108
|
render(true)
|
|
106
109
|
|
|
@@ -185,18 +188,20 @@ export async function select(message, choices) {
|
|
|
185
188
|
return ` ${C.dim}↑↓ 移动${C.reset} ${C.dim}回车 选择${C.reset}`
|
|
186
189
|
}
|
|
187
190
|
|
|
191
|
+
const totalLines = choices.length + 1
|
|
192
|
+
|
|
188
193
|
function render(isFirst) {
|
|
189
194
|
if (!isFirst) {
|
|
190
|
-
process.stdout.write(`\x1b[${
|
|
195
|
+
process.stdout.write(`\r\x1b[${totalLines}A\x1b[0J`)
|
|
191
196
|
}
|
|
192
197
|
for (const [i, c] of choices.entries()) {
|
|
193
|
-
|
|
198
|
+
process.stdout.write(renderLine(c, i) + '\n')
|
|
194
199
|
}
|
|
195
200
|
process.stdout.write(renderHint())
|
|
196
201
|
}
|
|
197
202
|
|
|
198
|
-
//
|
|
199
|
-
|
|
203
|
+
// 标题行
|
|
204
|
+
process.stdout.write(`\n ${C.cyan}?${C.reset} ${C.bold}${message}${C.reset}\n`)
|
|
200
205
|
process.stdout.write(C.hideCursor)
|
|
201
206
|
render(true)
|
|
202
207
|
|