@fnndsc/brasa 0.56.1 → 0.56.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/dist/buildinfo.json +1 -1
- package/dist/builtins/berth/berth.d.ts +90 -3
- package/dist/builtins/berth/berth.js +129 -76
- package/dist/builtins/berth/berth.js.map +1 -1
- package/dist/builtins/berth/berthClose.d.ts +25 -6
- package/dist/builtins/berth/berthClose.js +8 -64
- package/dist/builtins/berth/berthClose.js.map +1 -1
- package/dist/builtins/berth/berthCube.d.ts +3 -2
- package/dist/builtins/berth/berthCube.js +9 -16
- package/dist/builtins/berth/berthCube.js.map +1 -1
- package/dist/builtins/berth/berthProcesses.js +33 -3
- package/dist/builtins/berth/berthProcesses.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 +92 -13
- 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 +122 -56
- package/dist/builtins/fs/cp.js.map +1 -1
- package/dist/builtins/fs/download.d.ts +31 -4
- package/dist/builtins/fs/download.js +75 -38
- 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/ls.d.ts +69 -4
- package/dist/builtins/fs/ls.js +84 -45
- package/dist/builtins/fs/ls.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 +123 -31
- 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/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 +22 -3
- package/dist/builtins/fs/upload.js +82 -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 +41 -3
- package/dist/builtins/help.js +92 -796
- package/dist/builtins/help.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 +55 -7
- package/dist/builtins/res/dicom.js +86 -52
- 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 +719 -264
- 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 +1 -38
- package/dist/builtins/utils.js +1 -87
- package/dist/builtins/utils.js.map +1 -1
- package/dist/chris/backend.js +2 -0
- package/dist/chris/backend.js.map +1 -1
- package/dist/chris/chrisCommands.js +62 -159
- 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/files.js +24 -85
- package/dist/chris/files.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 -1082
- package/dist/chris/help.js.map +1 -1
- package/dist/chris/kinds.d.ts +30 -0
- package/dist/chris/kinds.js +154 -0
- package/dist/chris/kinds.js.map +1 -0
- 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/chris/promptContext.d.ts +6 -0
- package/dist/chris/promptContext.js +3 -1
- package/dist/chris/promptContext.js.map +1 -1
- package/dist/core/argumentKinds.d.ts +107 -0
- package/dist/core/argumentKinds.js +223 -0
- package/dist/core/argumentKinds.js.map +1 -0
- package/dist/core/backend.d.ts +4 -1
- package/dist/core/backend.js.map +1 -1
- package/dist/core/commandDeclaration.d.ts +453 -0
- package/dist/core/commandDeclaration.js +52 -0
- package/dist/core/commandDeclaration.js.map +1 -0
- package/dist/core/commandParse.d.ts +64 -0
- package/dist/core/commandParse.js +468 -0
- package/dist/core/commandParse.js.map +1 -0
- package/dist/core/commandRegistry.d.ts +37 -0
- package/dist/core/commandRegistry.js +100 -3
- package/dist/core/commandRegistry.js.map +1 -1
- package/dist/core/commandSchema.d.ts +32 -0
- package/dist/core/commandSchema.js +117 -0
- package/dist/core/commandSchema.js.map +1 -0
- package/dist/core/commandUsage.d.ts +62 -0
- package/dist/core/commandUsage.js +247 -0
- package/dist/core/commandUsage.js.map +1 -0
- package/dist/core/coreCommands.js +66 -214
- package/dist/core/coreCommands.js.map +1 -1
- package/dist/core/dispatch.js +15 -8
- package/dist/core/dispatch.js.map +1 -1
- package/dist/core/paths.d.ts +51 -0
- package/dist/core/paths.js +86 -2
- package/dist/core/paths.js.map +1 -1
- package/dist/core/preprocess.d.ts +10 -9
- package/dist/core/preprocess.js +10 -20
- package/dist/core/preprocess.js.map +1 -1
- package/dist/core/warmupFailures.d.ts +34 -2
- package/dist/core/warmupFailures.js +43 -2
- package/dist/core/warmupFailures.js.map +1 -1
- package/dist/lib/completer/cfsPaths.d.ts +14 -0
- package/dist/lib/completer/cfsPaths.js +91 -0
- package/dist/lib/completer/cfsPaths.js.map +1 -0
- package/dist/lib/completer/declared.d.ts +15 -0
- package/dist/lib/completer/declared.js +189 -0
- package/dist/lib/completer/declared.js.map +1 -0
- package/dist/lib/completer/index.js +33 -79
- package/dist/lib/completer/index.js.map +1 -1
- package/dist/lib/parser.d.ts +5 -8
- package/dist/lib/parser.js +2 -11
- package/dist/lib/parser.js.map +1 -1
- package/dist/lib/vfs/vfs.d.ts +2 -1
- package/dist/lib/vfs/vfs.js +9 -6
- package/dist/lib/vfs/vfs.js.map +1 -1
- package/dist/lib/wildcard.js +2 -3
- package/dist/lib/wildcard.js.map +1 -1
- package/dist/notes.json +1 -1
- package/package.json +6 -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,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAwE,MAAM,kCAAkC,CAAC;AACzI,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAwB,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,kDAAkD;AAClD,MAAM,kBAAkB,GAAW,GAAG,GAAG,IAAI,CAAC;AAE9C,sFAAsF;AACtF,MAAM,cAAc,GAAG;IACrB,WAAW,EAAE;QACX,KAAK,EAAE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
-
* 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,10 +171,11 @@ 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
|
-
:
|
|
108
|
-
|
|
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;
|
|
177
|
+
// Copied from where the store keeps it (a /proc data path, a link); named as it was asked.
|
|
178
|
+
const copied = await dispatcher.cp(await storePath_resolve(srcPath), finalDest, { recursive });
|
|
109
179
|
const success = copied.ok;
|
|
110
180
|
if (sources.length === 1) {
|
|
111
181
|
rendered += `${cp_render(srcPath, destPath, success)}\n`;
|
|
@@ -131,11 +201,7 @@ export async function cp_run(options) {
|
|
|
131
201
|
failCount++;
|
|
132
202
|
}
|
|
133
203
|
}
|
|
134
|
-
|
|
135
|
-
// listings were cached beneath it) and its parent.
|
|
136
|
-
listCache.cache_invalidateTree?.(destPath);
|
|
137
|
-
const destParent = path.posix.dirname(destPath);
|
|
138
|
-
listCache.cache_invalidate?.(destParent);
|
|
204
|
+
destination_invalidate(listCache, [destPath, destStore]);
|
|
139
205
|
// Summary for multiple files
|
|
140
206
|
if (sources.length > 1) {
|
|
141
207
|
if (failCount === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cp.js","sourceRoot":"","sources":["../../../src/builtins/fs/cp.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cp.js","sourceRoot":"","sources":["../../../src/builtins/fs/cp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,eAAe,EAA8C,MAAM,kCAAkC,CAAC;AAC/G,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAA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;IAED,sBAAsB,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;IAEzD,6BAA6B;IAC7B,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;YACpB,QAAQ,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,YAAY,YAAY,eAAe,QAAQ,EAAE,CAAC,IAAI,CAAC;QACpF,CAAC;aAAM,CAAC;YACN,QAAQ,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,YAAY,aAAa,SAAS,SAAS,CAAC,IAAI,CAAC;QAC3F,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACrG,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QAClB,MAAM,QAAQ,GAAoB,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,IAAI,SAAS,CAAC,CAAC;QAChG,QAAQ,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACpD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,WAAW,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -1,9 +1,36 @@
|
|
|
1
1
|
import { type CommandEnvelope } from '@fnndsc/menu';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* it to the surface when the engine's disk is not the operator's.
|
|
3
|
+
* `download [-f] <source…> <destination>`: the declaration.
|
|
5
4
|
*
|
|
6
|
-
* @
|
|
7
|
-
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* commands_register({ declarations: [downloadCommand] }, 'backend');
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare const downloadCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
|
|
11
|
+
readonly operands: readonly [{
|
|
12
|
+
readonly name: "source";
|
|
13
|
+
readonly kind: "cfsPath";
|
|
14
|
+
readonly repeat: true;
|
|
15
|
+
readonly glob: true;
|
|
16
|
+
readonly summary: "What to download: a ChRIS file or folder; a wildcard matches paths";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "destination";
|
|
19
|
+
readonly kind: "hostPath";
|
|
20
|
+
readonly summary: "Where it goes on this machine's disk; several sources go into one folder";
|
|
21
|
+
}];
|
|
22
|
+
readonly options: {
|
|
23
|
+
readonly force: {
|
|
24
|
+
readonly short: "f";
|
|
25
|
+
readonly long: "force";
|
|
26
|
+
readonly summary: "Overwrite local paths that exist";
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* `download` over words already split: the declaration's parse and handler.
|
|
32
|
+
*
|
|
33
|
+
* @param args - The words after `download`.
|
|
34
|
+
* @returns The download summary, or the refusal of a bad line.
|
|
8
35
|
*/
|
|
9
36
|
export declare function builtin_download(args: string[]): Promise<CommandEnvelope>;
|