@zswarm/cli 0.1.1 → 0.1.2
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 +19 -4
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { ZellijError, cliUsage, dispatchZswarm, parseCliArgv } from "@zswarm/core";
|
|
2
|
+
import { ZellijError, cliUsage, dispatchZswarm, parseCliArgv, serveChildEnv, startServe, } from "@zswarm/core";
|
|
3
3
|
const argv = process.argv.slice(2);
|
|
4
4
|
if (argv.length === 0 || argv[0] === "-h" || argv[0] === "--help") {
|
|
5
5
|
process.stderr.write(cliUsage());
|
|
@@ -14,6 +14,21 @@ catch (err) {
|
|
|
14
14
|
process.stderr.write(`${message}\n${cliUsage()}`);
|
|
15
15
|
process.exit(2);
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
// TCP server holds the event loop; process.exit would tear it down.
|
|
18
|
+
if (args.op === "serve" && args.install !== true && args.clear !== true) {
|
|
19
|
+
const listen = typeof args.listen === "string" ? args.listen : undefined;
|
|
20
|
+
try {
|
|
21
|
+
const { label } = await startServe(listen, (request) => dispatchZswarm(request, undefined, { env: serveChildEnv(process.env) }));
|
|
22
|
+
process.stdout.write(`${JSON.stringify({ ok: true, data: { listening: label } }, null, 2)}\n`);
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
26
|
+
process.stdout.write(`${JSON.stringify({ ok: false, error: { code: "failed", message } }, null, 2)}\n`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const result = await dispatchZswarm(args);
|
|
32
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
33
|
+
process.exit(result.ok ? 0 : 1);
|
|
34
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zswarm/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "zSwarm CLI — list, send, dump Zellij panes",
|
|
6
6
|
"bin": {
|
|
7
7
|
"zswarm": "./dist/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@zswarm/core": "0.1.
|
|
10
|
+
"@zswarm/core": "0.1.2"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@types/node": "22.14.1",
|