@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
package/dist/builtins/fs/du.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ParsedArgs } from '../utils.js';
|
|
2
1
|
import { type ScanRecord } from '@fnndsc/chili/path/pathCommand.js';
|
|
3
2
|
import { type CommandEnvelope } from '@fnndsc/menu';
|
|
4
3
|
/**
|
|
@@ -13,14 +12,67 @@ export interface DuOptions {
|
|
|
13
12
|
maxDepth: number | undefined;
|
|
14
13
|
}
|
|
15
14
|
/**
|
|
16
|
-
*
|
|
17
|
-
* takes a value for: a short flag is otherwise a switch, and the depth
|
|
18
|
-
* read as a path to measure.
|
|
15
|
+
* `du [-hsacS] [-d <N>] [path…]`: the declaration.
|
|
19
16
|
*
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* commands_register({ declarations: [duCommand] }, 'backend');
|
|
20
|
+
* ```
|
|
22
21
|
*/
|
|
23
|
-
export declare
|
|
22
|
+
export declare const duCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
|
|
23
|
+
readonly operands: readonly [{
|
|
24
|
+
readonly name: "path";
|
|
25
|
+
readonly kind: "cfsPath";
|
|
26
|
+
readonly optional: true;
|
|
27
|
+
readonly repeat: true;
|
|
28
|
+
readonly glob: true;
|
|
29
|
+
readonly summary: "What to measure; the working directory when none is given";
|
|
30
|
+
}];
|
|
31
|
+
readonly options: {
|
|
32
|
+
readonly humanReadable: {
|
|
33
|
+
readonly short: "h";
|
|
34
|
+
readonly long: "human-readable";
|
|
35
|
+
readonly summary: "Print sizes in human readable format";
|
|
36
|
+
};
|
|
37
|
+
readonly summarize: {
|
|
38
|
+
readonly short: "s";
|
|
39
|
+
readonly long: "summarize";
|
|
40
|
+
readonly summary: "Display only total for each argument";
|
|
41
|
+
};
|
|
42
|
+
readonly all: {
|
|
43
|
+
readonly short: "a";
|
|
44
|
+
readonly long: "all";
|
|
45
|
+
readonly summary: "Show counts for all files, not just directories";
|
|
46
|
+
};
|
|
47
|
+
readonly total: {
|
|
48
|
+
readonly short: "c";
|
|
49
|
+
readonly long: "total";
|
|
50
|
+
readonly summary: "Produce a grand total";
|
|
51
|
+
};
|
|
52
|
+
readonly separateDirs: {
|
|
53
|
+
readonly short: "S";
|
|
54
|
+
readonly long: "separate-dirs";
|
|
55
|
+
readonly summary: "Do not include size of subdirectories";
|
|
56
|
+
};
|
|
57
|
+
readonly maxDepth: {
|
|
58
|
+
readonly short: "d";
|
|
59
|
+
readonly long: "max-depth";
|
|
60
|
+
readonly summary: "Print total only if N or fewer levels below";
|
|
61
|
+
readonly value: {
|
|
62
|
+
readonly name: "N";
|
|
63
|
+
readonly kind: "int";
|
|
64
|
+
readonly min: 0;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* `du` over words already split: the declaration's parse and handler.
|
|
71
|
+
*
|
|
72
|
+
* @param args - The words after `du`.
|
|
73
|
+
* @returns The sizes, or the refusal of a bad line.
|
|
74
|
+
*/
|
|
75
|
+
export declare function builtin_du(args: string[]): Promise<CommandEnvelope>;
|
|
24
76
|
/**
|
|
25
77
|
* Formats a byte count for `du` output: human-readable string or KB integer,
|
|
26
78
|
* right-padded to 12 characters for column alignment.
|
|
@@ -30,13 +82,6 @@ export declare function depthOption_normalize(args: string[]): string[];
|
|
|
30
82
|
* @returns Right-aligned size string.
|
|
31
83
|
*/
|
|
32
84
|
export declare function duSize_format(bytes: number, humanReadable: boolean): string;
|
|
33
|
-
/**
|
|
34
|
-
* Extracts `du` flags from parsed command arguments.
|
|
35
|
-
*
|
|
36
|
-
* @param parsed - The parsed command arguments.
|
|
37
|
-
* @returns The resolved du options.
|
|
38
|
-
*/
|
|
39
|
-
export declare function duOptions_parse(parsed: ParsedArgs): DuOptions;
|
|
40
85
|
/**
|
|
41
86
|
* Accumulates per-directory sizes from a scan result, attributing each file's
|
|
42
87
|
* size to its ancestor directories up to (and including) the target path.
|
|
@@ -47,22 +92,3 @@ export declare function duOptions_parse(parsed: ParsedArgs): DuOptions;
|
|
|
47
92
|
* @returns A map of directory path to accumulated size.
|
|
48
93
|
*/
|
|
49
94
|
export declare function dirSizes_compute(scanResult: ScanRecord, targetPath: string, opts: DuOptions): Map<string, number>;
|
|
50
|
-
/**
|
|
51
|
-
* Displays disk usage statistics for ChRIS filesystem directories.
|
|
52
|
-
* Mimics standard Linux du command behavior and flags.
|
|
53
|
-
* Uses chili's scan_do machinery for recursive filesystem traversal.
|
|
54
|
-
*
|
|
55
|
-
* @param args - Command line arguments (optional path and flags).
|
|
56
|
-
* @returns A Promise that resolves when disk usage is displayed.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```
|
|
60
|
-
* du # Disk usage of current directory
|
|
61
|
-
* du -h # Human-readable sizes
|
|
62
|
-
* du -s /home/user/data # Summary only
|
|
63
|
-
* du -a # Show all files, not just directories
|
|
64
|
-
* du -c # Show grand total
|
|
65
|
-
* du -d 2 # Max depth of 2 levels
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
export declare function builtin_du(args: string[]): Promise<CommandEnvelope>;
|
package/dist/builtins/fs/du.js
CHANGED
|
@@ -1,49 +1,93 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
2
|
+
* @file `du`: how much of ChRIS's filesystem (CFS) each folder takes, as
|
|
3
|
+
* Linux du says it.
|
|
4
|
+
*
|
|
5
|
+
* Declared in one record (`duCommand`): paths that glob, and du's options;
|
|
6
|
+
* one it does not have is refused by name.
|
|
7
|
+
*
|
|
8
|
+
* Key components:
|
|
9
|
+
* - duCommand: the declaration.
|
|
10
|
+
* - builtin_du: the declaration run over words already split.
|
|
11
|
+
* - dirSizes_compute: each folder's size from a scan.
|
|
12
|
+
*
|
|
13
|
+
* Typical usage:
|
|
14
|
+
* ```ts
|
|
15
|
+
* await builtin_du(['-sh', '~/uploads']);
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Dependencies: chili's scan for the walk; the listing for what a path is.
|
|
19
|
+
*
|
|
20
|
+
* @module
|
|
4
21
|
*/
|
|
5
22
|
import chalk from 'chalk';
|
|
6
23
|
import path from 'path';
|
|
7
|
-
import {
|
|
24
|
+
import { path_resolve, storePath_resolve } from '../utils.js';
|
|
8
25
|
import { vfs } from '../../lib/vfs/vfs.js';
|
|
9
26
|
import { spinner } from '../../lib/spinner.js';
|
|
10
27
|
import { commandCancellation_enable, commandCancellation_signalGet } from '../../core/cancellation.js';
|
|
11
28
|
import { scan_do } from '@fnndsc/chili/path/pathCommand.js';
|
|
12
29
|
import { bytes_format } from '@fnndsc/chili/commands/fs/upload.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
/**
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
30
|
+
import { command_declare } from '../../core/commandDeclaration.js';
|
|
31
|
+
import { declaredCommand_run } from '../../core/commandParse.js';
|
|
32
|
+
/** What a `du` line may hold. */
|
|
33
|
+
const DU_GRAMMAR = {
|
|
34
|
+
operands: [
|
|
35
|
+
{ name: 'path', kind: 'cfsPath', optional: true, repeat: true, glob: true, summary: 'What to measure; the working directory when none is given' },
|
|
36
|
+
],
|
|
37
|
+
options: {
|
|
38
|
+
humanReadable: { short: 'h', long: 'human-readable', summary: 'Print sizes in human readable format' },
|
|
39
|
+
summarize: { short: 's', long: 'summarize', summary: 'Display only total for each argument' },
|
|
40
|
+
all: { short: 'a', long: 'all', summary: 'Show counts for all files, not just directories' },
|
|
41
|
+
total: { short: 'c', long: 'total', summary: 'Produce a grand total' },
|
|
42
|
+
separateDirs: { short: 'S', long: 'separate-dirs', summary: 'Do not include size of subdirectories' },
|
|
43
|
+
maxDepth: { short: 'd', long: 'max-depth', summary: 'Print total only if N or fewer levels below', value: { name: 'N', kind: 'int', min: 0 } },
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* `du [-hsacS] [-d <N>] [path…]`: the declaration.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* commands_register({ declarations: [duCommand] }, 'backend');
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export const duCommand = command_declare({
|
|
55
|
+
name: 'du',
|
|
56
|
+
grammar: DU_GRAMMAR,
|
|
57
|
+
help: {
|
|
58
|
+
summary: 'Display disk usage statistics (mimics Linux du)',
|
|
59
|
+
description: "Says how much of ChRIS's filesystem each folder under a path takes, its subfolders included, as Linux du does: the working directory when no path is given, each path given otherwise (a wildcard matches paths). A file is its own size.",
|
|
60
|
+
category: 'Navigation',
|
|
61
|
+
posix: { group: 'Files', differs: 'sizes in CFS' },
|
|
62
|
+
examples: [
|
|
63
|
+
'du # Disk usage of current directory',
|
|
64
|
+
'du -h # Human-readable sizes (1K, 234M, 2G)',
|
|
65
|
+
'du -s /home/user/data # Summary only for specified path',
|
|
66
|
+
'du -a # Show all files, not just directories',
|
|
67
|
+
'du -c # Show grand total at end',
|
|
68
|
+
'du -d 2 # Max depth of 2 levels',
|
|
69
|
+
'du -sh # Human-readable summary',
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
holds: [],
|
|
73
|
+
handler: async (args) => du_run(args.operands.path, {
|
|
74
|
+
humanReadable: args.options.humanReadable,
|
|
75
|
+
summarize: args.options.summarize,
|
|
76
|
+
showAll: args.options.all,
|
|
77
|
+
showTotal: args.options.total,
|
|
78
|
+
separateDirs: args.options.separateDirs,
|
|
79
|
+
maxDepth: args.options.maxDepth,
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
19
82
|
/**
|
|
20
|
-
*
|
|
21
|
-
* takes a value for: a short flag is otherwise a switch, and the depth
|
|
22
|
-
* read as a path to measure.
|
|
83
|
+
* `du` over words already split: the declaration's parse and handler.
|
|
23
84
|
*
|
|
24
|
-
* @param args -
|
|
25
|
-
* @returns The
|
|
85
|
+
* @param args - The words after `du`.
|
|
86
|
+
* @returns The sizes, or the refusal of a bad line.
|
|
26
87
|
*/
|
|
27
|
-
export function
|
|
28
|
-
|
|
29
|
-
for (let i = 0; i < args.length; i++) {
|
|
30
|
-
const arg = args[i];
|
|
31
|
-
if (arg === '--') {
|
|
32
|
-
out.push(...args.slice(i));
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
if (arg === '-d' && args[i + 1] !== undefined) {
|
|
36
|
-
out.push(`--max-depth=${args[i + 1]}`);
|
|
37
|
-
i++;
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
const glued = arg.match(/^-d(\d+)$/);
|
|
41
|
-
out.push(glued !== null ? `--max-depth=${glued[1]}` : arg);
|
|
42
|
-
}
|
|
43
|
-
return out;
|
|
88
|
+
export async function builtin_du(args) {
|
|
89
|
+
return declaredCommand_run(duCommand, args);
|
|
44
90
|
}
|
|
45
|
-
/** Every option du reads; any other is refused by name. */
|
|
46
|
-
const DU_OPTIONS = [...DU_BOOLEAN_LONG_OPTIONS, 'max-depth', 'h', 's', 'a', 'c', 'S', 'd'];
|
|
47
91
|
/**
|
|
48
92
|
* Formats a byte count for `du` output: human-readable string or KB integer,
|
|
49
93
|
* right-padded to 12 characters for column alignment.
|
|
@@ -58,27 +102,6 @@ export function duSize_format(bytes, humanReadable) {
|
|
|
58
102
|
: Math.ceil(bytes / 1024).toString();
|
|
59
103
|
return formatted.padStart(12, ' ');
|
|
60
104
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Extracts `du` flags from parsed command arguments.
|
|
63
|
-
*
|
|
64
|
-
* @param parsed - The parsed command arguments.
|
|
65
|
-
* @returns The resolved du options.
|
|
66
|
-
*/
|
|
67
|
-
export function duOptions_parse(parsed) {
|
|
68
|
-
const maxDepth = parsed['d']
|
|
69
|
-
? parseInt(String(parsed['d']), 10)
|
|
70
|
-
: parsed['max-depth']
|
|
71
|
-
? parseInt(String(parsed['max-depth']), 10)
|
|
72
|
-
: undefined;
|
|
73
|
-
return {
|
|
74
|
-
humanReadable: !!parsed['h'] || !!parsed['human-readable'],
|
|
75
|
-
summarize: !!parsed['s'] || !!parsed['summarize'],
|
|
76
|
-
showAll: !!parsed['a'] || !!parsed['all'],
|
|
77
|
-
showTotal: !!parsed['c'] || !!parsed['total'],
|
|
78
|
-
separateDirs: !!parsed['S'] || !!parsed['separate-dirs'],
|
|
79
|
-
maxDepth,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
105
|
/**
|
|
83
106
|
* Resolves whether a target path is a directory or a file (with size).
|
|
84
107
|
*
|
|
@@ -175,34 +198,22 @@ function dirUsage_render(dirSizes, targetPath, opts) {
|
|
|
175
198
|
* Mimics standard Linux du command behavior and flags.
|
|
176
199
|
* Uses chili's scan_do machinery for recursive filesystem traversal.
|
|
177
200
|
*
|
|
178
|
-
* @param
|
|
179
|
-
* @
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```
|
|
183
|
-
* du # Disk usage of current directory
|
|
184
|
-
* du -h # Human-readable sizes
|
|
185
|
-
* du -s /home/user/data # Summary only
|
|
186
|
-
* du -a # Show all files, not just directories
|
|
187
|
-
* du -c # Show grand total
|
|
188
|
-
* du -d 2 # Max depth of 2 levels
|
|
189
|
-
* ```
|
|
201
|
+
* @param pathArgs - The paths to measure; none measures the working directory.
|
|
202
|
+
* @param opts - The du options.
|
|
203
|
+
* @returns The sizes, and on the error channel each path that could not be read.
|
|
190
204
|
*/
|
|
191
|
-
|
|
192
|
-
const parsed = commandArgs_process(depthOption_normalize(args), { booleanLongOptions: DU_BOOLEAN_LONG_OPTIONS });
|
|
193
|
-
const unknown = optionsUnknown_refusal('du', parsed, DU_OPTIONS);
|
|
194
|
-
if (unknown !== null) {
|
|
195
|
-
exitCode_set(1);
|
|
196
|
-
return envelope_error('', undefined, `${chalk.red(unknown)}\n`);
|
|
197
|
-
}
|
|
198
|
-
const opts = duOptions_parse(parsed);
|
|
199
|
-
const pathArgs = parsed._;
|
|
205
|
+
async function du_run(pathArgs, opts) {
|
|
200
206
|
commandCancellation_enable();
|
|
201
207
|
const signal = commandCancellation_signalGet();
|
|
202
|
-
const rawTargets = pathArgs.length > 0 ? pathArgs : ['.'];
|
|
208
|
+
const rawTargets = pathArgs.length > 0 ? [...pathArgs] : ['.'];
|
|
209
|
+
// Sized where the store keeps it (a run's data path, a link on the line),
|
|
210
|
+
// and named as the session names it.
|
|
203
211
|
const resolvedTargets = [];
|
|
212
|
+
const logicalTargets = new Map();
|
|
204
213
|
for (const raw of rawTargets) {
|
|
205
|
-
|
|
214
|
+
const stored = await storePath_resolve(raw);
|
|
215
|
+
resolvedTargets.push(stored);
|
|
216
|
+
logicalTargets.set(stored, await path_resolve(raw));
|
|
206
217
|
}
|
|
207
218
|
let grandTotal = 0;
|
|
208
219
|
let rendered = '';
|
|
@@ -223,7 +234,7 @@ export async function builtin_du(args) {
|
|
|
223
234
|
if (!stat.isDirectory) {
|
|
224
235
|
grandTotal += stat.fileSize;
|
|
225
236
|
spinner.stop();
|
|
226
|
-
rendered += `${duSize_format(stat.fileSize, opts.humanReadable)}\t${targetPath}\n`;
|
|
237
|
+
rendered += `${duSize_format(stat.fileSize, opts.humanReadable)}\t${logicalTargets.get(targetPath) ?? targetPath}\n`;
|
|
227
238
|
continue;
|
|
228
239
|
}
|
|
229
240
|
// Scanned where it stands: the shared directory stays put.
|
|
@@ -246,7 +257,7 @@ export async function builtin_du(args) {
|
|
|
246
257
|
const dirSizes = dirSizes_compute(scanResult, targetPath, opts);
|
|
247
258
|
grandTotal += scanResult.totalSize;
|
|
248
259
|
spinner.stop();
|
|
249
|
-
rendered += dirUsage_render(dirSizes, targetPath, opts);
|
|
260
|
+
rendered += usageNames_logical(dirUsage_render(dirSizes, targetPath, opts), targetPath, logicalTargets.get(targetPath) ?? targetPath);
|
|
250
261
|
}
|
|
251
262
|
if (opts.showTotal && rawTargets.length > 0) {
|
|
252
263
|
rendered += `${duSize_format(grandTotal, opts.humanReadable)}\ttotal\n`;
|
|
@@ -261,4 +272,25 @@ export async function builtin_du(args) {
|
|
|
261
272
|
spinner.stop();
|
|
262
273
|
}
|
|
263
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Names each row of a folder's usage as the session names it: the store
|
|
277
|
+
* folder it was read from gives way to the path asked.
|
|
278
|
+
*
|
|
279
|
+
* @param rows - The rows, `size<TAB>path` each.
|
|
280
|
+
* @param storeRoot - The store folder scanned.
|
|
281
|
+
* @param logicalRoot - The folder as the session names it.
|
|
282
|
+
* @returns The rows, renamed.
|
|
283
|
+
*/
|
|
284
|
+
function usageNames_logical(rows, storeRoot, logicalRoot) {
|
|
285
|
+
if (storeRoot === logicalRoot)
|
|
286
|
+
return rows;
|
|
287
|
+
return rows.split('\n').map((row) => {
|
|
288
|
+
const tab = row.indexOf('\t');
|
|
289
|
+
if (tab === -1)
|
|
290
|
+
return row;
|
|
291
|
+
const named = row.slice(tab + 1);
|
|
292
|
+
const shown = named === storeRoot ? logicalRoot : named.startsWith(`${storeRoot}/`) ? `${logicalRoot}${named.slice(storeRoot.length)}` : named;
|
|
293
|
+
return `${row.slice(0, tab)}\t${shown}`;
|
|
294
|
+
}).join('\n');
|
|
295
|
+
}
|
|
264
296
|
//# sourceMappingURL=du.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"du.js","sourceRoot":"","sources":["../../../src/builtins/fs/du.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"du.js","sourceRoot":"","sources":["../../../src/builtins/fs/du.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;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,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AACvG,OAAO,EAAE,OAAO,EAAiC,MAAM,mCAAm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C;IAClB,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,kBAAkB,CAAC,IAAY,EAAE,SAAiB,EAAE,WAAmB;IAC9E,IAAI,SAAS,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAC3C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAW,EAAU,EAAE;QAClD,MAAM,GAAG,GAAW,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,GAAG,KAAK,CAAC,CAAC;YAAE,OAAO,GAAG,CAAC;QAC3B,MAAM,KAAK,GAAW,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACzC,MAAM,KAAK,GAAW,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACvJ,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC;IAC1C,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
|
@@ -2,10 +2,25 @@ import { type CommandEnvelope } from '@fnndsc/menu';
|
|
|
2
2
|
/** What `edit` says when the surface opened an editor that stays open. */
|
|
3
3
|
export declare const EDIT_OPENED_LINE: string;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* original via delete + re-upload. No-ops if content is unchanged.
|
|
5
|
+
* `edit <file>`: the declaration.
|
|
7
6
|
*
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* commands_register({ declarations: [editCommand] }, 'backend');
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare const editCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
|
|
13
|
+
readonly operands: readonly [{
|
|
14
|
+
readonly name: "file";
|
|
15
|
+
readonly kind: "cfsPath";
|
|
16
|
+
readonly glob: true;
|
|
17
|
+
readonly summary: "The ChRIS file to edit";
|
|
18
|
+
}];
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* `edit` over words already split: the declaration's parse and handler.
|
|
22
|
+
*
|
|
23
|
+
* @param args - The words after `edit`.
|
|
24
|
+
* @returns The edit outcome, or the refusal of a bad line.
|
|
10
25
|
*/
|
|
11
26
|
export declare function builtin_edit(args: string[]): Promise<CommandEnvelope>;
|
package/dist/builtins/fs/edit.js
CHANGED
|
@@ -1,17 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* @file `edit`: a ChRIS file opened in the surface's local editor, and
|
|
3
|
+
* saved back when it changed.
|
|
4
|
+
*
|
|
5
|
+
* The editor mechanics live in the surface, so this command knows nothing
|
|
6
|
+
* of processes or terminals: it reads the file, hands the content to the
|
|
7
|
+
* surface, and writes the result back. The file is read and written where
|
|
8
|
+
* the store keeps it (`storePath_resolve`): a path through a link edits the
|
|
9
|
+
* file the link points at.
|
|
10
|
+
*
|
|
11
|
+
* Declared in one record (`editCommand`): one CFS path.
|
|
12
|
+
*
|
|
13
|
+
* Key components:
|
|
14
|
+
* - editCommand: the declaration.
|
|
15
|
+
* - builtin_edit: the declaration run over words already split.
|
|
16
|
+
* - EDIT_OPENED_LINE: what `edit` says when a pane took the file.
|
|
17
|
+
*
|
|
18
|
+
* Typical usage:
|
|
19
|
+
* ```ts
|
|
20
|
+
* await builtin_edit(['~/uploads/config.yaml']);
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Dependencies: chili's read and replace for a store file; salsa's
|
|
24
|
+
* dispatcher for a projected one; the session's surface for the editor.
|
|
25
|
+
*
|
|
26
|
+
* @module
|
|
7
27
|
*/
|
|
8
28
|
import { vfsOutcome_convertToResult } from '@fnndsc/fond';
|
|
9
29
|
import { writeFileSync, unlinkSync, existsSync } from 'fs';
|
|
10
30
|
import { tmpdir } from 'os';
|
|
11
31
|
import { join, extname, posix } from 'path';
|
|
12
32
|
import chalk from 'chalk';
|
|
13
|
-
import { path_resolve, error_stripDebugPrefix } from '../utils.js';
|
|
33
|
+
import { path_resolve, storePath_resolve, error_stripDebugPrefix } from '../utils.js';
|
|
14
34
|
import { surface_get, capability_require, CapabilityError } from '../../core/surface.js';
|
|
35
|
+
import { command_declare } from '../../core/commandDeclaration.js';
|
|
36
|
+
import { declaredCommand_run } from '../../core/commandParse.js';
|
|
15
37
|
import { files_cat } from '@fnndsc/chili/commands/fs/cat.js';
|
|
16
38
|
import { file_replaceContent } from '@fnndsc/chili/commands/fs/edit.js';
|
|
17
39
|
import { listCache_get } from '@fnndsc/cumin';
|
|
@@ -20,18 +42,52 @@ import { errorStack } from '@fnndsc/fond';
|
|
|
20
42
|
import { exitCode_set } from '../../core/handlerRun.js';
|
|
21
43
|
/** What `edit` says when the surface opened an editor that stays open. */
|
|
22
44
|
export const EDIT_OPENED_LINE = '(opened in the editor)';
|
|
45
|
+
/** What an `edit` line may hold: one ChRIS file (a wildcard may name it, when it matches one). */
|
|
46
|
+
const EDIT_GRAMMAR = {
|
|
47
|
+
operands: [
|
|
48
|
+
{ name: 'file', kind: 'cfsPath', glob: true, summary: 'The ChRIS file to edit' },
|
|
49
|
+
],
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* `edit <file>`: the declaration.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* commands_register({ declarations: [editCommand] }, 'backend');
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export const editCommand = command_declare({
|
|
60
|
+
name: 'edit',
|
|
61
|
+
grammar: EDIT_GRAMMAR,
|
|
62
|
+
help: {
|
|
63
|
+
summary: 'Edit a ChRIS file in $EDITOR',
|
|
64
|
+
description: 'Edit a ChRIS file in $EDITOR: fetches it, opens it, and saves it back on write. Uses $EDITOR (or $VISUAL, or vi as fallback). Does nothing if the file is unchanged on exit. On save it deletes the original and re-uploads: the file path is preserved, its ID changes. On upload failure the edited content is preserved in /tmp.',
|
|
65
|
+
category: 'Files',
|
|
66
|
+
examples: [
|
|
67
|
+
'edit /home/chris/uploads/config.yaml',
|
|
68
|
+
'edit notes.txt',
|
|
69
|
+
'EDITOR=nano edit report.json',
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
handler: async (args) => edit_run(args.operands.file),
|
|
73
|
+
});
|
|
74
|
+
/**
|
|
75
|
+
* `edit` over words already split: the declaration's parse and handler.
|
|
76
|
+
*
|
|
77
|
+
* @param args - The words after `edit`.
|
|
78
|
+
* @returns The edit outcome, or the refusal of a bad line.
|
|
79
|
+
*/
|
|
80
|
+
export async function builtin_edit(args) {
|
|
81
|
+
return declaredCommand_run(editCommand, args);
|
|
82
|
+
}
|
|
23
83
|
/**
|
|
24
84
|
* Opens a ChRIS file in the surface's local editor. On save, replaces the
|
|
25
85
|
* original via delete + re-upload. No-ops if content is unchanged.
|
|
26
86
|
*
|
|
27
|
-
* @param
|
|
87
|
+
* @param named - The file as the operator typed it.
|
|
28
88
|
* @returns An envelope carrying the edit outcome.
|
|
29
89
|
*/
|
|
30
|
-
|
|
31
|
-
if (args.length === 0) {
|
|
32
|
-
exitCode_set(1);
|
|
33
|
-
return envelope_error('', undefined, `${chalk.red('Usage: edit <file>')}\n`);
|
|
34
|
-
}
|
|
90
|
+
async function edit_run(named) {
|
|
35
91
|
// Editing needs a surface that can open a local editor. A surface without
|
|
36
92
|
// the capability (a headless or browser host) fails here with a clear
|
|
37
93
|
// message instead of assuming a terminal exists.
|
|
@@ -43,17 +99,19 @@ export async function builtin_edit(args) {
|
|
|
43
99
|
exitCode_set(1);
|
|
44
100
|
return envelope_error('', undefined, `${chalk.red(message)}\n`);
|
|
45
101
|
}
|
|
46
|
-
|
|
102
|
+
// Read and written where the store keeps it: a path through a link (a
|
|
103
|
+
// run's output under /proc/jobs, a `.chrislink`) edits what it points at.
|
|
104
|
+
const target = await storePath_resolve(named);
|
|
47
105
|
const ext = extname(target).toLowerCase();
|
|
48
106
|
if (!path_isEditable(target)) {
|
|
49
107
|
exitCode_set(1);
|
|
50
|
-
return envelope_error('', undefined, `${chalk.red(`edit: ${
|
|
108
|
+
return envelope_error('', undefined, `${chalk.red(`edit: ${named}: binary file (${ext}), cannot edit as text`)}\n`);
|
|
51
109
|
}
|
|
52
110
|
// A projection's file (a feed's note under /proc) is read and written
|
|
53
111
|
// through the projection that owns it, never through CUBE's store.
|
|
54
112
|
const { vfsDispatcher } = await import('@fnndsc/salsa');
|
|
55
113
|
if (vfsDispatcher.path_isVirtual(target)) {
|
|
56
|
-
return projectedFile_edit(
|
|
114
|
+
return projectedFile_edit(named, target, ext, {
|
|
57
115
|
read: async (at) => vfsOutcome_convertToResult(await vfsDispatcher.read(at), 'read', at),
|
|
58
116
|
write: async (at, content) => vfsOutcome_convertToResult(await vfsDispatcher.write(at, content), 'write', at).ok,
|
|
59
117
|
});
|
|
@@ -88,9 +146,12 @@ export async function builtin_edit(args) {
|
|
|
88
146
|
try {
|
|
89
147
|
writeFileSync(tmpPath, edit.content, 'utf8');
|
|
90
148
|
const result = await file_replaceContent(target, tmpPath);
|
|
149
|
+
// The folder's listing is stale by both its names: where the store
|
|
150
|
+
// keeps it, and the path the file was reached by.
|
|
91
151
|
listCache_get().cache_invalidate(posix.dirname(target));
|
|
152
|
+
listCache_get().cache_invalidate(posix.dirname(await path_resolve(named)));
|
|
92
153
|
if (result.success) {
|
|
93
|
-
return envelope_ok(`${chalk.green(`Saved: ${
|
|
154
|
+
return envelope_ok(`${chalk.green(`Saved: ${named}`)}\n`);
|
|
94
155
|
}
|
|
95
156
|
const apiErr = errorStack.stack_pop();
|
|
96
157
|
let renderedErr = `${chalk.red(`edit: Save failed — ${result.error}`)}\n`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/builtins/fs/edit.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"edit.js","sourceRoot":"","sources":["../../../src/builtins/fs/edit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAwB,MAAM,uBAAuB,CAAC;AAC/G,OAAO,EAAE,eAAe,EAA8C,MAAM,kCAAkC,CAAC;AAC/G,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAc,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAwB,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAClG,OAAO,EAAE,UAAU,EAAwB,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,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CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACzE,IAAI,CAAC,IAAI,CAAC,OAAO;QAAE,OAAO,WAAW,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACzE,IAAI,MAAM,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC;QAAE,OAAO,WAAW,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC;IAC5G,MAAM,GAAG,GAA6B,UAAU,CAAC,SAAS,EAAE,CAAC;IAC7D,YAAY,CAAC,CAAC,CAAC,CAAC;IAChB,OAAO,cAAc,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,sBAAsB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,kBAAkB,EAAE,CAAC,IAAI,CAAC,CAAC;AAC5I,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExpressionDeclaration } from '../../core/commandDeclaration.js';
|
|
1
2
|
import { type CommandEnvelope } from '@fnndsc/menu';
|
|
2
3
|
/** One entry the walk visits. */
|
|
3
4
|
export interface FindNode {
|
|
@@ -80,3 +81,27 @@ export declare function find_evaluate(expr: FindExpr, node: FindNode, out: strin
|
|
|
80
81
|
* @returns The selected paths, and why any part of the walk failed.
|
|
81
82
|
*/
|
|
82
83
|
export declare function builtin_find(args: string[]): Promise<CommandEnvelope>;
|
|
84
|
+
/**
|
|
85
|
+
* Completes one word of a `find` line: a path among the starting points, a
|
|
86
|
+
* test or operator once the expression has begun (or when a dash is typed),
|
|
87
|
+
* and `-type`'s and `-status`'s words.
|
|
88
|
+
*
|
|
89
|
+
* @param words - The words before the one completed.
|
|
90
|
+
* @param word - The word typed so far.
|
|
91
|
+
* @returns The candidates.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* await find_complete(['.', '-type'], ''); // ['f', 'd', 'l']
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function find_complete(words: readonly string[], word: string): Promise<string[]>;
|
|
99
|
+
/**
|
|
100
|
+
* `find [path...] [expression]`: the declaration, an expression grammar.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* commands_register({ declarations: [findCommand] });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare const findCommand: ExpressionDeclaration;
|