MCPcopy Create free account
hub / github.com/antvis/AVA / ask

Function ask

src/cli/feishu.ts:22–55  ·  view source on GitHub ↗
(label: string, echo: boolean)

Source from the content-addressed store, hash-verified

20}
21
22function ask(label: string, echo: boolean) {
23 process.stderr.write(label);
24 const input = process.stdin;
25 input.setRawMode(true);
26 input.resume();
27 return new Promise<string>((resolve) => {
28 let value = '';
29 const onData = (chunk: Buffer) => {
30 const key = chunk.toString();
31 if (key === '\u0003') {
32 input.setRawMode(false);
33 process.exit(130);
34 }
35 if (key === '\r' || key === '\n') {
36 input.setRawMode(false);
37 input.pause();
38 input.off('data', onData);
39 process.stderr.write('\n');
40 resolve(value);
41 return;
42 }
43 if (key === '\u007f' || key === '\b') {
44 if (!value) return;
45 value = value.slice(0, -1);
46 if (echo) process.stderr.write('\b \b');
47 return;
48 } else {
49 value += key;
50 if (echo) process.stderr.write(key);
51 }
52 };
53 input.on('data', onData);
54 });
55}
56
57export function feishuBindError(code: unknown, msg: unknown): Error {
58 return new Error(`飞书应用绑定失败: ${String(code ?? 'unknown')} ${String(msg ?? '')}`);

Callers 1

bindFeishuFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected