From c86f0d9ec1df3ff0461624157572f90ba581aae4 Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Mon, 2 Mar 2020 00:32:07 +0800 Subject: [PATCH] feat: add complate function Signed-off-by: MiaoWoo --- packages/client/src/index.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index 810dd2bb..104d91ee 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -29,19 +29,29 @@ client.on('end', (resone) => { const rl = createInterface({ input: process.stdin, output: process.stdout, + completer: (line, func) => { + let args = line.split(' ') + let comp = args[args.length - 1] + client.once('tab_complete', (msg) => { + let mcts = msg.matches.filter(s => s) + func(null, [mcts, comp]) + }) + client.write('tab_complete', { + text: line + }) + }, terminal: true, prompt: '' }) -rl.on('line', function(line) { +rl.on('line', function (line) { switch (line) { case "": break; + case "write": + break; case "/respawn": client.write('client_command', { payload: 0 }) - // client.write("respawn", { - - // }) break; case "//reco": client.end("")