@fnndsc/brasa 0.56.2 → 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/berthCube.d.ts +3 -2
- package/dist/builtins/berth/berthCube.js +5 -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/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/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 +38 -2
- package/dist/builtins/help.js +76 -769
- 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 +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 +3 -3
package/dist/builtins/fs/mv.js
CHANGED
|
@@ -1,44 +1,76 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
2
|
+
* @file `mv`: moves or renames files and folders within ChRIS's filesystem
|
|
3
|
+
* (CFS), reported as a command envelope.
|
|
4
|
+
*
|
|
5
|
+
* Declared in one record (`mvCommand`): 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 is the entry itself, so moving a link moves the link, never what
|
|
9
|
+
* it points at; a destination through a link lands in the link's target.
|
|
10
|
+
* What mv says names the paths as the session resolves them.
|
|
11
|
+
*
|
|
12
|
+
* Key components:
|
|
13
|
+
* - mvCommand: the declaration.
|
|
14
|
+
* - builtin_mv: the declaration run over words already split.
|
|
15
|
+
* - mv_run: the typed core behind both, and the typed API.
|
|
16
|
+
*
|
|
17
|
+
* Typical usage:
|
|
18
|
+
* ```ts
|
|
19
|
+
* await builtin_mv(['old.txt', 'new.txt']);
|
|
20
|
+
* await mv_run({ sources: ['a.txt', 'b.txt'], dest: 'archive/' });
|
|
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 { pathEntry_find, entry_isFolder } from './entries.js';
|
|
11
36
|
import { mv_render, vfs_fail, vfsRefusal_text } from '@fnndsc/fond';
|
|
12
37
|
import { envelope_ok, envelope_error } from '@fnndsc/menu';
|
|
13
38
|
import { exitCode_set } from '../../core/handlerRun.js';
|
|
39
|
+
/** What an `mv` line may hold. */
|
|
40
|
+
const MV_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
|
+
askTarget: { short: 't', summary: 'Every operand is a source; asks for the target directory, and the answer must be one' },
|
|
46
|
+
targetDirectory: { long: 'target-directory', summary: 'Every operand is a source; move into this directory', value: { name: 'dir', kind: 'cfsPath' } },
|
|
47
|
+
},
|
|
48
|
+
};
|
|
14
49
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
50
|
+
* Runs a parsed `mv` line: into a target directory given or asked for, to a
|
|
51
|
+
* destination asked for a lone source, or to the last operand.
|
|
17
52
|
*
|
|
18
|
-
* @param args -
|
|
19
|
-
* @returns
|
|
20
|
-
* whose model carries per-source outcomes.
|
|
53
|
+
* @param args - The typed line.
|
|
54
|
+
* @returns The move's envelope, or the refusal of an abandoned question.
|
|
21
55
|
*/
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return mv_run({ sources: pathArgs, dest: target });
|
|
37
|
-
}
|
|
56
|
+
async function mv_handle(args) {
|
|
57
|
+
const paths = args.operands.paths;
|
|
58
|
+
// `--target-directory <dir>` names the TARGET DIRECTORY, so every operand
|
|
59
|
+
// is a source: the shell's own answer to "several things, one destination".
|
|
60
|
+
const target = args.options.targetDirectory;
|
|
61
|
+
if (target !== undefined)
|
|
62
|
+
return mv_run({ sources: paths, dest: target });
|
|
63
|
+
// `-t` alone is that line with the directory not said: a question
|
|
64
|
+
// (an-absent-value-is-a-question), and the answer wants a directory:
|
|
65
|
+
// `mv a b` without it means rename a ONTO b, the right reading of that
|
|
66
|
+
// line and the wrong thing for a set. One operand names what to move and
|
|
67
|
+
// not where: a question too, not a usage error. The answer opens where
|
|
68
|
+
// the file already lives, so the ordinary case is a rename.
|
|
69
|
+
if (args.options.askTarget || paths.length === 1) {
|
|
38
70
|
// The sources are fixed before the question: other commands run while it is open.
|
|
39
|
-
const sources = await operands_fix(
|
|
71
|
+
const sources = await operands_fix(paths);
|
|
40
72
|
const chosen = await destination_ask({
|
|
41
|
-
verb: 'mv', commit: 'MOVE HERE', sources, wantsDirectory: true,
|
|
73
|
+
verb: 'mv', commit: 'MOVE HERE', sources, ...(args.options.askTarget ? { wantsDirectory: true } : {}),
|
|
42
74
|
});
|
|
43
75
|
if (chosen === '') {
|
|
44
76
|
exitCode_set(1);
|
|
@@ -46,26 +78,47 @@ export async function builtin_mv(args) {
|
|
|
46
78
|
}
|
|
47
79
|
return mv_run({ sources, dest: chosen });
|
|
48
80
|
}
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
81
|
+
// The last operand is the destination, all others are sources.
|
|
82
|
+
return mv_run({ sources: paths.slice(0, -1), dest: paths[paths.length - 1] ?? '' });
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* `mv [-t] [--target-directory <dir>] <paths…>`: the declaration.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* commands_register({ declarations: [mvCommand] });
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export const mvCommand = command_declare({
|
|
93
|
+
name: 'mv',
|
|
94
|
+
grammar: MV_GRAMMAR,
|
|
95
|
+
help: {
|
|
96
|
+
summary: 'Move or rename files or directories (supports wildcards and multiple sources)',
|
|
97
|
+
description: "Moves or renames files or folders within ChRIS's filesystem: the last operand is the destination, and into a folder it names an entry keeps its name. Given only a source, the destination is asked for. A link is moved as itself, never what it points at; a destination through a link lands in the folder it points at.",
|
|
98
|
+
category: 'Files',
|
|
99
|
+
posix: { group: 'Files', differs: 'moves within CFS' },
|
|
100
|
+
examples: [
|
|
101
|
+
'mv old.txt new.txt # Rename file',
|
|
102
|
+
'mv dir1/ dir2/ # Move directory into dir2',
|
|
103
|
+
'mv file.txt /home/user/archive/ # Move into existing directory',
|
|
104
|
+
'mv file1 file2 file3 dest/ # Move multiple files',
|
|
105
|
+
'mv uploads/* backup/ # Move with wildcard',
|
|
106
|
+
'mv --target-directory backup/ a b # Move several into one folder',
|
|
107
|
+
'mv -t a.txt b.txt # Ask which folder they go to',
|
|
108
|
+
'mv "file with spaces.txt" dest/ # Use quotes for spaces',
|
|
109
|
+
],
|
|
110
|
+
},
|
|
111
|
+
handler: mv_handle,
|
|
112
|
+
});
|
|
113
|
+
/**
|
|
114
|
+
* `mv` over words already split: the declaration's parse and handler.
|
|
115
|
+
*
|
|
116
|
+
* @param args - The words after `mv`.
|
|
117
|
+
* @returns An envelope whose rendered text reports progress and results and
|
|
118
|
+
* whose model carries per-source outcomes, or the refusal of a bad line.
|
|
119
|
+
*/
|
|
120
|
+
export async function builtin_mv(args) {
|
|
121
|
+
return declaredCommand_run(mvCommand, args);
|
|
69
122
|
}
|
|
70
123
|
/**
|
|
71
124
|
* Moves one entry. Into a folder the destination names (or one named with a
|
|
@@ -74,20 +127,32 @@ export async function builtin_mv(args) {
|
|
|
74
127
|
* and across one it refuses.
|
|
75
128
|
*
|
|
76
129
|
* @param dispatcher - The session's filesystem.
|
|
77
|
-
* @param
|
|
78
|
-
* @param destPath - The absolute destination.
|
|
79
|
-
* @param intoFolder - Whether the destination was written with a trailing slash.
|
|
130
|
+
* @param move - The source and destination, as the store keeps them.
|
|
80
131
|
* @returns Done, or why not.
|
|
81
132
|
*/
|
|
82
|
-
async function entry_move(dispatcher,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
133
|
+
async function entry_move(dispatcher, move) {
|
|
134
|
+
const { srcStore, destStore, srcPath, intoFolder } = move;
|
|
135
|
+
if (dispatcher.path_isVirtual(srcStore) || dispatcher.path_isVirtual(destStore))
|
|
136
|
+
return dispatcher.rename(srcStore, destStore);
|
|
137
|
+
if ((await pathEntry_find(dispatcher, srcStore)) === null)
|
|
86
138
|
return vfs_fail('ENOENT', `Source not found: ${srcPath}`);
|
|
87
|
-
const finalDest = intoFolder || entry_isFolder(await pathEntry_find(dispatcher,
|
|
88
|
-
? path.posix.join(
|
|
89
|
-
:
|
|
90
|
-
return dispatcher.rename(
|
|
139
|
+
const finalDest = intoFolder || entry_isFolder(await pathEntry_find(dispatcher, destStore))
|
|
140
|
+
? path.posix.join(destStore, path.posix.basename(srcStore))
|
|
141
|
+
: destStore;
|
|
142
|
+
return dispatcher.rename(srcStore, finalDest);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Forgets the cached listings a move changes at a path: beneath it and of
|
|
146
|
+
* its parent, by each name it has.
|
|
147
|
+
*
|
|
148
|
+
* @param listCache - The session's listing cache.
|
|
149
|
+
* @param names - The path as the session names it and as the store keeps it.
|
|
150
|
+
*/
|
|
151
|
+
function listings_invalidate(listCache, names) {
|
|
152
|
+
for (const name of new Set(names)) {
|
|
153
|
+
listCache.cache_invalidate?.(path.posix.dirname(name));
|
|
154
|
+
listCache.cache_invalidateTree?.(name);
|
|
155
|
+
}
|
|
91
156
|
}
|
|
92
157
|
/**
|
|
93
158
|
* Moves or renames files or directories: the shared typed core behind the
|
|
@@ -104,6 +169,8 @@ export async function mv_run(options) {
|
|
|
104
169
|
return envelope_error(`${chalk.red('Usage: mv <source...> <dest>')}\n`);
|
|
105
170
|
}
|
|
106
171
|
const destPath = await path_resolve(dest);
|
|
172
|
+
// Written where the store keeps it: into a linked folder lands in the link's target.
|
|
173
|
+
const destStore = await storePath_resolve(destPath);
|
|
107
174
|
const listCache = listingCache_get();
|
|
108
175
|
const dispatcher = vfsDispatcher_get();
|
|
109
176
|
let successCount = 0;
|
|
@@ -114,6 +181,8 @@ export async function mv_run(options) {
|
|
|
114
181
|
for (const src of sources) {
|
|
115
182
|
try {
|
|
116
183
|
const srcPath = await path_resolve(src);
|
|
184
|
+
// The entry itself: moving a link moves the link, not what it points at.
|
|
185
|
+
const srcStore = await storePath_resolve(srcPath, { entry: true });
|
|
117
186
|
// For multiple sources, show which file we're moving
|
|
118
187
|
if (sources.length > 1) {
|
|
119
188
|
rendered += `${chalk.gray(`Moving ${srcPath}...`)}\n`;
|
|
@@ -121,7 +190,7 @@ export async function mv_run(options) {
|
|
|
121
190
|
else {
|
|
122
191
|
rendered += `Moving ${srcPath} to ${destPath}...\n`;
|
|
123
192
|
}
|
|
124
|
-
const moved = await entry_move(dispatcher,
|
|
193
|
+
const moved = await entry_move(dispatcher, { srcStore, destStore, srcPath, intoFolder: dest.endsWith('/') });
|
|
125
194
|
const success = moved.ok;
|
|
126
195
|
if (sources.length === 1) {
|
|
127
196
|
rendered += `${mv_render(srcPath, destPath, success)}\n`;
|
|
@@ -138,9 +207,7 @@ export async function mv_run(options) {
|
|
|
138
207
|
// Invalidate the source's parent AND the moved subtree: listings
|
|
139
208
|
// cached beneath the old path would otherwise serve the vanished
|
|
140
209
|
// tree until their TTL expires.
|
|
141
|
-
|
|
142
|
-
listCache.cache_invalidate?.(srcDir);
|
|
143
|
-
listCache.cache_invalidateTree?.(srcPath);
|
|
210
|
+
listings_invalidate(listCache, [srcPath, srcStore]);
|
|
144
211
|
}
|
|
145
212
|
else {
|
|
146
213
|
failCount++;
|
|
@@ -155,9 +222,7 @@ export async function mv_run(options) {
|
|
|
155
222
|
}
|
|
156
223
|
// Invalidate the destination subtree (a moved directory replaces whatever
|
|
157
224
|
// listings were cached beneath it) and its parent.
|
|
158
|
-
listCache
|
|
159
|
-
const destParent = path.posix.dirname(destPath);
|
|
160
|
-
listCache.cache_invalidate?.(destParent);
|
|
225
|
+
listings_invalidate(listCache, [destPath, destStore]);
|
|
161
226
|
// Summary for multiple files
|
|
162
227
|
if (sources.length > 1) {
|
|
163
228
|
if (failCount === 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mv.js","sourceRoot":"","sources":["../../../src/builtins/fs/mv.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"mv.js","s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WAAW,YAAY,aAAa,SAAS,SAAS,CAAC,IAAI,CAAC;QAC1F,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACpG,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,25 +1,64 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
2
|
+
* @file What a pull's line may hold, as `pull` and `pacs pull` both take it:
|
|
3
|
+
* the queries, studies or series to pull, and how to wait for them.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
+
* One grammar, so the standalone verb and the subcommand cannot drift. It
|
|
6
|
+
* lives apart from the pull verb so `pacs` reads it without loading that
|
|
7
|
+
* verb's graph.
|
|
8
|
+
*
|
|
9
|
+
* Key components:
|
|
10
|
+
* - PULL_GRAMMAR: the operands and options.
|
|
11
|
+
* - PullLine: what a handler of either line reads.
|
|
12
|
+
*
|
|
13
|
+
* Dependencies: the declaration types only.
|
|
5
14
|
*
|
|
6
15
|
* @module
|
|
7
16
|
*/
|
|
17
|
+
import type { CommandArguments } from '../../core/commandDeclaration.js';
|
|
8
18
|
/**
|
|
9
|
-
*
|
|
10
|
-
*/
|
|
11
|
-
export interface PullArgs {
|
|
12
|
-
nowait: boolean;
|
|
13
|
-
retryMax: number;
|
|
14
|
-
newFeedTitle: string | null;
|
|
15
|
-
parseError: string | null;
|
|
16
|
-
paths: string[];
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Parses `pull` arguments: `--detach` (`--nowait`), `--retry N`, `--new-feed TITLE`, and
|
|
20
|
-
* path operands.
|
|
19
|
+
* A pull's operands and options.
|
|
21
20
|
*
|
|
22
|
-
* @
|
|
23
|
-
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const pullCommand = command_declare({ name: 'pull', grammar: PULL_GRAMMAR, help, handler });
|
|
24
|
+
* ```
|
|
24
25
|
*/
|
|
25
|
-
export declare
|
|
26
|
+
export declare const PULL_GRAMMAR: {
|
|
27
|
+
readonly operands: readonly [{
|
|
28
|
+
readonly name: "target";
|
|
29
|
+
readonly kind: "pacsQuery";
|
|
30
|
+
readonly repeat: true;
|
|
31
|
+
readonly glob: true;
|
|
32
|
+
readonly summary: "A /net/pacs/queries/… path (a query, a study or a series), or a Key:Value question asked first";
|
|
33
|
+
}];
|
|
34
|
+
readonly options: {
|
|
35
|
+
readonly detach: {
|
|
36
|
+
readonly long: "detach";
|
|
37
|
+
readonly summary: "Fire the retrieves and return the handles at once: <seriesUID> <retrieveId> per line";
|
|
38
|
+
};
|
|
39
|
+
readonly nowait: {
|
|
40
|
+
readonly long: "nowait";
|
|
41
|
+
readonly summary: "The older spelling of --detach";
|
|
42
|
+
};
|
|
43
|
+
readonly retry: {
|
|
44
|
+
readonly long: "retry";
|
|
45
|
+
readonly summary: "Re-fire retrieves for [NO LONK] series up to N more times";
|
|
46
|
+
readonly value: {
|
|
47
|
+
readonly name: "N";
|
|
48
|
+
readonly kind: "int";
|
|
49
|
+
readonly min: 0;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
readonly newFeed: {
|
|
53
|
+
readonly long: "new-feed";
|
|
54
|
+
readonly repeat: true;
|
|
55
|
+
readonly summary: "Create one named feed from the complete retrieved selection";
|
|
56
|
+
readonly value: {
|
|
57
|
+
readonly name: "title";
|
|
58
|
+
readonly kind: "word";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/** What a handler of a pull line reads: the targets and the options, from `pull` or `pacs pull`. */
|
|
64
|
+
export type PullLine = Pick<CommandArguments<typeof PULL_GRAMMAR>, 'operands' | 'options'>;
|
|
@@ -1,70 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* A pull's operands and options.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Parses `pull` arguments: `--detach` (`--nowait`), `--retry N`, `--new-feed TITLE`, and
|
|
10
|
-
* path operands.
|
|
11
|
-
*
|
|
12
|
-
* @param args - Raw command arguments.
|
|
13
|
-
* @returns The parsed flags and paths.
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const pullCommand = command_declare({ name: 'pull', grammar: PULL_GRAMMAR, help, handler });
|
|
7
|
+
* ```
|
|
14
8
|
*/
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
else if (commandArgs[i] === '--retry') {
|
|
29
|
-
const value = commandArgs[i + 1];
|
|
30
|
-
if (value === undefined || value.startsWith('--')) {
|
|
31
|
-
parseError ??= '--retry requires a non-negative integer';
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
i++;
|
|
35
|
-
const n = Number(value);
|
|
36
|
-
if (Number.isInteger(n) && n >= 0) {
|
|
37
|
-
retryMax = n;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
parseError ??= '--retry requires a non-negative integer';
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else if (commandArgs[i] === '--new-feed') {
|
|
44
|
-
if (newFeedTitle !== null) {
|
|
45
|
-
parseError = '--new-feed may only be specified once';
|
|
46
|
-
}
|
|
47
|
-
const title = commandArgs[i + 1];
|
|
48
|
-
if (title === undefined || title.startsWith('--') || title.trim().length === 0) {
|
|
49
|
-
parseError ??= '--new-feed requires a title';
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
newFeedTitle = title.trim();
|
|
53
|
-
i++;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else if (commandArgs[i] === '--plugin' || commandArgs[i] === '--pipeline') {
|
|
57
|
-
// Pulling lands data; running over it is `gather process`, or a run
|
|
58
|
-
// by name where the pull's feed stands.
|
|
59
|
-
parseError ??= `${commandArgs[i]} is retired: pull lands the data; run over it with gather process <name>, or cd into the feed and run by name`;
|
|
60
|
-
}
|
|
61
|
-
else if (commandArgs[i].startsWith('--')) {
|
|
62
|
-
parseError ??= `unsupported option: ${commandArgs[i]}`;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
paths.push(commandArgs[i]);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return { nowait, retryMax, newFeedTitle, parseError, paths };
|
|
69
|
-
}
|
|
9
|
+
export const PULL_GRAMMAR = {
|
|
10
|
+
operands: [
|
|
11
|
+
{ name: 'target', kind: 'pacsQuery', repeat: true, glob: true, summary: 'A /net/pacs/queries/… path (a query, a study or a series), or a Key:Value question asked first' },
|
|
12
|
+
],
|
|
13
|
+
options: {
|
|
14
|
+
detach: { long: 'detach', summary: 'Fire the retrieves and return the handles at once: <seriesUID> <retrieveId> per line' },
|
|
15
|
+
nowait: { long: 'nowait', summary: 'The older spelling of --detach' },
|
|
16
|
+
retry: { long: 'retry', summary: 'Re-fire retrieves for [NO LONK] series up to N more times', value: { name: 'N', kind: 'int', min: 0 } },
|
|
17
|
+
newFeed: { long: 'new-feed', repeat: true, summary: 'Create one named feed from the complete retrieved selection', value: { name: 'title', kind: 'word' } },
|
|
18
|
+
},
|
|
19
|
+
};
|
|
70
20
|
//# sourceMappingURL=pull.args.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull.args.js","sourceRoot":"","sources":["../../../src/builtins/fs/pull.args.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pull.args.js","sourceRoot":"","sources":["../../../src/builtins/fs/pull.args.ts"],"names":[],"mappings":"AAkBA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ,EAAE;QACR,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,gGAAgG,EAAE;KAC3K;IACD,OAAO,EAAE;QACP,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,sFAAsF,EAAE;QAC3H,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,gCAAgC,EAAE;QACrE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,2DAA2D,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE;QACzI,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,6DAA6D,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;KAC5J;CACgC,CAAC"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @module
|
|
12
12
|
*/
|
|
13
|
+
import { type PullLine } from './pull.args.js';
|
|
13
14
|
import { type CommandEnvelope } from '@fnndsc/menu';
|
|
14
15
|
/**
|
|
15
16
|
* Pulls one or more `/net/pacs/queries/...` VFS paths into ChRIS storage.
|
|
@@ -20,9 +21,70 @@ import { type CommandEnvelope } from '@fnndsc/menu';
|
|
|
20
21
|
* With `--retry N`: re-fires retrieves for [NO LONK] series up to N additional times.
|
|
21
22
|
* With `--new-feed TITLE`: creates one feed from the exact successfully retrieved set.
|
|
22
23
|
*
|
|
24
|
+
* The declaration's parse and handler, over words already split.
|
|
25
|
+
*
|
|
23
26
|
* @param args - Command arguments (VFS paths, optional flags).
|
|
27
|
+
* @returns The outcome, or the refusal of a bad line.
|
|
24
28
|
* @example
|
|
25
29
|
* pull /net/pacs/queries/42_AccessionNumber:12345678
|
|
26
30
|
* pull --retry 3 /net/pacs/queries/42_AccessionNumber:12345678/Study_1.2.3_US-Hips
|
|
27
31
|
*/
|
|
28
32
|
export declare function builtin_pull(args: string[]): Promise<CommandEnvelope>;
|
|
33
|
+
/**
|
|
34
|
+
* `pull [options] <target>…`: the declaration. `pacs pull` takes the same
|
|
35
|
+
* line (`PULL_GRAMMAR`) and runs the same handler.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* commands_register({ declarations: [pullCommand] }, 'backend');
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare const pullCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
|
|
43
|
+
readonly operands: readonly [{
|
|
44
|
+
readonly name: "target";
|
|
45
|
+
readonly kind: "pacsQuery";
|
|
46
|
+
readonly repeat: true;
|
|
47
|
+
readonly glob: true;
|
|
48
|
+
readonly summary: "A /net/pacs/queries/… path (a query, a study or a series), or a Key:Value question asked first";
|
|
49
|
+
}];
|
|
50
|
+
readonly options: {
|
|
51
|
+
readonly detach: {
|
|
52
|
+
readonly long: "detach";
|
|
53
|
+
readonly summary: "Fire the retrieves and return the handles at once: <seriesUID> <retrieveId> per line";
|
|
54
|
+
};
|
|
55
|
+
readonly nowait: {
|
|
56
|
+
readonly long: "nowait";
|
|
57
|
+
readonly summary: "The older spelling of --detach";
|
|
58
|
+
};
|
|
59
|
+
readonly retry: {
|
|
60
|
+
readonly long: "retry";
|
|
61
|
+
readonly summary: "Re-fire retrieves for [NO LONK] series up to N more times";
|
|
62
|
+
readonly value: {
|
|
63
|
+
readonly name: "N";
|
|
64
|
+
readonly kind: "int";
|
|
65
|
+
readonly min: 0;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
readonly newFeed: {
|
|
69
|
+
readonly long: "new-feed";
|
|
70
|
+
readonly repeat: true;
|
|
71
|
+
readonly summary: "Create one named feed from the complete retrieved selection";
|
|
72
|
+
readonly value: {
|
|
73
|
+
readonly name: "title";
|
|
74
|
+
readonly kind: "word";
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Pulls the series a line names: the handler of `pull` and of `pacs pull`.
|
|
81
|
+
*
|
|
82
|
+
* @param args - The line, parsed.
|
|
83
|
+
* @returns The outcome; the progress and the CUBE paths stream as it runs.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* await pullLine_run({ operands: { target: ['/net/pacs/queries/42_AccessionNumber:1'] }, options: { detach: true, … } });
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function pullLine_run(args: PullLine): Promise<CommandEnvelope>;
|