@xiangyixie/dsh-superagent 0.9.2 → 0.10.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/watch.js CHANGED
@@ -1,57 +1,57 @@
1
- #!/usr/bin/env node
2
- /**
3
- * `dsh-superagent-watch` — live terminal panel over the run store.
4
- *
5
- * The panel reads the same files the host writes, so it works from a separate
6
- * terminal, against a remote-mounted state directory, or after the host that
7
- * started the runs has gone.
8
- */
9
- import { DEFAULT_INTERVAL_MS, watch } from '../lib/watch.js'
10
-
11
- const USAGE = `Usage: dsh-superagent-watch [options]
12
-
13
- Draw one line per run, refreshed in place, until Ctrl-C.
14
-
15
- Options:
16
- --state-dir <path> run state directory (default: $DSH_HOME/state/superagent)
17
- --interval <ms> refresh interval (default: ${DEFAULT_INTERVAL_MS})
18
- --once print one frame and exit (for logs and pipes)
19
- --no-color never emit ANSI colour
20
- -h, --help show this message`
21
-
22
- /** Read one value that follows a flag, or fail with the usage text. */
23
- function valueOf(argv, index, flag) {
24
- const value = argv[index]
25
- if (value === undefined || value.startsWith('--')) {
26
- console.error(`${flag} needs a value\n\n${USAGE}`)
27
- process.exit(2)
28
- }
29
- return value
30
- }
31
-
32
- function parse(argv) {
33
- const options = { intervalMs: DEFAULT_INTERVAL_MS }
34
- for (let index = 0; index < argv.length; index++) {
35
- const arg = argv[index]
36
- if (arg === '--state-dir') options.stateDir = valueOf(argv, ++index, '--state-dir')
37
- else if (arg.startsWith('--state-dir=')) options.stateDir = arg.slice('--state-dir='.length)
38
- else if (arg === '--interval') options.intervalMs = Number(valueOf(argv, ++index, '--interval'))
39
- else if (arg.startsWith('--interval=')) options.intervalMs = Number(arg.slice('--interval='.length))
40
- else if (arg === '--once') options.once = true
41
- else if (arg === '--no-color') options.color = false
42
- else if (arg === '-h' || arg === '--help') {
43
- console.log(USAGE)
44
- process.exit(0)
45
- } else {
46
- console.error(`unknown argument: ${arg}\n\n${USAGE}`)
47
- process.exit(2)
48
- }
49
- }
50
- if (!Number.isFinite(options.intervalMs) || options.intervalMs <= 0) {
51
- console.error(`--interval must be a positive number of milliseconds\n\n${USAGE}`)
52
- process.exit(2)
53
- }
54
- return options
55
- }
56
-
57
- await watch(parse(process.argv.slice(2)))
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `dsh-superagent-watch` — live terminal panel over the run store.
4
+ *
5
+ * The panel reads the same files the host writes, so it works from a separate
6
+ * terminal, against a remote-mounted state directory, or after the host that
7
+ * started the runs has gone.
8
+ */
9
+ import { DEFAULT_INTERVAL_MS, watch } from '../lib/watch.js'
10
+
11
+ const USAGE = `Usage: dsh-superagent-watch [options]
12
+
13
+ Draw one line per run, refreshed in place, until Ctrl-C.
14
+
15
+ Options:
16
+ --state-dir <path> run state directory (default: $DSH_HOME/state/superagent)
17
+ --interval <ms> refresh interval (default: ${DEFAULT_INTERVAL_MS})
18
+ --once print one frame and exit (for logs and pipes)
19
+ --no-color never emit ANSI colour
20
+ -h, --help show this message`
21
+
22
+ /** Read one value that follows a flag, or fail with the usage text. */
23
+ function valueOf(argv, index, flag) {
24
+ const value = argv[index]
25
+ if (value === undefined || value.startsWith('--')) {
26
+ console.error(`${flag} needs a value\n\n${USAGE}`)
27
+ process.exit(2)
28
+ }
29
+ return value
30
+ }
31
+
32
+ function parse(argv) {
33
+ const options = { intervalMs: DEFAULT_INTERVAL_MS }
34
+ for (let index = 0; index < argv.length; index++) {
35
+ const arg = argv[index]
36
+ if (arg === '--state-dir') options.stateDir = valueOf(argv, ++index, '--state-dir')
37
+ else if (arg.startsWith('--state-dir=')) options.stateDir = arg.slice('--state-dir='.length)
38
+ else if (arg === '--interval') options.intervalMs = Number(valueOf(argv, ++index, '--interval'))
39
+ else if (arg.startsWith('--interval=')) options.intervalMs = Number(arg.slice('--interval='.length))
40
+ else if (arg === '--once') options.once = true
41
+ else if (arg === '--no-color') options.color = false
42
+ else if (arg === '-h' || arg === '--help') {
43
+ console.log(USAGE)
44
+ process.exit(0)
45
+ } else {
46
+ console.error(`unknown argument: ${arg}\n\n${USAGE}`)
47
+ process.exit(2)
48
+ }
49
+ }
50
+ if (!Number.isFinite(options.intervalMs) || options.intervalMs <= 0) {
51
+ console.error(`--interval must be a positive number of milliseconds\n\n${USAGE}`)
52
+ process.exit(2)
53
+ }
54
+ return options
55
+ }
56
+
57
+ await watch(parse(process.argv.slice(2)))
package/cordis.patch.yml CHANGED
@@ -1,9 +1,9 @@
1
- # dsh-superagent bundle layer.
2
- #
3
- # Inserts one tools-only plugin row at PROFILE scope, so every session in the
4
- # profile can start a run. The package never edits the profile's `bundles`
5
- # list — that entry is the operator's action (`dsh plugin --profile <name> add
6
- # @xiangyixie/dsh-superagent`).
7
- - insert:
8
- - id: superagent
9
- name: '@xiangyixie/dsh-superagent'
1
+ # dsh-superagent bundle layer.
2
+ #
3
+ # Inserts one tools-only plugin row at PROFILE scope, so every session in the
4
+ # profile can start a run. The package never edits the profile's `bundles`
5
+ # list — that entry is the operator's action (`dsh plugin --profile <name> add
6
+ # @xiangyixie/dsh-superagent`).
7
+ - insert:
8
+ - id: superagent
9
+ name: '@xiangyixie/dsh-superagent'