@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/store.d.ts
CHANGED
|
@@ -1,8 +1,90 @@
|
|
|
1
1
|
import { type CommandEnvelope } from '@fnndsc/menu';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* `store <list | search <query> | install <plugin> | inspect | set <url> | reset>`: the declaration.
|
|
4
4
|
*
|
|
5
|
-
* @
|
|
6
|
-
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* commands_register({ declarations: [storeCommand] }, 'backend');
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare const storeCommand: import("../core/commandDeclaration.js").CommandDeclaration<{
|
|
11
|
+
readonly options: {
|
|
12
|
+
readonly store: {
|
|
13
|
+
readonly long: "store";
|
|
14
|
+
readonly summary: "Ask this peer store instead of the one set (store inspect names it)";
|
|
15
|
+
readonly value: {
|
|
16
|
+
readonly name: "url";
|
|
17
|
+
readonly kind: "word";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
readonly subcommands: {
|
|
22
|
+
readonly list: {
|
|
23
|
+
readonly summary: "Browse every plugin in the peer store";
|
|
24
|
+
readonly options: {
|
|
25
|
+
readonly long: {
|
|
26
|
+
readonly short: "l";
|
|
27
|
+
readonly summary: "One plugin per line, with its details";
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
readonly search: {
|
|
32
|
+
readonly summary: "Search the peer store's plugins by name";
|
|
33
|
+
readonly operands: readonly [{
|
|
34
|
+
readonly name: "query";
|
|
35
|
+
readonly kind: "word";
|
|
36
|
+
readonly summary: "Part of a plugin name";
|
|
37
|
+
}];
|
|
38
|
+
readonly options: {
|
|
39
|
+
readonly long: {
|
|
40
|
+
readonly short: "l";
|
|
41
|
+
readonly summary: "One plugin per line, with its details";
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
readonly install: {
|
|
46
|
+
readonly summary: "Install a plugin from the peer store into this CUBE (an administrator: sudo store install …)";
|
|
47
|
+
readonly operands: readonly [{
|
|
48
|
+
readonly name: "plugin";
|
|
49
|
+
readonly kind: "word";
|
|
50
|
+
readonly summary: "The plugin: its name, name-vVersion, or its image";
|
|
51
|
+
}];
|
|
52
|
+
readonly options: {
|
|
53
|
+
readonly compute: {
|
|
54
|
+
readonly long: "compute";
|
|
55
|
+
readonly summary: "The compute resources it runs on, comma-separated";
|
|
56
|
+
readonly value: {
|
|
57
|
+
readonly name: "names";
|
|
58
|
+
readonly kind: "compute";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
readonly inspect: {
|
|
64
|
+
readonly summary: "Name the peer store, and whether it is the default";
|
|
65
|
+
};
|
|
66
|
+
readonly set: {
|
|
67
|
+
readonly summary: "Set the peer store (kept in ~/.config/chell/settings.json)";
|
|
68
|
+
readonly operands: readonly [{
|
|
69
|
+
readonly name: "url";
|
|
70
|
+
readonly kind: "word";
|
|
71
|
+
readonly summary: "The store's API URL";
|
|
72
|
+
}];
|
|
73
|
+
};
|
|
74
|
+
readonly reset: {
|
|
75
|
+
readonly summary: `Set the peer store back to the default (${string})`;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* `store` over words already split: the declaration's parse and handler.
|
|
81
|
+
*
|
|
82
|
+
* @param args - The words after `store`.
|
|
83
|
+
* @returns The answer, or the refusal of a bad line.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* await builtin_store(['search', 'dicom']);
|
|
88
|
+
* ```
|
|
7
89
|
*/
|
|
8
90
|
export declare function builtin_store(args: string[]): Promise<CommandEnvelope>;
|
package/dist/builtins/store.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
2
|
+
* @file `store`: the peer store, another ChRIS whose plugins this CUBE can
|
|
3
|
+
* install. Browse and search it, install a plugin from it, and say, set or
|
|
4
|
+
* reset which store it is.
|
|
5
|
+
*
|
|
6
|
+
* Declared in one record (`storeCommand`): the subcommands, their operands
|
|
7
|
+
* and options.
|
|
8
|
+
*
|
|
9
|
+
* Key components:
|
|
10
|
+
* - storeCommand: the declaration.
|
|
11
|
+
* - builtin_store: the declaration run over words already split.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
4
14
|
*/
|
|
5
15
|
import chalk from 'chalk';
|
|
6
|
-
import { commandArgs_process } from './utils.js';
|
|
7
16
|
import { store_listPlugins, store_searchPlugins } from '@fnndsc/chili/commands/store/list.js';
|
|
8
17
|
import { grid_render, long_render } from '@fnndsc/chili/views/ls.js';
|
|
9
18
|
import { spinner } from '../lib/spinner.js';
|
|
@@ -12,6 +21,8 @@ import { envelope_ok, envelope_error } from '@fnndsc/menu';
|
|
|
12
21
|
import { DEFAULT_STORE_URL, storeUrl_get, storeUrl_isDefault, storeUrl_set, storeUrl_clear, storeConfig_persist, } from '../config/storeConfig.js';
|
|
13
22
|
import { errorStack } from '@fnndsc/fond';
|
|
14
23
|
import { exitCode_set } from '../core/handlerRun.js';
|
|
24
|
+
import { command_declare } from '../core/commandDeclaration.js';
|
|
25
|
+
import { declaredCommand_run } from '../core/commandParse.js';
|
|
15
26
|
/**
|
|
16
27
|
* Renders a store fetch failure as an error envelope, draining the reason the
|
|
17
28
|
* fetch pushed onto the error stack.
|
|
@@ -26,83 +37,96 @@ function storeFailure_envelope(fallback) {
|
|
|
26
37
|
return envelope_error('', undefined, `${chalk.red(detail)}\n`);
|
|
27
38
|
}
|
|
28
39
|
/**
|
|
29
|
-
*
|
|
40
|
+
* The store's plugins as a listing draws them: a grid, or one per line with `-l`.
|
|
30
41
|
*
|
|
31
|
-
* @param
|
|
32
|
-
* @
|
|
42
|
+
* @param items - The plugins.
|
|
43
|
+
* @param long - Whether to draw one per line.
|
|
44
|
+
* @returns The listing.
|
|
33
45
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
function storeItems_render(items, long) {
|
|
47
|
+
return long ? `${long_render(items, { human: false })}\n` : `${grid_render(items)}\n`;
|
|
48
|
+
}
|
|
49
|
+
/** What a `store` line may hold. */
|
|
50
|
+
const STORE_GRAMMAR = {
|
|
51
|
+
options: {
|
|
52
|
+
store: { long: 'store', summary: 'Ask this peer store instead of the one set (store inspect names it)', value: { name: 'url', kind: 'word' } },
|
|
53
|
+
},
|
|
54
|
+
subcommands: {
|
|
55
|
+
list: { summary: "Browse every plugin in the peer store", options: { long: { short: 'l', summary: 'One plugin per line, with its details' } } },
|
|
56
|
+
search: {
|
|
57
|
+
summary: 'Search the peer store\'s plugins by name',
|
|
58
|
+
operands: [{ name: 'query', kind: 'word', summary: 'Part of a plugin name' }],
|
|
59
|
+
options: { long: { short: 'l', summary: 'One plugin per line, with its details' } },
|
|
60
|
+
},
|
|
61
|
+
install: {
|
|
62
|
+
summary: 'Install a plugin from the peer store into this CUBE (an administrator: sudo store install …)',
|
|
63
|
+
operands: [{ name: 'plugin', kind: 'word', summary: 'The plugin: its name, name-vVersion, or its image' }],
|
|
64
|
+
options: { compute: { long: 'compute', summary: 'The compute resources it runs on, comma-separated', value: { name: 'names', kind: 'compute' } } },
|
|
65
|
+
},
|
|
66
|
+
inspect: { summary: 'Name the peer store, and whether it is the default' },
|
|
67
|
+
set: { summary: 'Set the peer store (kept in ~/.config/chell/settings.json)', operands: [{ name: 'url', kind: 'word', summary: "The store's API URL" }] },
|
|
68
|
+
reset: { summary: `Set the peer store back to the default (${DEFAULT_STORE_URL})` },
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Runs one `store` line.
|
|
73
|
+
*
|
|
74
|
+
* @param args - The line, parsed.
|
|
75
|
+
* @returns The answer, or the error.
|
|
76
|
+
*/
|
|
77
|
+
async function store_run(args) {
|
|
78
|
+
const storeOptions = { store: args.options.store };
|
|
43
79
|
try {
|
|
44
80
|
spinner.start('Fetching from store...');
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
81
|
+
switch (args.subcommand) {
|
|
82
|
+
case 'list': {
|
|
83
|
+
const listResult = await store_listPlugins(storeOptions);
|
|
84
|
+
spinner.stop();
|
|
85
|
+
if (!listResult.ok)
|
|
86
|
+
return storeFailure_envelope('store list failed');
|
|
87
|
+
if (listResult.value.length === 0)
|
|
88
|
+
return envelope_ok('No plugins found in store.\n');
|
|
89
|
+
return envelope_ok(storeItems_render(listResult.value, args.options.long));
|
|
50
90
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
91
|
+
case 'search': {
|
|
92
|
+
const query = args.operands.query;
|
|
93
|
+
const searchResult = await store_searchPlugins(query, storeOptions);
|
|
94
|
+
spinner.stop();
|
|
95
|
+
if (!searchResult.ok)
|
|
96
|
+
return storeFailure_envelope(`store search failed for '${query}'`);
|
|
97
|
+
if (searchResult.value.length === 0)
|
|
98
|
+
return envelope_ok(`No plugins found matching '${query}'.\n`);
|
|
99
|
+
return envelope_ok(storeItems_render(searchResult.value, args.options.long));
|
|
54
100
|
}
|
|
55
|
-
|
|
56
|
-
return envelope_ok(parsed.l ? `${long_render(items, { human: !!parsed.h })}\n` : `${grid_render(items)}\n`);
|
|
57
|
-
}
|
|
58
|
-
else if (subcommand === 'search') {
|
|
59
|
-
const query = parsed._[1];
|
|
60
|
-
if (!query) {
|
|
101
|
+
case 'install': {
|
|
61
102
|
spinner.stop();
|
|
62
|
-
|
|
103
|
+
// The add is the plugin verb's, which reads its words as parsed.
|
|
104
|
+
const install = {
|
|
105
|
+
_: ['install', args.operands.plugin],
|
|
106
|
+
...(args.options.compute !== undefined ? { compute: args.options.compute } : {}),
|
|
107
|
+
...(args.options.store !== undefined ? { store: args.options.store } : {}),
|
|
108
|
+
};
|
|
109
|
+
return await plugin_addInteractive(install);
|
|
63
110
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
111
|
+
case 'inspect': {
|
|
112
|
+
spinner.stop();
|
|
113
|
+
const current = storeUrl_get();
|
|
114
|
+
const isDefault = storeUrl_isDefault();
|
|
115
|
+
return envelope_ok(`${chalk.bold('Peer store URL:')} ${chalk.blue(current)}${isDefault ? chalk.gray(' (default)') : chalk.yellow(' (custom)')}\n`);
|
|
68
116
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
117
|
+
case 'set': {
|
|
118
|
+
spinner.stop();
|
|
119
|
+
storeUrl_set(args.operands.url);
|
|
120
|
+
await storeConfig_persist();
|
|
121
|
+
return envelope_ok(`${chalk.green(`Store URL set to: ${chalk.blue(args.operands.url)}`)}\n`);
|
|
72
122
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return await plugin_addInteractive(installParsed);
|
|
79
|
-
}
|
|
80
|
-
else if (subcommand === 'inspect') {
|
|
81
|
-
spinner.stop();
|
|
82
|
-
const current = storeUrl_get();
|
|
83
|
-
const isDefault = storeUrl_isDefault();
|
|
84
|
-
return envelope_ok(`${chalk.bold('Peer store URL:')} ${chalk.blue(current)}${isDefault ? chalk.gray(' (default)') : chalk.yellow(' (custom)')}\n`);
|
|
85
|
-
}
|
|
86
|
-
else if (subcommand === 'set') {
|
|
87
|
-
spinner.stop();
|
|
88
|
-
const url = parsed._[1];
|
|
89
|
-
if (!url) {
|
|
90
|
-
exitCode_set(1);
|
|
91
|
-
return envelope_error('', undefined, `${chalk.red('Usage: store set <url>')}\n`);
|
|
123
|
+
case 'reset': {
|
|
124
|
+
spinner.stop();
|
|
125
|
+
storeUrl_clear();
|
|
126
|
+
await storeConfig_persist();
|
|
127
|
+
return envelope_ok(`${chalk.green(`Store URL reset to default: ${chalk.blue(DEFAULT_STORE_URL)}`)}\n`);
|
|
92
128
|
}
|
|
93
|
-
storeUrl_set(url);
|
|
94
|
-
await storeConfig_persist();
|
|
95
|
-
return envelope_ok(`${chalk.green(`Store URL set to: ${chalk.blue(url)}`)}\n`);
|
|
96
|
-
}
|
|
97
|
-
else if (subcommand === 'reset') {
|
|
98
|
-
spinner.stop();
|
|
99
|
-
storeUrl_clear();
|
|
100
|
-
await storeConfig_persist();
|
|
101
|
-
return envelope_ok(`${chalk.green(`Store URL reset to default: ${chalk.blue(DEFAULT_STORE_URL)}`)}\n`);
|
|
102
129
|
}
|
|
103
|
-
spinner.stop();
|
|
104
|
-
exitCode_set(1);
|
|
105
|
-
return envelope_error('', undefined, `${chalk.red(`Unknown subcommand: ${subcommand}. Usage: store <list|search|install|inspect|set|reset>`)}\n`);
|
|
106
130
|
}
|
|
107
131
|
catch (e) {
|
|
108
132
|
spinner.stop();
|
|
@@ -111,4 +135,47 @@ export async function builtin_store(args) {
|
|
|
111
135
|
return envelope_error('', undefined, `${chalk.red(`Store error: ${msg}`)}\n`);
|
|
112
136
|
}
|
|
113
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* `store <list | search <query> | install <plugin> | inspect | set <url> | reset>`: the declaration.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* commands_register({ declarations: [storeCommand] }, 'backend');
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export const storeCommand = command_declare({
|
|
147
|
+
name: 'store',
|
|
148
|
+
grammar: STORE_GRAMMAR,
|
|
149
|
+
help: {
|
|
150
|
+
summary: 'The peer store: browse and search its plugins, install one, say or set which store it is',
|
|
151
|
+
description: "The peer store is another ChRIS, by default cube.chrisproject.org, whose plugins this CUBE can install; it is not a resource of this CUBE, so the resource listing options do not apply. list and search browse it; install registers one of its plugins here, on the compute resources --compute names, and needs an administrator (sudo store install …); inspect names the store, set and reset change it.",
|
|
152
|
+
category: 'Resources',
|
|
153
|
+
examples: [
|
|
154
|
+
'store list',
|
|
155
|
+
'store search dicom',
|
|
156
|
+
'store install pl-dcm2niix',
|
|
157
|
+
'store install pl-dcm2niix-v1.2.3',
|
|
158
|
+
'store install fnndsc/pl-dcm2niix:1.2.3',
|
|
159
|
+
'store install pl-dcm2niix --compute moc',
|
|
160
|
+
'store inspect',
|
|
161
|
+
'store set https://my-cube.org/api/v1/',
|
|
162
|
+
'store reset',
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
handler: store_run,
|
|
166
|
+
});
|
|
167
|
+
/**
|
|
168
|
+
* `store` over words already split: the declaration's parse and handler.
|
|
169
|
+
*
|
|
170
|
+
* @param args - The words after `store`.
|
|
171
|
+
* @returns The answer, or the refusal of a bad line.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* await builtin_store(['search', 'dicom']);
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
export async function builtin_store(args) {
|
|
179
|
+
return declaredCommand_run(storeCommand, args);
|
|
180
|
+
}
|
|
114
181
|
//# sourceMappingURL=store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/builtins/store.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/builtins/store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAA0C,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnG,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAe,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,eAAe,EAA8C,MAAM,+BAA+B,CAAC;AAC5G,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D;;;;;;GAMG;AACH,SAAS,qBAAqB,CAAC,QAAgB;IAC7C,MAAM,SAAS,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;IACzC,MAAM,MAAM,GAAW,SAAS,CAAC,CAAC,CAAC,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,EAAE,CAAC,IAAI,CAAC,CAAC;IAChF,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;IAC1C,IAAI,EAAE,OAAO;IACb,OAAO,EAAE,aAAa;IACtB,IAAI,EAAE;QACJ,OAAO,EAAE,0FAA0F;QACnG,WAAW,EAAE,+YAA+Y;QAC5Z,QAAQ,EAAE,WAAW;QACrB,QAAQ,EAAE;YACR,YAAY;YACZ,oBAAoB;YACpB,2BAA2B;YAC3B,kCAAkC;YAClC,wCAAwC;YACxC,yCAAyC;YACzC,eAAe;YACf,uCAAuC;YACvC,aAAa;SACd;KACF;IACD,OAAO,EAAE,SAAS;CACnB,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,IAAc;IAChD,OAAO,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -2,21 +2,96 @@
|
|
|
2
2
|
* @file apropos and man: find a command by a word, and read its page, in the
|
|
3
3
|
* words every Unix hand already knows (builtins/helpSections.ts).
|
|
4
4
|
*
|
|
5
|
+
* Declared in one record each (`aproposCommand`, `manCommand`): grammar,
|
|
6
|
+
* help and handler.
|
|
7
|
+
*
|
|
8
|
+
* Key components:
|
|
9
|
+
* - aproposCommand, manCommand: the declarations.
|
|
10
|
+
* - builtin_apropos, builtin_man: the declarations run over words already split.
|
|
11
|
+
* - apropos_run: the typed core of both.
|
|
12
|
+
*
|
|
13
|
+
* Typical usage:
|
|
14
|
+
* ```ts
|
|
15
|
+
* await builtin_apropos(['dicom']);
|
|
16
|
+
* await builtin_man(['-k', 'pull']);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
5
19
|
* @module
|
|
6
20
|
*/
|
|
7
21
|
import { CommandEnvelope } from '@fnndsc/menu';
|
|
8
22
|
/**
|
|
9
|
-
* `apropos <word
|
|
10
|
-
*
|
|
23
|
+
* `apropos <word…>`: the declaration.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* commands_register({ declarations: [aproposCommand] });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare const aproposCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
|
|
31
|
+
readonly operands: readonly [{
|
|
32
|
+
readonly name: "word";
|
|
33
|
+
readonly kind: "word";
|
|
34
|
+
readonly repeat: true;
|
|
35
|
+
readonly summary: "The word to look for; several words are one phrase";
|
|
36
|
+
}];
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* `man <topic…> | man -k <word…>`: the declaration.
|
|
11
40
|
*
|
|
12
|
-
* @
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* commands_register({ declarations: [manCommand] });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare const manCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
|
|
47
|
+
readonly operands: readonly [{
|
|
48
|
+
readonly name: "topic";
|
|
49
|
+
readonly kind: "word";
|
|
50
|
+
readonly optional: true;
|
|
51
|
+
readonly repeat: true;
|
|
52
|
+
readonly summary: "A command, a section or a Shell topic; with -k, the word to look for";
|
|
53
|
+
}];
|
|
54
|
+
readonly options: {
|
|
55
|
+
readonly keyword: {
|
|
56
|
+
readonly short: "k";
|
|
57
|
+
readonly summary: "Look for the word, as apropos does";
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}>;
|
|
61
|
+
/**
|
|
62
|
+
* Every command, section and Shell topic whose name, summary or description
|
|
63
|
+
* holds the words, as one phrase.
|
|
64
|
+
*
|
|
65
|
+
* @param words - The words to look for.
|
|
13
66
|
* @returns The matches, or nothing appropriate (exit 1, as apropos does).
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* await apropos_run(['dicom']);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function apropos_run(words: readonly string[]): Promise<CommandEnvelope>;
|
|
74
|
+
/**
|
|
75
|
+
* `apropos` over words already split: the declaration's parse and handler.
|
|
76
|
+
*
|
|
77
|
+
* @param args - The words after `apropos`.
|
|
78
|
+
* @returns The matches, or the refusal of a bad line.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* await builtin_apropos(['dicom']);
|
|
83
|
+
* ```
|
|
14
84
|
*/
|
|
15
85
|
export declare function builtin_apropos(args: string[]): Promise<CommandEnvelope>;
|
|
16
86
|
/**
|
|
17
|
-
* `man
|
|
87
|
+
* `man` over words already split: the declaration's parse and handler.
|
|
18
88
|
*
|
|
19
89
|
* @param args - The words after `man`.
|
|
20
|
-
* @returns The page, or the
|
|
90
|
+
* @returns The page, the matches, or the refusal of a bad line.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* await builtin_man(['ls']);
|
|
95
|
+
* ```
|
|
21
96
|
*/
|
|
22
97
|
export declare function builtin_man(args: string[]): Promise<CommandEnvelope>;
|
|
@@ -2,23 +2,99 @@
|
|
|
2
2
|
* @file apropos and man: find a command by a word, and read its page, in the
|
|
3
3
|
* words every Unix hand already knows (builtins/helpSections.ts).
|
|
4
4
|
*
|
|
5
|
+
* Declared in one record each (`aproposCommand`, `manCommand`): grammar,
|
|
6
|
+
* help and handler.
|
|
7
|
+
*
|
|
8
|
+
* Key components:
|
|
9
|
+
* - aproposCommand, manCommand: the declarations.
|
|
10
|
+
* - builtin_apropos, builtin_man: the declarations run over words already split.
|
|
11
|
+
* - apropos_run: the typed core of both.
|
|
12
|
+
*
|
|
13
|
+
* Typical usage:
|
|
14
|
+
* ```ts
|
|
15
|
+
* await builtin_apropos(['dicom']);
|
|
16
|
+
* await builtin_man(['-k', 'pull']);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
5
19
|
* @module
|
|
6
20
|
*/
|
|
7
21
|
import { envelope_ok, envelope_error } from '@fnndsc/menu';
|
|
8
22
|
import { apropos_search } from '../helpSections.js';
|
|
9
|
-
import {
|
|
23
|
+
import { help_answer, helpLookup_make } from '../help.js';
|
|
10
24
|
import { exitCode_set } from '../../core/handlerRun.js';
|
|
25
|
+
import { command_declare } from '../../core/commandDeclaration.js';
|
|
26
|
+
import { declaredCommand_run } from '../../core/commandParse.js';
|
|
27
|
+
/** What an `apropos` line may hold. */
|
|
28
|
+
const APROPOS_GRAMMAR = {
|
|
29
|
+
operands: [
|
|
30
|
+
{ name: 'word', kind: 'word', repeat: true, summary: 'The word to look for; several words are one phrase' },
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
/** What a `man` line may hold. */
|
|
34
|
+
const MAN_GRAMMAR = {
|
|
35
|
+
operands: [
|
|
36
|
+
{ name: 'topic', kind: 'word', optional: true, repeat: true, summary: 'A command, a section or a Shell topic; with -k, the word to look for' },
|
|
37
|
+
],
|
|
38
|
+
options: {
|
|
39
|
+
keyword: { short: 'k', summary: 'Look for the word, as apropos does' },
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* `apropos <word…>`: the declaration.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* commands_register({ declarations: [aproposCommand] });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export const aproposCommand = command_declare({
|
|
51
|
+
name: 'apropos',
|
|
52
|
+
grammar: APROPOS_GRAMMAR,
|
|
53
|
+
help: {
|
|
54
|
+
summary: 'Find commands by a word in their name, summary or description',
|
|
55
|
+
description: 'Search every command, section and Shell topic for a word, in any case. Nothing found is exit 1, as apropos is. man -k <word> is the same.',
|
|
56
|
+
category: 'General',
|
|
57
|
+
posix: { group: 'Shell', differs: 'as apropos: searches every command\'s line and description' },
|
|
58
|
+
examples: ['apropos dicom', 'apropos link', 'man -k pull'],
|
|
59
|
+
},
|
|
60
|
+
holds: [],
|
|
61
|
+
handler: async (args) => apropos_run(args.operands.word),
|
|
62
|
+
});
|
|
11
63
|
/**
|
|
12
|
-
* `
|
|
13
|
-
* summary or description holds the word.
|
|
64
|
+
* `man <topic…> | man -k <word…>`: the declaration.
|
|
14
65
|
*
|
|
15
|
-
* @
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* commands_register({ declarations: [manCommand] });
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export const manCommand = command_declare({
|
|
72
|
+
name: 'man',
|
|
73
|
+
grammar: MAN_GRAMMAR,
|
|
74
|
+
help: {
|
|
75
|
+
summary: 'The page for a command, a section or a Shell topic (help, by its Unix name)',
|
|
76
|
+
description: 'man <name> is help <name>; man -k <word> is apropos <word>',
|
|
77
|
+
category: 'General',
|
|
78
|
+
posix: { group: 'Shell', differs: 'man <name> is help <name>; man -k is apropos' },
|
|
79
|
+
examples: ['man grep', 'man PACS', 'man -k dicom'],
|
|
80
|
+
},
|
|
81
|
+
holds: [],
|
|
82
|
+
handler: async (args) => man_run(args.operands.topic, args.options.keyword),
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Every command, section and Shell topic whose name, summary or description
|
|
86
|
+
* holds the words, as one phrase.
|
|
87
|
+
*
|
|
88
|
+
* @param words - The words to look for.
|
|
16
89
|
* @returns The matches, or nothing appropriate (exit 1, as apropos does).
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* await apropos_run(['dicom']);
|
|
94
|
+
* ```
|
|
17
95
|
*/
|
|
18
|
-
export async function
|
|
19
|
-
const word =
|
|
20
|
-
if (word === '')
|
|
21
|
-
return envelope_error('', undefined, 'apropos: a word to look for: apropos <word>\n');
|
|
96
|
+
export async function apropos_run(words) {
|
|
97
|
+
const word = words.join(' ').trim();
|
|
22
98
|
const hits = apropos_search(word, helpLookup_make());
|
|
23
99
|
if (hits.length === 0) {
|
|
24
100
|
exitCode_set(1);
|
|
@@ -27,16 +103,46 @@ export async function builtin_apropos(args) {
|
|
|
27
103
|
return envelope_ok(`${hits.join('\n')}\n`);
|
|
28
104
|
}
|
|
29
105
|
/**
|
|
30
|
-
* `man <
|
|
106
|
+
* `man <topic>` is `help` for it; `man -k <word>` is apropos.
|
|
107
|
+
*
|
|
108
|
+
* @param topic - The words after the options.
|
|
109
|
+
* @param keyword - Whether -k asked for apropos.
|
|
110
|
+
* @returns The page, the matches, or a refusal for nothing asked.
|
|
111
|
+
*/
|
|
112
|
+
async function man_run(topic, keyword) {
|
|
113
|
+
if (topic.length === 0) {
|
|
114
|
+
return envelope_error('', undefined, keyword
|
|
115
|
+
? 'apropos: a word to look for: apropos <word>\n'
|
|
116
|
+
: 'man: what manual page do you want? man <command>, man <Section>, man -k <word>\n');
|
|
117
|
+
}
|
|
118
|
+
return keyword ? apropos_run(topic) : help_answer(topic);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* `apropos` over words already split: the declaration's parse and handler.
|
|
122
|
+
*
|
|
123
|
+
* @param args - The words after `apropos`.
|
|
124
|
+
* @returns The matches, or the refusal of a bad line.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* await builtin_apropos(['dicom']);
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export async function builtin_apropos(args) {
|
|
132
|
+
return declaredCommand_run(aproposCommand, args);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* `man` over words already split: the declaration's parse and handler.
|
|
31
136
|
*
|
|
32
137
|
* @param args - The words after `man`.
|
|
33
|
-
* @returns The page, or the
|
|
138
|
+
* @returns The page, the matches, or the refusal of a bad line.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* await builtin_man(['ls']);
|
|
143
|
+
* ```
|
|
34
144
|
*/
|
|
35
145
|
export async function builtin_man(args) {
|
|
36
|
-
|
|
37
|
-
return builtin_apropos(args.slice(1));
|
|
38
|
-
if (args.length === 0)
|
|
39
|
-
return envelope_error('', undefined, 'man: what manual page do you want? man <command>, man <Section>, man -k <word>\n');
|
|
40
|
-
return builtin_help(args);
|
|
146
|
+
return declaredCommand_run(manCommand, args);
|
|
41
147
|
}
|
|
42
148
|
//# sourceMappingURL=apropos.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apropos.js","sourceRoot":"","sources":["../../../src/builtins/sys/apropos.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"apropos.js","sourceRoot":"","sources":["../../../src/builtins/sys/apropos.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAmB,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAA8C,MAAM,kCAAkC,CAAC;AAC/G,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,uCAAuC;AACvC,MAAM,eAAe,GAAG;IACtB,QAAQ,EAAE;QACR,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,oDAAoD,EAAE;KAC5G;CACgC,CAAC;AAEpC,kCAAkC;AAClC,MAAM,WAAW,GAAG;IAClB,QAAQ,EAAE;QACR,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,sEAAsE,EAAE;KAC/I;IACD,OAAO,EAAE;QACP,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,oCAAoC,EAAE;K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