termbeam 1.13.6 → 1.14.0
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/termbeam.js +2 -1
- package/package.json +1 -1
- package/src/cli/index.js +1 -1
- package/src/cli/resume.js +13 -2
package/bin/termbeam.js
CHANGED
|
@@ -16,7 +16,8 @@ if (subcommand === 'service') {
|
|
|
16
16
|
});
|
|
17
17
|
} else if (subcommand === 'list') {
|
|
18
18
|
const { list } = require('../src/cli/resume');
|
|
19
|
-
|
|
19
|
+
const listArgs = process.argv.slice(3);
|
|
20
|
+
list({ json: listArgs.includes('--json') }).catch((err) => {
|
|
20
21
|
console.error(err.message);
|
|
21
22
|
process.exit(1);
|
|
22
23
|
});
|
package/package.json
CHANGED
package/src/cli/index.js
CHANGED
|
@@ -11,7 +11,7 @@ termbeam — Beam your terminal to any device
|
|
|
11
11
|
Usage:
|
|
12
12
|
termbeam [options] [shell] [args...]
|
|
13
13
|
termbeam resume [name] [options] Reconnect to a running session (alias: attach)
|
|
14
|
-
termbeam list
|
|
14
|
+
termbeam list [--json] List running sessions
|
|
15
15
|
termbeam service <action> Manage as a background service (PM2)
|
|
16
16
|
|
|
17
17
|
Actions (service):
|
package/src/cli/resume.js
CHANGED
|
@@ -315,8 +315,8 @@ async function resume(args) {
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
async function list() {
|
|
319
|
-
log.info('Listing sessions');
|
|
318
|
+
async function list(options = {}) {
|
|
319
|
+
if (!options.json) log.info('Listing sessions');
|
|
320
320
|
const saved = readConnectionConfig();
|
|
321
321
|
const host = (saved && saved.host) || 'localhost';
|
|
322
322
|
const port = (saved && saved.port) || 3456;
|
|
@@ -345,6 +345,10 @@ async function list() {
|
|
|
345
345
|
process.exit(1);
|
|
346
346
|
}
|
|
347
347
|
} else if (err.code === 'ECONNREFUSED') {
|
|
348
|
+
if (options.json) {
|
|
349
|
+
console.log('[]');
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
348
352
|
console.log(dim(' No TermBeam server is running.'));
|
|
349
353
|
return;
|
|
350
354
|
} else {
|
|
@@ -353,6 +357,11 @@ async function list() {
|
|
|
353
357
|
}
|
|
354
358
|
}
|
|
355
359
|
|
|
360
|
+
if (options.json) {
|
|
361
|
+
console.log(JSON.stringify(sessions));
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
|
|
356
365
|
if (sessions.length === 0) {
|
|
357
366
|
console.log(dim(` Connected to server on ${displayUrl} — no active sessions.`));
|
|
358
367
|
return;
|
|
@@ -381,6 +390,8 @@ async function list() {
|
|
|
381
390
|
);
|
|
382
391
|
}
|
|
383
392
|
console.log('');
|
|
393
|
+
console.log(dim(' Tip: use --json for machine-readable output'));
|
|
394
|
+
console.log('');
|
|
384
395
|
}
|
|
385
396
|
|
|
386
397
|
module.exports = {
|