@fnndsc/brasa 0.56.2 → 0.56.4
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/buildinfo.json +1 -1
- package/dist/builtins/berth/berth.d.ts +11 -0
- package/dist/builtins/berth/berth.js +53 -22
- package/dist/builtins/berth/berth.js.map +1 -1
- package/dist/builtins/berth/berthCube.d.ts +17 -2
- package/dist/builtins/berth/berthCube.js +22 -10
- package/dist/builtins/berth/berthCube.js.map +1 -1
- package/dist/builtins/debug.d.ts +24 -3
- package/dist/builtins/debug.js +66 -13
- package/dist/builtins/debug.js.map +1 -1
- package/dist/builtins/fs/acl.args.d.ts +5 -38
- package/dist/builtins/fs/acl.args.js +6 -72
- package/dist/builtins/fs/acl.args.js.map +1 -1
- package/dist/builtins/fs/acl.d.ts +100 -10
- package/dist/builtins/fs/acl.js +222 -68
- package/dist/builtins/fs/acl.js.map +1 -1
- package/dist/builtins/fs/cat.args.d.ts +14 -15
- package/dist/builtins/fs/cat.args.js +13 -40
- package/dist/builtins/fs/cat.args.js.map +1 -1
- package/dist/builtins/fs/cat.d.ts +40 -3
- package/dist/builtins/fs/cat.js +89 -10
- package/dist/builtins/fs/cat.js.map +1 -1
- package/dist/builtins/fs/cd.d.ts +24 -6
- package/dist/builtins/fs/cd.js +71 -18
- package/dist/builtins/fs/cd.js.map +1 -1
- package/dist/builtins/fs/configWrite.d.ts +24 -8
- package/dist/builtins/fs/configWrite.js +77 -36
- package/dist/builtins/fs/configWrite.js.map +1 -1
- package/dist/builtins/fs/cp.d.ts +39 -4
- package/dist/builtins/fs/cp.js +120 -55
- package/dist/builtins/fs/cp.js.map +1 -1
- package/dist/builtins/fs/download.d.ts +12 -1
- package/dist/builtins/fs/download.js +24 -4
- package/dist/builtins/fs/download.js.map +1 -1
- package/dist/builtins/fs/du.d.ts +59 -33
- package/dist/builtins/fs/du.js +111 -79
- package/dist/builtins/fs/du.js.map +1 -1
- package/dist/builtins/fs/edit.d.ts +19 -4
- package/dist/builtins/fs/edit.js +77 -16
- package/dist/builtins/fs/edit.js.map +1 -1
- package/dist/builtins/fs/find.d.ts +25 -0
- package/dist/builtins/fs/find.js +76 -5
- package/dist/builtins/fs/find.js.map +1 -1
- package/dist/builtins/fs/mkdir.d.ts +28 -18
- package/dist/builtins/fs/mkdir.js +95 -66
- package/dist/builtins/fs/mkdir.js.map +1 -1
- package/dist/builtins/fs/mv.d.ts +34 -4
- package/dist/builtins/fs/mv.js +129 -64
- package/dist/builtins/fs/mv.js.map +1 -1
- package/dist/builtins/fs/pull.args.d.ts +56 -17
- package/dist/builtins/fs/pull.args.js +16 -66
- package/dist/builtins/fs/pull.args.js.map +1 -1
- package/dist/builtins/fs/pull.d.ts +62 -0
- package/dist/builtins/fs/pull.js +86 -22
- package/dist/builtins/fs/pull.js.map +1 -1
- package/dist/builtins/fs/pwd.d.ts +19 -5
- package/dist/builtins/fs/pwd.js +62 -8
- package/dist/builtins/fs/pwd.js.map +1 -1
- package/dist/builtins/fs/rm.d.ts +58 -21
- package/dist/builtins/fs/rm.js +99 -82
- package/dist/builtins/fs/rm.js.map +1 -1
- package/dist/builtins/fs/rmdir.d.ts +29 -11
- package/dist/builtins/fs/rmdir.js +87 -36
- package/dist/builtins/fs/rmdir.js.map +1 -1
- package/dist/builtins/fs/touch.d.ts +44 -9
- package/dist/builtins/fs/touch.js +91 -27
- package/dist/builtins/fs/touch.js.map +1 -1
- package/dist/builtins/fs/transferJobs.d.ts +64 -0
- package/dist/builtins/fs/transferJobs.js +98 -0
- package/dist/builtins/fs/transferJobs.js.map +1 -0
- package/dist/builtins/fs/tree.d.ts +36 -9
- package/dist/builtins/fs/tree.js +126 -36
- package/dist/builtins/fs/tree.js.map +1 -1
- package/dist/builtins/fs/upload.d.ts +35 -3
- package/dist/builtins/fs/upload.js +99 -14
- package/dist/builtins/fs/upload.js.map +1 -1
- package/dist/builtins/fs/xattr.args.d.ts +12 -33
- package/dist/builtins/fs/xattr.args.js +17 -95
- package/dist/builtins/fs/xattr.args.js.map +1 -1
- package/dist/builtins/fs/xattr.d.ts +98 -8
- package/dist/builtins/fs/xattr.js +163 -24
- package/dist/builtins/fs/xattr.js.map +1 -1
- package/dist/builtins/games/bytes.d.ts +201 -5
- package/dist/builtins/games/bytes.js +255 -54
- package/dist/builtins/games/bytes.js.map +1 -1
- package/dist/builtins/games/chimes.d.ts +180 -3
- package/dist/builtins/games/chimes.js +203 -26
- package/dist/builtins/games/chimes.js.map +1 -1
- package/dist/builtins/games/chrislab.d.ts +101 -3
- package/dist/builtins/games/chrislab.js +117 -17
- package/dist/builtins/games/chrislab.js.map +1 -1
- package/dist/builtins/games/cowsay.d.ts +93 -2
- package/dist/builtins/games/cowsay.js +90 -31
- package/dist/builtins/games/cowsay.js.map +1 -1
- package/dist/builtins/games/figlet.d.ts +70 -2
- package/dist/builtins/games/figlet.js +83 -6
- package/dist/builtins/games/figlet.js.map +1 -1
- package/dist/builtins/games/lab.d.ts +104 -5
- package/dist/builtins/games/lab.js +144 -6
- package/dist/builtins/games/lab.js.map +1 -1
- package/dist/builtins/games/lolcat.d.ts +61 -1
- package/dist/builtins/games/lolcat.js +59 -24
- package/dist/builtins/games/lolcat.js.map +1 -1
- package/dist/builtins/games/morse.d.ts +36 -1
- package/dist/builtins/games/morse.js +50 -2
- package/dist/builtins/games/morse.js.map +1 -1
- package/dist/builtins/games/numbers.d.ts +241 -5
- package/dist/builtins/games/numbers.js +298 -23
- package/dist/builtins/games/numbers.js.map +1 -1
- package/dist/builtins/games/play.d.ts +96 -6
- package/dist/builtins/games/play.js +137 -6
- package/dist/builtins/games/play.js.map +1 -1
- package/dist/builtins/games/qr.d.ts +40 -1
- package/dist/builtins/games/qr.js +51 -2
- package/dist/builtins/games/qr.js.map +1 -1
- package/dist/builtins/games/show.d.ts +131 -6
- package/dist/builtins/games/show.js +208 -20
- package/dist/builtins/games/show.js.map +1 -1
- package/dist/builtins/games/sky.d.ts +178 -4
- package/dist/builtins/games/sky.js +228 -12
- package/dist/builtins/games/sky.js.map +1 -1
- package/dist/builtins/games/text.d.ts +258 -7
- package/dist/builtins/games/text.js +310 -29
- package/dist/builtins/games/text.js.map +1 -1
- package/dist/builtins/games/trek.d.ts +67 -3
- package/dist/builtins/games/trek.js +63 -10
- package/dist/builtins/games/trek.js.map +1 -1
- package/dist/builtins/games/wtf.d.ts +58 -1
- package/dist/builtins/games/wtf.js +67 -6
- package/dist/builtins/games/wtf.js.map +1 -1
- package/dist/builtins/help.d.ts +38 -2
- package/dist/builtins/help.js +76 -769
- package/dist/builtins/help.js.map +1 -1
- package/dist/builtins/helpSections.js +4 -1
- package/dist/builtins/helpSections.js.map +1 -1
- package/dist/builtins/net/connect.d.ts +36 -3
- package/dist/builtins/net/connect.js +84 -26
- package/dist/builtins/net/connect.js.map +1 -1
- package/dist/builtins/net/cubepath.d.ts +49 -5
- package/dist/builtins/net/cubepath.js +69 -27
- package/dist/builtins/net/cubepath.js.map +1 -1
- package/dist/builtins/net/logout.d.ts +13 -4
- package/dist/builtins/net/logout.js +49 -3
- package/dist/builtins/net/logout.js.map +1 -1
- package/dist/builtins/net/netstat.d.ts +29 -4
- package/dist/builtins/net/netstat.js +64 -23
- package/dist/builtins/net/netstat.js.map +1 -1
- package/dist/builtins/net/pacs.d.ts +169 -15
- package/dist/builtins/net/pacs.js +92 -33
- package/dist/builtins/net/pacs.js.map +1 -1
- package/dist/builtins/net/query.args.d.ts +95 -0
- package/dist/builtins/net/query.args.js +26 -0
- package/dist/builtins/net/query.args.js.map +1 -0
- package/dist/builtins/net/query.d.ts +98 -5
- package/dist/builtins/net/query.js +89 -83
- package/dist/builtins/net/query.js.map +1 -1
- package/dist/builtins/net/status.d.ts +5 -3
- package/dist/builtins/net/status.js +5 -12
- package/dist/builtins/net/status.js.map +1 -1
- package/dist/builtins/parametersofplugin.d.ts +82 -3
- package/dist/builtins/parametersofplugin.js +79 -23
- package/dist/builtins/parametersofplugin.js.map +1 -1
- package/dist/builtins/proc.d.ts +210 -3
- package/dist/builtins/proc.js +210 -119
- package/dist/builtins/proc.js.map +1 -1
- package/dist/builtins/res/compute.d.ts +67 -3
- package/dist/builtins/res/compute.js +121 -35
- package/dist/builtins/res/compute.js.map +1 -1
- package/dist/builtins/res/dicom.d.ts +52 -3
- package/dist/builtins/res/dicom.js +82 -34
- package/dist/builtins/res/dicom.js.map +1 -1
- package/dist/builtins/res/expect.d.ts +52 -3
- package/dist/builtins/res/expect.js +92 -29
- package/dist/builtins/res/expect.js.map +1 -1
- package/dist/builtins/res/feed.d.ts +475 -3
- package/dist/builtins/res/feed.js +253 -158
- package/dist/builtins/res/feed.js.map +1 -1
- package/dist/builtins/res/files.d.ts +517 -3
- package/dist/builtins/res/files.js +124 -44
- package/dist/builtins/res/files.js.map +1 -1
- package/dist/builtins/res/gather.d.ts +113 -3
- package/dist/builtins/res/gather.js +153 -44
- package/dist/builtins/res/gather.js.map +1 -1
- package/dist/builtins/res/gather.process.d.ts +27 -19
- package/dist/builtins/res/gather.process.js +29 -59
- package/dist/builtins/res/gather.process.js.map +1 -1
- package/dist/builtins/res/group.d.ts +284 -3
- package/dist/builtins/res/group.js +147 -76
- package/dist/builtins/res/group.js.map +1 -1
- package/dist/builtins/res/image.d.ts +30 -2
- package/dist/builtins/res/image.js +62 -10
- package/dist/builtins/res/image.js.map +1 -1
- package/dist/builtins/res/play.d.ts +71 -9
- package/dist/builtins/res/play.js +124 -82
- package/dist/builtins/res/play.js.map +1 -1
- package/dist/builtins/res/plugininstance.d.ts +307 -2
- package/dist/builtins/res/plugininstance.js +122 -50
- package/dist/builtins/res/plugininstance.js.map +1 -1
- package/dist/builtins/res/pluginmeta.d.ts +244 -2
- package/dist/builtins/res/pluginmeta.js +98 -40
- package/dist/builtins/res/pluginmeta.js.map +1 -1
- package/dist/builtins/res/record.d.ts +37 -3
- package/dist/builtins/res/record.js +127 -57
- package/dist/builtins/res/record.js.map +1 -1
- package/dist/builtins/res/resourceList.d.ts +136 -0
- package/dist/builtins/res/resourceList.js +51 -0
- package/dist/builtins/res/resourceList.js.map +1 -0
- package/dist/builtins/res/tag.d.ts +244 -3
- package/dist/builtins/res/tag.js +97 -41
- package/dist/builtins/res/tag.js.map +1 -1
- package/dist/builtins/res/user.d.ts +122 -3
- package/dist/builtins/res/user.js +83 -21
- package/dist/builtins/res/user.js.map +1 -1
- package/dist/builtins/res/workflow.d.ts +244 -2
- package/dist/builtins/res/workflow.js +97 -40
- package/dist/builtins/res/workflow.js.map +1 -1
- package/dist/builtins/store.d.ts +85 -3
- package/dist/builtins/store.js +135 -68
- package/dist/builtins/store.js.map +1 -1
- package/dist/builtins/sys/apropos.d.ts +80 -5
- package/dist/builtins/sys/apropos.js +121 -15
- package/dist/builtins/sys/apropos.js.map +1 -1
- package/dist/builtins/sys/cal.d.ts +44 -5
- package/dist/builtins/sys/cal.js +57 -10
- package/dist/builtins/sys/cal.js.map +1 -1
- package/dist/builtins/sys/command.d.ts +20 -0
- package/dist/builtins/sys/command.js +31 -0
- package/dist/builtins/sys/command.js.map +1 -1
- package/dist/builtins/sys/context.d.ts +13 -3
- package/dist/builtins/sys/context.js +51 -4
- package/dist/builtins/sys/context.js.map +1 -1
- package/dist/builtins/sys/date.d.ts +56 -5
- package/dist/builtins/sys/date.js +63 -9
- package/dist/builtins/sys/date.js.map +1 -1
- package/dist/builtins/sys/echo.d.ts +63 -2
- package/dist/builtins/sys/echo.js +87 -8
- package/dist/builtins/sys/echo.js.map +1 -1
- package/dist/builtins/sys/fortune.d.ts +27 -2
- package/dist/builtins/sys/fortune.js +44 -2
- package/dist/builtins/sys/fortune.js.map +1 -1
- package/dist/builtins/sys/grep.d.ts +245 -11
- package/dist/builtins/sys/grep.js +418 -131
- package/dist/builtins/sys/grep.js.map +1 -1
- package/dist/builtins/sys/joblets.d.ts +66 -7
- package/dist/builtins/sys/joblets.js +101 -14
- package/dist/builtins/sys/joblets.js.map +1 -1
- package/dist/builtins/sys/motd.d.ts +37 -3
- package/dist/builtins/sys/motd.js +49 -8
- package/dist/builtins/sys/motd.js.map +1 -1
- package/dist/builtins/sys/notes.d.ts +75 -3
- package/dist/builtins/sys/notes.js +90 -29
- package/dist/builtins/sys/notes.js.map +1 -1
- package/dist/builtins/sys/physicalmode.d.ts +24 -3
- package/dist/builtins/sys/physicalmode.js +68 -14
- package/dist/builtins/sys/physicalmode.js.map +1 -1
- package/dist/builtins/sys/tasks.d.ts +74 -5
- package/dist/builtins/sys/tasks.js +102 -14
- package/dist/builtins/sys/tasks.js.map +1 -1
- package/dist/builtins/sys/textFilters.d.ts +673 -41
- package/dist/builtins/sys/textFilters.js +718 -263
- package/dist/builtins/sys/textFilters.js.map +1 -1
- package/dist/builtins/sys/timing.d.ts +24 -3
- package/dist/builtins/sys/timing.js +67 -14
- package/dist/builtins/sys/timing.js.map +1 -1
- package/dist/builtins/sys/variables.d.ts +70 -4
- package/dist/builtins/sys/variables.js +103 -31
- package/dist/builtins/sys/variables.js.map +1 -1
- package/dist/builtins/sys/version.d.ts +27 -2
- package/dist/builtins/sys/version.js +48 -3
- package/dist/builtins/sys/version.js.map +1 -1
- package/dist/builtins/sys/weather.d.ts +92 -15
- package/dist/builtins/sys/weather.js +71 -45
- package/dist/builtins/sys/weather.js.map +1 -1
- package/dist/builtins/sys/whoami.d.ts +38 -18
- package/dist/builtins/sys/whoami.js +112 -8
- package/dist/builtins/sys/whoami.js.map +1 -1
- package/dist/builtins/utils.d.ts +0 -37
- package/dist/builtins/utils.js +0 -86
- package/dist/builtins/utils.js.map +1 -1
- package/dist/chris/chrisCommands.js +58 -152
- package/dist/chris/chrisCommands.js.map +1 -1
- package/dist/chris/commandFallback.d.ts +12 -0
- package/dist/chris/commandFallback.js +47 -0
- package/dist/chris/commandFallback.js.map +1 -1
- package/dist/chris/filesystem.js +7 -5
- package/dist/chris/filesystem.js.map +1 -1
- package/dist/chris/help.js +0 -1018
- package/dist/chris/help.js.map +1 -1
- package/dist/chris/kinds.d.ts +21 -0
- package/dist/chris/kinds.js +114 -2
- package/dist/chris/kinds.js.map +1 -1
- package/dist/chris/mounts.d.ts +4 -4
- package/dist/chris/mounts.js +9 -16
- package/dist/chris/mounts.js.map +1 -1
- package/dist/chris/navigation.d.ts +2 -3
- package/dist/chris/navigation.js +6 -20
- package/dist/chris/navigation.js.map +1 -1
- package/dist/chris/pacsResources.d.ts +259 -0
- package/dist/chris/pacsResources.js +168 -0
- package/dist/chris/pacsResources.js.map +1 -0
- package/dist/core/commandDeclaration.d.ts +97 -7
- package/dist/core/commandDeclaration.js +21 -0
- package/dist/core/commandDeclaration.js.map +1 -1
- package/dist/core/commandParse.js +65 -17
- package/dist/core/commandParse.js.map +1 -1
- package/dist/core/commandRegistry.d.ts +4 -3
- package/dist/core/commandRegistry.js +36 -8
- package/dist/core/commandRegistry.js.map +1 -1
- package/dist/core/commandSchema.js +5 -2
- package/dist/core/commandSchema.js.map +1 -1
- package/dist/core/commandUsage.d.ts +15 -0
- package/dist/core/commandUsage.js +59 -7
- package/dist/core/commandUsage.js.map +1 -1
- package/dist/core/coreCommands.js +63 -212
- package/dist/core/coreCommands.js.map +1 -1
- package/dist/core/paths.d.ts +29 -1
- package/dist/core/paths.js +15 -2
- package/dist/core/paths.js.map +1 -1
- package/dist/core/preprocess.d.ts +3 -4
- package/dist/core/preprocess.js +4 -5
- package/dist/core/preprocess.js.map +1 -1
- package/dist/lib/completer/declared.js +7 -4
- package/dist/lib/completer/declared.js.map +1 -1
- package/dist/lib/completer/index.js +2 -7
- package/dist/lib/completer/index.js.map +1 -1
- package/dist/lib/parser.d.ts +0 -8
- package/dist/lib/parser.js +0 -11
- package/dist/lib/parser.js.map +1 -1
- package/dist/lib/vfs/vfs.d.ts +2 -1
- package/dist/lib/vfs/vfs.js +5 -4
- package/dist/lib/vfs/vfs.js.map +1 -1
- package/dist/notes.json +1 -1
- package/package.json +5 -5
|
@@ -6,47 +6,98 @@
|
|
|
6
6
|
* argus desktops, prompt choices — as files under `~/.config/...` on CFS.
|
|
7
7
|
* Surfaces hold no upload credentials of their own, so the write travels
|
|
8
8
|
* the session: content arrives base64-encoded, lands in a host temp file,
|
|
9
|
-
* and rides the same upload path the edit-in-place flow already uses.
|
|
9
|
+
* and rides the same upload path the edit-in-place flow already uses. The
|
|
10
|
+
* document is written where the store keeps its path (`storePath_resolve`).
|
|
11
|
+
*
|
|
12
|
+
* Declared in one record (`configCommand`): one subcommand, `write`, with a
|
|
13
|
+
* CFS path and the content as a word.
|
|
14
|
+
*
|
|
15
|
+
* Key components:
|
|
16
|
+
* - configCommand: the declaration.
|
|
17
|
+
* - builtin_config: the declaration run over words already split.
|
|
18
|
+
*
|
|
19
|
+
* Typical usage:
|
|
20
|
+
* ```ts
|
|
21
|
+
* await builtin_config(['write', '~/.config/argus/desktops/quad.desk', 'dmlldyBmaWxlcwo=']);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Dependencies: salsa's upload and chili's replace-in-place; the session's
|
|
25
|
+
* listing cache.
|
|
10
26
|
*
|
|
11
27
|
* @module
|
|
12
28
|
*/
|
|
13
29
|
import { writeFileSync, unlinkSync, existsSync } from 'fs';
|
|
14
30
|
import { tmpdir } from 'os';
|
|
15
|
-
import { join } from 'path';
|
|
31
|
+
import { join, posix } from 'path';
|
|
16
32
|
import chalk from 'chalk';
|
|
17
33
|
import { files_uploadPath } from '@fnndsc/salsa';
|
|
18
34
|
import { file_replaceContent } from '@fnndsc/chili/commands/fs/edit.js';
|
|
19
|
-
import { path_resolve } from '../utils.js';
|
|
35
|
+
import { path_resolve, storePath_resolve } from '../utils.js';
|
|
36
|
+
import { command_declare } from '../../core/commandDeclaration.js';
|
|
37
|
+
import { declaredCommand_run } from '../../core/commandParse.js';
|
|
38
|
+
import { listingCache_get } from '../../core/filesystem.js';
|
|
20
39
|
import { envelope_error, envelope_ok } from '@fnndsc/menu';
|
|
21
40
|
import { exitCode_set } from '../../core/handlerRun.js';
|
|
22
41
|
/** A config document is a note, not a dataset. */
|
|
23
42
|
const CONFIG_WRITE_LIMIT = 256 * 1024;
|
|
43
|
+
/** What a `config` line may hold: `write`, a CFS path, and the document as base64. */
|
|
44
|
+
const CONFIG_GRAMMAR = {
|
|
45
|
+
subcommands: {
|
|
46
|
+
write: {
|
|
47
|
+
summary: 'Write a configuration document',
|
|
48
|
+
operands: [
|
|
49
|
+
{ name: 'path', kind: 'cfsPath', summary: 'Where the document goes in ChRIS' },
|
|
50
|
+
{ name: 'content', kind: 'word', summary: 'The document, base64-encoded' },
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* `config write <path> <content>`: the declaration.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* commands_register({ declarations: [configCommand] }, 'backend');
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export const configCommand = command_declare({
|
|
64
|
+
name: 'config',
|
|
65
|
+
grammar: CONFIG_GRAMMAR,
|
|
66
|
+
help: {
|
|
67
|
+
summary: "Write a small configuration document into the user's CUBE home",
|
|
68
|
+
description: 'Write a small configuration document into the user\'s CUBE home (the durable layer: argus desktops, surface preferences). Reads travel the ordinary cat. Documents are notes, not datasets: 256KB limit.',
|
|
69
|
+
category: 'Files',
|
|
70
|
+
examples: [
|
|
71
|
+
'config write ~/.config/argus/desktops/quad.desk dmlldyBmaWxlcwo= # a saved argus desktop',
|
|
72
|
+
'cat ~/.config/argus/desktops/quad.desk # reading one back',
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
handler: async (args) => configWrite_run(args),
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* `config` over words already split: the declaration's parse and handler.
|
|
79
|
+
*
|
|
80
|
+
* @param args - The words after `config`.
|
|
81
|
+
* @returns The subcommand's envelope, or the refusal of a bad line.
|
|
82
|
+
*/
|
|
83
|
+
export async function builtin_config(args) {
|
|
84
|
+
return declaredCommand_run(configCommand, args);
|
|
85
|
+
}
|
|
24
86
|
/**
|
|
25
|
-
*
|
|
87
|
+
* Runs `config write <path> <base64>`.
|
|
26
88
|
*
|
|
27
|
-
* @param args -
|
|
89
|
+
* @param args - The line, parsed.
|
|
28
90
|
* @returns An envelope reporting the written path.
|
|
29
91
|
*/
|
|
30
|
-
|
|
31
|
-
const rawPath = args
|
|
32
|
-
const
|
|
33
|
-
if (rawPath === undefined || encoded === undefined) {
|
|
34
|
-
exitCode_set(1);
|
|
35
|
-
return envelope_error('', undefined, 'usage: config write <cfs-path> <base64-content>\n');
|
|
36
|
-
}
|
|
37
|
-
let content;
|
|
38
|
-
try {
|
|
39
|
-
content = Buffer.from(encoded, 'base64');
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
exitCode_set(1);
|
|
43
|
-
return envelope_error('', undefined, 'config write: the content is not valid base64.\n');
|
|
44
|
-
}
|
|
92
|
+
async function configWrite_run(args) {
|
|
93
|
+
const rawPath = args.operands.path;
|
|
94
|
+
const content = Buffer.from(args.operands.content, 'base64');
|
|
45
95
|
if (content.length > CONFIG_WRITE_LIMIT) {
|
|
46
96
|
exitCode_set(1);
|
|
47
97
|
return envelope_error('', undefined, 'config write: a config document is a note, not a dataset (256KB limit).\n');
|
|
48
98
|
}
|
|
49
|
-
const
|
|
99
|
+
const shown = await path_resolve(rawPath);
|
|
100
|
+
const remotePath = await storePath_resolve(rawPath);
|
|
50
101
|
const tmpPath = join(tmpdir(), `chell-config-${Date.now()}.tmp`);
|
|
51
102
|
try {
|
|
52
103
|
writeFileSync(tmpPath, content);
|
|
@@ -59,26 +110,16 @@ export async function configWrite_handle(args) {
|
|
|
59
110
|
}
|
|
60
111
|
if (!uploaded) {
|
|
61
112
|
exitCode_set(1);
|
|
62
|
-
return envelope_error('', undefined, `config write: upload to ${
|
|
113
|
+
return envelope_error('', undefined, `config write: upload to ${shown} failed.\n`);
|
|
63
114
|
}
|
|
64
|
-
|
|
115
|
+
// The folder's listing is stale by both its names.
|
|
116
|
+
listingCache_get().cache_invalidate?.(posix.dirname(remotePath));
|
|
117
|
+
listingCache_get().cache_invalidate?.(posix.dirname(shown));
|
|
118
|
+
return envelope_ok(`${chalk.green('[+]')} wrote ${shown} (${content.length} bytes)\n`);
|
|
65
119
|
}
|
|
66
120
|
finally {
|
|
67
121
|
if (existsSync(tmpPath))
|
|
68
122
|
unlinkSync(tmpPath);
|
|
69
123
|
}
|
|
70
124
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Routes the `config` command family. `write` is its only member today;
|
|
73
|
-
* reads travel the ordinary `cat`.
|
|
74
|
-
*
|
|
75
|
-
* @param args - Full command args.
|
|
76
|
-
* @returns The subcommand's envelope.
|
|
77
|
-
*/
|
|
78
|
-
export async function builtin_config(args) {
|
|
79
|
-
if (args[1] === 'write')
|
|
80
|
-
return configWrite_handle(args);
|
|
81
|
-
exitCode_set(1);
|
|
82
|
-
return envelope_error('', undefined, 'usage: config write <cfs-path> <base64-content>\n');
|
|
83
|
-
}
|
|
84
125
|
//# sourceMappingURL=configWrite.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configWrite.js","sourceRoot":"","sources":["../../../src/builtins/fs/configWrite.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"configWrite.js","sourceRoot":"","sources":["../../../src/builtins/fs/configWrite.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAmB,MAAM,mCAAmC,CAAC;AACzF,OAAO,EAAE,YAAY,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gB,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5D,OAAO,WAAW,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,KAAK,KAAK,OAAO,CAAC,MAAM,WAAW,CAAC,CAAC;IACzF,CAAC;YAAS,CAAC;QACT,IAAI,UAAU,CAAC,OAAO,CAAC;YAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
package/dist/builtins/fs/cp.d.ts
CHANGED
|
@@ -12,12 +12,47 @@ export interface CpModelData {
|
|
|
12
12
|
failed: number;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
* Supports multiple sources when destination is a directory.
|
|
15
|
+
* `cp [-rt] [--target-directory <dir>] <paths…>`: the declaration.
|
|
17
16
|
*
|
|
18
|
-
* @
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* commands_register({ declarations: [cpCommand] });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const cpCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
|
|
23
|
+
readonly operands: readonly [{
|
|
24
|
+
readonly name: "paths";
|
|
25
|
+
readonly kind: "cfsPath";
|
|
26
|
+
readonly repeat: true;
|
|
27
|
+
readonly glob: true;
|
|
28
|
+
readonly summary: "The sources, then the destination; a lone source asks where it goes";
|
|
29
|
+
}];
|
|
30
|
+
readonly options: {
|
|
31
|
+
readonly recursive: {
|
|
32
|
+
readonly short: "r";
|
|
33
|
+
readonly long: "recursive";
|
|
34
|
+
readonly summary: "Recursive copy (for directories)";
|
|
35
|
+
};
|
|
36
|
+
readonly askTarget: {
|
|
37
|
+
readonly short: "t";
|
|
38
|
+
readonly summary: "Every operand is a source; asks for the target directory, and the answer must be one";
|
|
39
|
+
};
|
|
40
|
+
readonly targetDirectory: {
|
|
41
|
+
readonly long: "target-directory";
|
|
42
|
+
readonly summary: "Every operand is a source; copy into this directory";
|
|
43
|
+
readonly value: {
|
|
44
|
+
readonly name: "dir";
|
|
45
|
+
readonly kind: "cfsPath";
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* `cp` over words already split: the declaration's parse and handler.
|
|
52
|
+
*
|
|
53
|
+
* @param args - The words after `cp`.
|
|
19
54
|
* @returns An envelope whose rendered text reports progress and results and
|
|
20
|
-
* whose model carries per-source outcomes.
|
|
55
|
+
* whose model carries per-source outcomes, or the refusal of a bad line.
|
|
21
56
|
*/
|
|
22
57
|
export declare function builtin_cp(args: string[]): Promise<CommandEnvelope>;
|
|
23
58
|
/** Typed invocation options for cp. */
|
package/dist/builtins/fs/cp.js
CHANGED
|
@@ -1,59 +1,77 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
2
|
+
* @file `cp`: copies files and folders within ChRIS's filesystem (CFS),
|
|
3
|
+
* reported as a command envelope.
|
|
4
|
+
*
|
|
5
|
+
* Declared in one record (`cpCommand`): the sources, then the destination,
|
|
6
|
+
* each a path that may be a wildcard; a lone source, or `-t`, asks where.
|
|
7
|
+
* Each path is acted on where the store keeps it (`storePath_resolve`): a
|
|
8
|
+
* source through a link is what the link points at, and a destination
|
|
9
|
+
* through a link lands in the link's target. What cp says names the paths
|
|
10
|
+
* as the session resolves them.
|
|
11
|
+
*
|
|
12
|
+
* Key components:
|
|
13
|
+
* - cpCommand: the declaration.
|
|
14
|
+
* - builtin_cp: the declaration run over words already split.
|
|
15
|
+
* - cp_run: the typed core behind both, and the typed API.
|
|
16
|
+
*
|
|
17
|
+
* Typical usage:
|
|
18
|
+
* ```ts
|
|
19
|
+
* await builtin_cp(['-r', 'data', 'backup/']);
|
|
20
|
+
* await cp_run({ sources: ['a.txt'], dest: 'b.txt' });
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Dependencies: the session's filesystem and listing cache, and the
|
|
24
|
+
* destination question.
|
|
25
|
+
*
|
|
26
|
+
* @module
|
|
4
27
|
*/
|
|
5
28
|
import chalk from 'chalk';
|
|
6
29
|
import path from 'path';
|
|
7
|
-
import {
|
|
30
|
+
import { path_resolve, storePath_resolve } from '../utils.js';
|
|
31
|
+
import { command_declare } from '../../core/commandDeclaration.js';
|
|
32
|
+
import { declaredCommand_run } from '../../core/commandParse.js';
|
|
8
33
|
import { listingCache_get, vfsDispatcher_get } from '../../core/filesystem.js';
|
|
9
34
|
import { destination_ask, destination_missing, operands_fix } from './destination.js';
|
|
10
35
|
import { cp_render, vfsRefusal_text } from '@fnndsc/fond';
|
|
11
36
|
import { pathEntry_find, entry_isFolder } from './entries.js';
|
|
12
37
|
import { envelope_ok, envelope_error } from '@fnndsc/menu';
|
|
13
38
|
import { exitCode_set } from '../../core/handlerRun.js';
|
|
39
|
+
/** What a `cp` line may hold. */
|
|
40
|
+
const CP_GRAMMAR = {
|
|
41
|
+
operands: [
|
|
42
|
+
{ name: 'paths', kind: 'cfsPath', repeat: true, glob: true, summary: 'The sources, then the destination; a lone source asks where it goes' },
|
|
43
|
+
],
|
|
44
|
+
options: {
|
|
45
|
+
recursive: { short: 'r', long: 'recursive', summary: 'Recursive copy (for directories)' },
|
|
46
|
+
askTarget: { short: 't', summary: 'Every operand is a source; asks for the target directory, and the answer must be one' },
|
|
47
|
+
targetDirectory: { long: 'target-directory', summary: 'Every operand is a source; copy into this directory', value: { name: 'dir', kind: 'cfsPath' } },
|
|
48
|
+
},
|
|
49
|
+
};
|
|
14
50
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
51
|
+
* Runs a parsed `cp` line: into a target directory given or asked for, to a
|
|
52
|
+
* destination asked for a lone source, or to the last operand.
|
|
17
53
|
*
|
|
18
|
-
* @param args -
|
|
19
|
-
* @returns
|
|
20
|
-
* whose model carries per-source outcomes.
|
|
54
|
+
* @param args - The typed line.
|
|
55
|
+
* @returns The copy's envelope, or the refusal of an abandoned question.
|
|
21
56
|
*/
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return cp_run({ sources: pathArgs, dest: target });
|
|
37
|
-
}
|
|
38
|
-
// The sources are fixed before the question: other commands run while it is open.
|
|
39
|
-
const sources = await operands_fix(pathArgs);
|
|
40
|
-
const chosen = await destination_ask({
|
|
41
|
-
verb: 'cp', commit: 'COPY HERE', sources, wantsDirectory: true,
|
|
42
|
-
});
|
|
43
|
-
if (chosen === '') {
|
|
44
|
-
exitCode_set(1);
|
|
45
|
-
return envelope_error('', undefined, `${chalk.red(destination_missing('cp'))}\n`);
|
|
46
|
-
}
|
|
47
|
-
return cp_run({ sources, dest: chosen });
|
|
48
|
-
}
|
|
49
|
-
const recursive = !!parsed['r'] || !!parsed['recursive'];
|
|
50
|
-
// One operand names what to copy and not where: a question, not a usage
|
|
51
|
-
// error. See `destination_ask`.
|
|
52
|
-
if (pathArgs.length === 1) {
|
|
57
|
+
async function cp_handle(args) {
|
|
58
|
+
const paths = args.operands.paths;
|
|
59
|
+
const recursive = args.options.recursive;
|
|
60
|
+
// `--target-directory <dir>` names the TARGET DIRECTORY, so every operand
|
|
61
|
+
// is a source: the shell's own answer to "several things, one destination".
|
|
62
|
+
const target = args.options.targetDirectory;
|
|
63
|
+
if (target !== undefined)
|
|
64
|
+
return cp_run({ sources: paths, dest: target, recursive });
|
|
65
|
+
// `-t` alone is that line with the directory not said: a question
|
|
66
|
+
// (an-absent-value-is-a-question), and the answer wants a directory:
|
|
67
|
+
// `cp a b` without it means copy a ONTO b, the right reading of that line
|
|
68
|
+
// and the wrong thing for a set. One operand names what to copy and not
|
|
69
|
+
// where: a question too, not a usage error. See `destination_ask`.
|
|
70
|
+
if (args.options.askTarget || paths.length === 1) {
|
|
53
71
|
// The sources are fixed before the question: other commands run while it is open.
|
|
54
|
-
const sources = await operands_fix(
|
|
72
|
+
const sources = await operands_fix(paths);
|
|
55
73
|
const chosen = await destination_ask({
|
|
56
|
-
verb: 'cp', commit: 'COPY HERE', sources,
|
|
74
|
+
verb: 'cp', commit: 'COPY HERE', sources, ...(args.options.askTarget ? { wantsDirectory: true } : {}),
|
|
57
75
|
});
|
|
58
76
|
if (chosen === '') {
|
|
59
77
|
exitCode_set(1);
|
|
@@ -61,12 +79,61 @@ export async function builtin_cp(args) {
|
|
|
61
79
|
}
|
|
62
80
|
return cp_run({ sources, dest: chosen, recursive });
|
|
63
81
|
}
|
|
64
|
-
//
|
|
65
|
-
return cp_run({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
82
|
+
// The last operand is the destination, all others are sources.
|
|
83
|
+
return cp_run({ sources: paths.slice(0, -1), dest: paths[paths.length - 1] ?? '', recursive });
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* `cp [-rt] [--target-directory <dir>] <paths…>`: the declaration.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* commands_register({ declarations: [cpCommand] });
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export const cpCommand = command_declare({
|
|
94
|
+
name: 'cp',
|
|
95
|
+
grammar: CP_GRAMMAR,
|
|
96
|
+
help: {
|
|
97
|
+
summary: 'Copy files or directories (supports wildcards and multiple sources)',
|
|
98
|
+
description: "Copies files or folders within ChRIS's filesystem: the last operand is the destination, and several sources want a folder there. Given only a source, the destination is asked for. A path through a link is the link's target: a copy into a linked folder lands in the folder it points at. PACS sources: a /net/pacs/queries/... source names query results, not stored files, and cp materializes the series: if its DICOMs are not yet in CUBE it fires a PACS retrieve and waits for them to land (the same engine as pull), then copies the landed files to the destination. A series already fully in CUBE is copied without a retrieve.",
|
|
99
|
+
category: 'Files',
|
|
100
|
+
posix: { group: 'Files', differs: 'copies within CFS; -r for folders' },
|
|
101
|
+
examples: [
|
|
102
|
+
'cp file.txt copy.txt # Copy single file',
|
|
103
|
+
'cp -r dir1/ dir2/ # Copy directory recursively',
|
|
104
|
+
'cp file1 file2 file3 dest/ # Copy multiple files',
|
|
105
|
+
'cp uploads/*.txt backup/ # Copy with wildcard',
|
|
106
|
+
'cp --target-directory backup/ a b # Copy several into one folder',
|
|
107
|
+
'cp -t a.txt b.txt # Ask which folder they go to',
|
|
108
|
+
'cp "file with spaces.txt" dest/ # Use quotes for spaces',
|
|
109
|
+
'cp -r /net/pacs/queries/AccessionNumber:123_qid:7/Study_1.2.3_Head/Series_1.2.3.4_AX_T2 results/',
|
|
110
|
+
' # Retrieve-if-needed, then copy the series',
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
handler: cp_handle,
|
|
114
|
+
});
|
|
115
|
+
/**
|
|
116
|
+
* `cp` over words already split: the declaration's parse and handler.
|
|
117
|
+
*
|
|
118
|
+
* @param args - The words after `cp`.
|
|
119
|
+
* @returns An envelope whose rendered text reports progress and results and
|
|
120
|
+
* whose model carries per-source outcomes, or the refusal of a bad line.
|
|
121
|
+
*/
|
|
122
|
+
export async function builtin_cp(args) {
|
|
123
|
+
return declaredCommand_run(cpCommand, args);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Forgets the cached listings a write to a destination changes: beneath it
|
|
127
|
+
* (a recursive copy replaces them) and of its parent, by each name it has.
|
|
128
|
+
*
|
|
129
|
+
* @param listCache - The session's listing cache.
|
|
130
|
+
* @param names - The destination as the session names it and as the store keeps it.
|
|
131
|
+
*/
|
|
132
|
+
function destination_invalidate(listCache, names) {
|
|
133
|
+
for (const name of new Set(names)) {
|
|
134
|
+
listCache.cache_invalidateTree?.(name);
|
|
135
|
+
listCache.cache_invalidate?.(path.posix.dirname(name));
|
|
136
|
+
}
|
|
70
137
|
}
|
|
71
138
|
/**
|
|
72
139
|
* Copies files or directories: the shared typed core behind the parsed
|
|
@@ -84,6 +151,8 @@ export async function cp_run(options) {
|
|
|
84
151
|
}
|
|
85
152
|
const recursive = options.recursive ?? false;
|
|
86
153
|
const destPath = await path_resolve(dest);
|
|
154
|
+
// Written where the store keeps it: into a linked folder lands in the link's target.
|
|
155
|
+
const destStore = await storePath_resolve(destPath);
|
|
87
156
|
const listCache = listingCache_get();
|
|
88
157
|
let successCount = 0;
|
|
89
158
|
let failCount = 0;
|
|
@@ -102,9 +171,9 @@ export async function cp_run(options) {
|
|
|
102
171
|
}
|
|
103
172
|
// Into a folder the destination names, the copy keeps its name.
|
|
104
173
|
const dispatcher = vfsDispatcher_get();
|
|
105
|
-
const finalDest = entry_isFolder(await pathEntry_find(dispatcher,
|
|
106
|
-
? path.posix.join(
|
|
107
|
-
:
|
|
174
|
+
const finalDest = entry_isFolder(await pathEntry_find(dispatcher, destStore)) && !dispatcher.path_isVirtual(destStore)
|
|
175
|
+
? path.posix.join(destStore, path.posix.basename(srcPath))
|
|
176
|
+
: destStore;
|
|
108
177
|
// Copied from where the store keeps it (a /proc data path, a link); named as it was asked.
|
|
109
178
|
const copied = await dispatcher.cp(await storePath_resolve(srcPath), finalDest, { recursive });
|
|
110
179
|
const success = copied.ok;
|
|
@@ -132,11 +201,7 @@ export async function cp_run(options) {
|
|
|
132
201
|
failCount++;
|
|
133
202
|
}
|
|
134
203
|
}
|
|
135
|
-
|
|
136
|
-
// listings were cached beneath it) and its parent.
|
|
137
|
-
listCache.cache_invalidateTree?.(destPath);
|
|
138
|
-
const destParent = path.posix.dirname(destPath);
|
|
139
|
-
listCache.cache_invalidate?.(destParent);
|
|
204
|
+
destination_invalidate(listCache, [destPath, destStore]);
|
|
140
205
|
// Summary for multiple files
|
|
141
206
|
if (sources.length > 1) {
|
|
142
207
|
if (failCount === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cp.js","sourceRoot":"","sources":["../../../src/builtins/fs/cp.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
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EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CommandEnvelope } from '@fnndsc/menu';
|
|
2
2
|
/**
|
|
3
|
-
* `download [-f] <source…> <destination>`: the declaration.
|
|
3
|
+
* `download [-f] [-j N] <source…> <destination>`: the declaration.
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* ```ts
|
|
@@ -25,6 +25,17 @@ export declare const downloadCommand: import("../../core/commandDeclaration.js")
|
|
|
25
25
|
readonly long: "force";
|
|
26
26
|
readonly summary: "Overwrite local paths that exist";
|
|
27
27
|
};
|
|
28
|
+
readonly jobs: {
|
|
29
|
+
readonly short: "j";
|
|
30
|
+
readonly long: "jobs";
|
|
31
|
+
readonly summary: `Move N files at once, 1 to ${number} (1 is one at a time); without it $TRANSFER_JOBS, else ${number}`;
|
|
32
|
+
readonly value: {
|
|
33
|
+
readonly name: "N";
|
|
34
|
+
readonly kind: "int";
|
|
35
|
+
readonly min: 1;
|
|
36
|
+
readonly max: number;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
28
39
|
};
|
|
29
40
|
}>;
|
|
30
41
|
/**
|
|
@@ -32,6 +32,8 @@ import { directory_archive } from './archive.js';
|
|
|
32
32
|
import { envelope_ok, envelope_error } from '@fnndsc/menu';
|
|
33
33
|
import { errorStack } from '@fnndsc/fond';
|
|
34
34
|
import { exitCode_set } from '../../core/handlerRun.js';
|
|
35
|
+
import { commandCancellation_enable, commandCancellation_signalGet } from '../../core/cancellation.js';
|
|
36
|
+
import { TRANSFER_JOBS_OPTION, transferJobs_resolve, transferLeftovers_render } from './transferJobs.js';
|
|
35
37
|
/**
|
|
36
38
|
* A source as the transfer reads it: where the store keeps it, resolved as
|
|
37
39
|
* every reader resolves a path (a `/proc/jobs/.../data` path through the
|
|
@@ -158,10 +160,11 @@ const DOWNLOAD_GRAMMAR = {
|
|
|
158
160
|
],
|
|
159
161
|
options: {
|
|
160
162
|
force: { short: 'f', long: 'force', summary: 'Overwrite local paths that exist' },
|
|
163
|
+
jobs: TRANSFER_JOBS_OPTION,
|
|
161
164
|
},
|
|
162
165
|
};
|
|
163
166
|
/**
|
|
164
|
-
* `download [-f] <source…> <destination>`: the declaration.
|
|
167
|
+
* `download [-f] [-j N] <source…> <destination>`: the declaration.
|
|
165
168
|
*
|
|
166
169
|
* @example
|
|
167
170
|
* ```ts
|
|
@@ -173,15 +176,17 @@ export const downloadCommand = command_declare({
|
|
|
173
176
|
grammar: DOWNLOAD_GRAMMAR,
|
|
174
177
|
help: {
|
|
175
178
|
summary: 'Download ChRIS files or folders to this machine',
|
|
176
|
-
description: 'Download a ChRIS file, folder, or the paths a wildcard matches to the local filesystem with progress tracking: files, ETA, bytes transferred. Several sources, typed or matched, go together into one folder. Under a daemon the files are handed to the surface, which puts them on its own disk or in a browser\'s downloads.',
|
|
179
|
+
description: 'Download a ChRIS file, folder, or the paths a wildcard matches to the local filesystem with progress tracking: files, ETA, bytes transferred. Several sources, typed or matched, go together into one folder. The files of a folder move 8 at a time (-j N, or the session variable TRANSFER_JOBS, says how many, 1 to 32); a file that fails is tried once more, the rest continue, and the summary names each that failed. Under a daemon the files are handed to the surface, which puts them on its own disk or in a browser\'s downloads.',
|
|
177
180
|
category: 'Files',
|
|
178
181
|
examples: [
|
|
179
182
|
'download /home/user/data ./data',
|
|
180
183
|
'download /home/user/results/*.nii ./results/',
|
|
181
184
|
'download /feeds/feed_123 ./downloads -f',
|
|
185
|
+
'download -j 16 /home/user/uploads/study ./study',
|
|
186
|
+
'TRANSFER_JOBS=1; download /home/user/uploads/study ./study # one at a time',
|
|
182
187
|
],
|
|
183
188
|
},
|
|
184
|
-
handler: async (args) => download_run(args.operands.source, args.operands.destination, args.options.force, args.expanded.source),
|
|
189
|
+
handler: async (args) => download_run(args.operands.source, args.operands.destination, args.options.force, args.expanded.source, args.options.jobs),
|
|
185
190
|
});
|
|
186
191
|
/**
|
|
187
192
|
* `download` over words already split: the declaration's parse and handler.
|
|
@@ -200,9 +205,15 @@ export async function builtin_download(args) {
|
|
|
200
205
|
* @param localPathArg - Where they go.
|
|
201
206
|
* @param force - Overwrite local paths that exist.
|
|
202
207
|
* @param sourceWasExpanded - The sources came from a wildcard, so even one goes into a folder.
|
|
208
|
+
* @param jobsGiven - The line's `-j`; undefined when it gives none.
|
|
203
209
|
* @returns An envelope carrying the download summary.
|
|
204
210
|
*/
|
|
205
|
-
async function download_run(sourceArgs, localPathArg, force, sourceWasExpanded) {
|
|
211
|
+
async function download_run(sourceArgs, localPathArg, force, sourceWasExpanded, jobsGiven) {
|
|
212
|
+
const jobs = transferJobs_resolve(jobsGiven);
|
|
213
|
+
if ('refused' in jobs) {
|
|
214
|
+
exitCode_set(1);
|
|
215
|
+
return envelope_error('', undefined, `${chalk.red(`download: ${jobs.refused}`)}\n`);
|
|
216
|
+
}
|
|
206
217
|
// A path resolved here is a path on the *engine's* disk. That is the
|
|
207
218
|
// operator's disk only when a local shell hosts the engine in its own
|
|
208
219
|
// process; under a daemon it is a machine nobody attending the session is
|
|
@@ -215,9 +226,13 @@ async function download_run(sourceArgs, localPathArg, force, sourceWasExpanded)
|
|
|
215
226
|
return surfaceDownload_run(surface, sourceArgs, localPathArg);
|
|
216
227
|
}
|
|
217
228
|
const targetLocal = path.resolve(localPathArg);
|
|
229
|
+
commandCancellation_enable();
|
|
230
|
+
const signal = commandCancellation_signalGet();
|
|
218
231
|
try {
|
|
219
232
|
const progress = {
|
|
220
233
|
force,
|
|
234
|
+
jobs: jobs.jobs,
|
|
235
|
+
...(signal !== undefined ? { signal } : {}),
|
|
221
236
|
confirm: downloadConfirmation_request,
|
|
222
237
|
onNotice: (message, channel) => {
|
|
223
238
|
const sink = sink_get();
|
|
@@ -246,6 +261,11 @@ async function download_run(sourceArgs, localPathArg, force, sourceWasExpanded)
|
|
|
246
261
|
rendered += `${chalk.yellow(`⚠ Downloaded ${summary.transferredCount} file(s), ${summary.failedCount} failed`)}\n`;
|
|
247
262
|
}
|
|
248
263
|
rendered += `${chalk.gray(` Total: ${bytes_format(summary.transferSize)} in ${summary.duration.toFixed(1)}s (${bytes_format(summary.speed)}/s)`)}\n`;
|
|
264
|
+
rendered += transferLeftovers_render(summary.failedPaths, summary.cancelledCount, 'downloaded');
|
|
265
|
+
if (summary.failedCount > 0 || summary.cancelledCount > 0) {
|
|
266
|
+
exitCode_set(1);
|
|
267
|
+
return envelope_error(rendered, undefined, '');
|
|
268
|
+
}
|
|
249
269
|
return envelope_ok(rendered);
|
|
250
270
|
}
|
|
251
271
|
catch (e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","sourceRoot":"","sources":["../../../src/builtins/fs/download.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EACL,0BAA0B,IAAI,kBAAkB,EAChD,8BAA8B,IAAI,sBAAsB,EAIxD,YAAY,EACb,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAA8C,MAAM,kCAAkC,CAAC;AAC/G,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,WAAW,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAe,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAsB,MAAM,cAAc,CAAC;AACrE,OAAO,EAAgD,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACzG,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAA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