cli-setu 0.2.2 → 0.2.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/bin/setu.js +7 -2
- package/package.json +1 -1
- package/src/stop.js +18 -1
package/bin/setu.js
CHANGED
|
@@ -60,7 +60,10 @@ async function main() {
|
|
|
60
60
|
}
|
|
61
61
|
case 'stop': {
|
|
62
62
|
const { stop } = require('../src/stop');
|
|
63
|
-
|
|
63
|
+
// args[1] (optional) - a specific sessionId to stop, copied from
|
|
64
|
+
// `cli-setu status`'s own output. Omitted stops every session on
|
|
65
|
+
// this computer, unchanged from before.
|
|
66
|
+
await stop(args[1]);
|
|
64
67
|
return;
|
|
65
68
|
}
|
|
66
69
|
case 'unpair': {
|
|
@@ -103,7 +106,9 @@ Usage:
|
|
|
103
106
|
(e.g. --cli claude, --cli codex)
|
|
104
107
|
cli-setu pair Pair this computer with your phone, nothing else
|
|
105
108
|
cli-setu status Show pairing status and any sessions running now
|
|
106
|
-
cli-setu stop Stop
|
|
109
|
+
cli-setu stop Stop every session running on this computer
|
|
110
|
+
cli-setu stop <sessionId> Stop just one session (see \`cli-setu status\`
|
|
111
|
+
for the exact id to use)
|
|
107
112
|
cli-setu unpair Unpair this computer (asks for confirmation)
|
|
108
113
|
cli-setu --version, -v Print the installed version
|
|
109
114
|
cli-setu --update Check for and install the latest version
|
package/package.json
CHANGED
package/src/stop.js
CHANGED
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
// a supervisor was closing its terminal window (or Ctrl+C, which only
|
|
4
4
|
// reaches the one you're actually looking at) - this reaches every
|
|
5
5
|
// running session at once via the same PID files status.js reads.
|
|
6
|
+
//
|
|
7
|
+
// `cli-setu stop <sessionId>` (new) - real gap found by testing: running
|
|
8
|
+
// several sessions at once (e.g. two different project folders) had no
|
|
9
|
+
// way to stop just ONE of them without killing all the others too -
|
|
10
|
+
// copy the exact sessionId from `cli-setu status`'s own output.
|
|
6
11
|
const fs = require('fs');
|
|
7
12
|
const { CONFIG_DIR } = require('./config');
|
|
8
13
|
|
|
9
|
-
async function stop() {
|
|
14
|
+
async function stop(targetSessionId) {
|
|
10
15
|
let files;
|
|
11
16
|
try {
|
|
12
17
|
files = fs.readdirSync(CONFIG_DIR).filter((f) => f.startsWith('session.') && f.endsWith('.pid'));
|
|
@@ -20,6 +25,7 @@ async function stop() {
|
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
let stopped = 0;
|
|
28
|
+
let matchedTarget = false;
|
|
23
29
|
for (const file of files) {
|
|
24
30
|
const pidFile = `${CONFIG_DIR}/${file}`;
|
|
25
31
|
let info;
|
|
@@ -28,6 +34,12 @@ async function stop() {
|
|
|
28
34
|
} catch {
|
|
29
35
|
continue;
|
|
30
36
|
}
|
|
37
|
+
|
|
38
|
+
// Only act on the one session asked for, if a target was given - every
|
|
39
|
+
// other running session is left completely untouched.
|
|
40
|
+
if (targetSessionId && info.sessionId !== targetSessionId) continue;
|
|
41
|
+
if (targetSessionId) matchedTarget = true;
|
|
42
|
+
|
|
31
43
|
try {
|
|
32
44
|
// SIGINT (not SIGKILL) - the same signal Ctrl+C sends, so the
|
|
33
45
|
// process's own handler (supervisor.js's process.on('SIGINT', ...))
|
|
@@ -43,6 +55,11 @@ async function stop() {
|
|
|
43
55
|
}
|
|
44
56
|
}
|
|
45
57
|
|
|
58
|
+
if (targetSessionId && !matchedTarget) {
|
|
59
|
+
console.log(`[cli-setu] No running session found with id "${targetSessionId}". Run \`cli-setu status\` to see what's running.`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
46
63
|
if (stopped === 0) {
|
|
47
64
|
console.log('[cli-setu] Sessions were already stopped (stale state cleaned up).');
|
|
48
65
|
}
|