From 73a083409548092dbb97d787a511c4f4b59737b5 Mon Sep 17 00:00:00 2001 From: Zjmainstay Date: Mon, 23 Dec 2024 02:32:10 +0800 Subject: [PATCH] support multi execute command like -x 'cmd1' -x 'cmd2' --- bin/wscat | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/wscat b/bin/wscat index 729a2b3..d7f6737 100755 --- a/bin/wscat +++ b/bin/wscat @@ -166,7 +166,9 @@ program .option('-w, --wait ', 'wait given seconds after executing command') .option( '-x, --execute ', - 'execute command after connecting (--connect only)' + 'execute command after connecting (--connect only)', + collect, + [] ) .parse(process.argv); @@ -282,7 +284,9 @@ if (programOptions.listen) { ws.on('open', () => { if (programOptions.execute) { - ws.send(programOptions.execute); + for (let index = 0; index < programOptions.execute.length; index++) { + ws.send(programOptions.execute[index]); + } setTimeout( () => { ws.close();