@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/acl.js
CHANGED
|
@@ -7,62 +7,148 @@
|
|
|
7
7
|
* a group's grant, and `chmod o±r` is the other entry spelled as a mode.
|
|
8
8
|
* `share X with Y` is a sentence; it lands nowhere in a terminal.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
10
|
+
* Each is declared in one record: the feeds are path operands that glob,
|
|
11
|
+
* `setfacl`'s entry an option's value, `chmod`'s mode one of two words. The
|
|
12
|
+
* capability itself lives in the kernel (cumin `feed_share`,
|
|
11
13
|
* `feedShare_group`, `feedShare_revoke`, `feedAccess_read`,
|
|
12
14
|
* `feed_makePublic`, `feed_makePrivate`). This is its shell face.
|
|
13
15
|
*
|
|
16
|
+
* Key components:
|
|
17
|
+
* - setfaclCommand, getfaclCommand, chmodCommand: the declarations.
|
|
18
|
+
* - builtin_setfacl, builtin_getfacl, builtin_chmod: each declaration run over words already split.
|
|
19
|
+
*
|
|
20
|
+
* Typical usage:
|
|
21
|
+
* ```ts
|
|
22
|
+
* await builtin_setfacl(['-m', 'u:someone:r', 'feed_12']);
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Dependencies: cumin's sharing calls; the words of an entry and of a feed (`acl.args.ts`).
|
|
26
|
+
*
|
|
14
27
|
* @module
|
|
15
28
|
*/
|
|
16
29
|
import { feed_share, feedShare_group, feedShare_revoke, feedAccess_read, feed_makePublic, feed_makePrivate } from '@fnndsc/cumin';
|
|
17
|
-
import {
|
|
30
|
+
import { aclEntry_parse, aclRemoval_parse, aclTarget_resolve, acl_render, } from './acl.args.js';
|
|
18
31
|
import { errorStack } from '@fnndsc/fond';
|
|
19
32
|
import { envelope_ok, envelope_error } from '@fnndsc/menu';
|
|
33
|
+
import { command_declare } from '../../core/commandDeclaration.js';
|
|
34
|
+
import { declaredCommand_run } from '../../core/commandParse.js';
|
|
35
|
+
/** The feeds a line names, as each of these commands takes them. */
|
|
36
|
+
const FEEDS_OPERAND = {
|
|
37
|
+
name: 'path',
|
|
38
|
+
kind: 'cfsPath',
|
|
39
|
+
repeat: true,
|
|
40
|
+
glob: true,
|
|
41
|
+
summary: 'The feeds: an id, feed_N, any path through /feeds/, or /proc/jobs/feed_N',
|
|
42
|
+
};
|
|
43
|
+
/** What a `setfacl` line may hold. */
|
|
44
|
+
const SETFACL_GRAMMAR = {
|
|
45
|
+
operands: [FEEDS_OPERAND],
|
|
46
|
+
options: {
|
|
47
|
+
modify: { short: 'm', long: 'modify', summary: 'Add an entry: u:<user>:r, g:<group>:r, o::r (public) or o::- (private)', value: { name: 'entry', kind: 'word' } },
|
|
48
|
+
remove: { short: 'x', long: 'remove', summary: 'Withdraw a grant: u:<user> or g:<group>', value: { name: 'entry', kind: 'word' } },
|
|
49
|
+
},
|
|
50
|
+
};
|
|
20
51
|
/**
|
|
21
|
-
*
|
|
52
|
+
* The feeds some targets name, in order.
|
|
22
53
|
*
|
|
23
|
-
* @param
|
|
24
|
-
* @
|
|
54
|
+
* @param verb - The command, for its refusal.
|
|
55
|
+
* @param paths - The targets as the line gave them.
|
|
56
|
+
* @param distinct - Whether a feed named twice counts once.
|
|
57
|
+
* @returns The feed ids, or the refusal of the first target that names none.
|
|
25
58
|
*/
|
|
26
|
-
|
|
27
|
-
let parsed = setfaclArgs_parse(args);
|
|
28
|
-
// A path and no entry names WHAT to share and not WITH WHOM, which is a
|
|
29
|
-
// question rather than a usage error (an-absent-value-is-a-question). The
|
|
30
|
-
// grant CUBE offers is read on a feed, so the only thing missing is the
|
|
31
|
-
// identity: ask for it, and refuse as before when it is not answered.
|
|
32
|
-
if (parsed.error !== null && entryless_is(args)) {
|
|
33
|
-
const paths = args.filter((token) => !token.startsWith('-'));
|
|
34
|
-
const feedIDs = [];
|
|
35
|
-
for (const path of paths) {
|
|
36
|
-
const feedID = aclTarget_resolve(path);
|
|
37
|
-
if (feedID === null) {
|
|
38
|
-
return envelope_error(`setfacl: '${path}' does not name a feed\n`);
|
|
39
|
-
}
|
|
40
|
-
if (!feedIDs.includes(feedID))
|
|
41
|
-
feedIDs.push(feedID);
|
|
42
|
-
}
|
|
43
|
-
// One question for the whole set: a grant is per identity, and asking
|
|
44
|
-
// who once for twenty feeds is the same answer twenty times.
|
|
45
|
-
const who = (await who_ask(feedIDs)).trim();
|
|
46
|
-
if (who === '') {
|
|
47
|
-
const named = feedIDs.map((id) => `feed_${id}`).join(' ');
|
|
48
|
-
return envelope_error(`setfacl: nobody named; ${named} shared with no one new\n`);
|
|
49
|
-
}
|
|
50
|
-
parsed = setfaclArgs_parse(['-m', `u:${who}:r`, ...paths]);
|
|
51
|
-
}
|
|
52
|
-
if (parsed.error !== null)
|
|
53
|
-
return envelope_error(`${parsed.error}\n`);
|
|
59
|
+
function feedIDs_resolve(verb, paths, distinct) {
|
|
54
60
|
const feedIDs = [];
|
|
55
|
-
for (const path of
|
|
61
|
+
for (const path of paths) {
|
|
56
62
|
const feedID = aclTarget_resolve(path);
|
|
57
63
|
if (feedID === null)
|
|
58
|
-
return envelope_error(
|
|
59
|
-
feedIDs.
|
|
64
|
+
return envelope_error(`${verb}: '${path}' does not name a feed\n`);
|
|
65
|
+
if (!distinct || !feedIDs.includes(feedID))
|
|
66
|
+
feedIDs.push(feedID);
|
|
67
|
+
}
|
|
68
|
+
return feedIDs;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Adds or modifies an access control entry on feeds, or withdraws a grant;
|
|
72
|
+
* given feeds and no entry, asks whom to share them with.
|
|
73
|
+
*
|
|
74
|
+
* @param args - The line, parsed.
|
|
75
|
+
* @returns An envelope naming what was granted or withdrawn.
|
|
76
|
+
*/
|
|
77
|
+
async function setfacl_run(args) {
|
|
78
|
+
const { modify, remove } = args.options;
|
|
79
|
+
if (remove !== undefined) {
|
|
80
|
+
const removal = aclRemoval_parse(remove);
|
|
81
|
+
if (typeof removal === 'string')
|
|
82
|
+
return envelope_error(`${removal}\n`);
|
|
83
|
+
const feedIDs = feedIDs_resolve('setfacl', args.operands.path, false);
|
|
84
|
+
return Array.isArray(feedIDs) ? acl_remove(removal, feedIDs) : feedIDs;
|
|
85
|
+
}
|
|
86
|
+
if (modify !== undefined) {
|
|
87
|
+
const entry = aclEntry_parse(modify);
|
|
88
|
+
if (entry === null)
|
|
89
|
+
return envelope_error(`setfacl: '${modify}' is not an entry (want u:<user>:r, g:<group>:r, o::r or o::-)\n`);
|
|
90
|
+
const feedIDs = feedIDs_resolve('setfacl', args.operands.path, false);
|
|
91
|
+
return Array.isArray(feedIDs) ? acl_apply(entry, feedIDs, 'setfacl') : feedIDs;
|
|
60
92
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
93
|
+
// A path and no entry names WHAT to share and not WITH WHOM, which is a
|
|
94
|
+
// question rather than a usage error (an-absent-value-is-a-question). The
|
|
95
|
+
// grant CUBE offers is read on a feed, so the only thing missing is the
|
|
96
|
+
// identity: ask for it, and refuse when it is not answered.
|
|
97
|
+
const feedIDs = feedIDs_resolve('setfacl', args.operands.path, true);
|
|
98
|
+
if (!Array.isArray(feedIDs))
|
|
99
|
+
return feedIDs;
|
|
100
|
+
// One question for the whole set: a grant is per identity, and asking
|
|
101
|
+
// who once for twenty feeds is the same answer twenty times.
|
|
102
|
+
const who = (await who_ask(feedIDs)).trim();
|
|
103
|
+
if (who === '') {
|
|
104
|
+
const named = feedIDs.map((id) => `feed_${id}`).join(' ');
|
|
105
|
+
return envelope_error(`setfacl: nobody named; ${named} shared with no one new\n`);
|
|
106
|
+
}
|
|
107
|
+
return acl_apply({ kind: 'user', name: who, perms: 'r' }, feedIDs, 'setfacl');
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* `setfacl [-m <entry>] [-x <entry>] <path>…`: the declaration.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* commands_register({ declarations: [setfaclCommand] }, 'backend');
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export const setfaclCommand = command_declare({
|
|
118
|
+
name: 'setfacl',
|
|
119
|
+
grammar: SETFACL_GRAMMAR,
|
|
120
|
+
help: {
|
|
121
|
+
summary: 'Share a feed with a user, a group or everyone, or stop sharing it',
|
|
122
|
+
description: 'A feed\'s access list, as POSIX ACL entries. -m u:<user>:r shares it with a user, -m g:<group>:r '
|
|
123
|
+
+ 'with a group, -m o::r with everyone (a public feed) and -m o::- makes it private again. '
|
|
124
|
+
+ '-x u:<user> or -x g:<group> withdraws that grant. A feed is named by id, by the feed_N a '
|
|
125
|
+
+ 'listing shows, by any path through /feeds/, or by /proc/jobs/feed_N. Given a feed and no '
|
|
126
|
+
+ 'entry, it asks which user to share it with.',
|
|
127
|
+
category: 'Sharing',
|
|
128
|
+
posix: { group: 'Files', differs: 'ChRIS sharing, as ACL entries' },
|
|
129
|
+
examples: [
|
|
130
|
+
'setfacl -m u:someone:r /home/me/feeds/feed_12',
|
|
131
|
+
'setfacl -m g:grantlab:r feed_12 feed_13',
|
|
132
|
+
'setfacl -m o::r feed_12 # public',
|
|
133
|
+
'setfacl -x u:someone feed_12',
|
|
134
|
+
'setfacl feed_12 # asks who to share it with',
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
handler: setfacl_run,
|
|
138
|
+
});
|
|
139
|
+
/**
|
|
140
|
+
* `setfacl` over words already split: the declaration's parse and handler.
|
|
141
|
+
*
|
|
142
|
+
* @param args - The words after `setfacl`.
|
|
143
|
+
* @returns An envelope naming what was granted, or the refusal of a bad line.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* await builtin_setfacl(['-x', 'u:someone', 'feed_12']);
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export async function builtin_setfacl(args) {
|
|
151
|
+
return declaredCommand_run(setfaclCommand, args);
|
|
66
152
|
}
|
|
67
153
|
/**
|
|
68
154
|
* Applies one entry to feeds: a user or group granted read, or the other
|
|
@@ -128,36 +214,63 @@ async function acl_remove(removal, feedIDs) {
|
|
|
128
214
|
lines.unshift(`${removal.kind} ${removal.name} no longer reads ${removed.join(' ')}`);
|
|
129
215
|
return envelope_ok(`${lines.join('\n')}\n`, { kind: 'fs.acl.removed', data: { kind: removal.kind, name: removal.name, targets: removed } });
|
|
130
216
|
}
|
|
217
|
+
/** What a `chmod` line may hold: a feed's one mode, then the feeds. */
|
|
218
|
+
const CHMOD_GRAMMAR = {
|
|
219
|
+
operands: [
|
|
220
|
+
{ name: 'mode', kind: 'enum', values: ['o+r', 'o-r'], summary: 'o+r makes the feeds public, o-r private: no other mode is one a feed has' },
|
|
221
|
+
FEEDS_OPERAND,
|
|
222
|
+
],
|
|
223
|
+
};
|
|
131
224
|
/**
|
|
132
225
|
* `chmod o+r` / `o-r` on feeds: the other entry, public or private, as
|
|
133
|
-
* `setfacl -m o::r` / `o::-` writes it.
|
|
226
|
+
* `setfacl -m o::r` / `o::-` writes it.
|
|
134
227
|
*
|
|
135
|
-
* @param args -
|
|
228
|
+
* @param args - The line, parsed.
|
|
136
229
|
* @returns An envelope naming what changed.
|
|
137
230
|
*/
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
return
|
|
142
|
-
|
|
143
|
-
for (const path of parsed.paths) {
|
|
144
|
-
const feedID = aclTarget_resolve(path);
|
|
145
|
-
if (feedID === null)
|
|
146
|
-
return envelope_error(`chmod: '${path}' does not name a feed\n`);
|
|
147
|
-
feedIDs.push(feedID);
|
|
148
|
-
}
|
|
149
|
-
return acl_apply(parsed.entry, feedIDs, 'chmod');
|
|
231
|
+
async function chmod_run(args) {
|
|
232
|
+
const feedIDs = feedIDs_resolve('chmod', args.operands.path, false);
|
|
233
|
+
if (!Array.isArray(feedIDs))
|
|
234
|
+
return feedIDs;
|
|
235
|
+
return acl_apply({ kind: 'other', name: '', perms: args.operands.mode === 'o+r' ? 'r' : '-' }, feedIDs, 'chmod');
|
|
150
236
|
}
|
|
151
237
|
/**
|
|
152
|
-
*
|
|
238
|
+
* `chmod <o+r|o-r> <path>…`: the declaration.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* commands_register({ declarations: [chmodCommand] }, 'backend');
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
export const chmodCommand = command_declare({
|
|
246
|
+
name: 'chmod',
|
|
247
|
+
grammar: CHMOD_GRAMMAR,
|
|
248
|
+
help: {
|
|
249
|
+
summary: 'Make a feed public, or private again',
|
|
250
|
+
description: 'The other entry of a feed\'s access list spelled as a mode: o+r makes it public, o-r private, '
|
|
251
|
+
+ 'exactly as setfacl -m o::r and o::- do. No other mode is one a feed has.',
|
|
252
|
+
category: 'Sharing',
|
|
253
|
+
posix: { group: 'Files', differs: 'sets who may see a feed or folder (ChRIS sharing)' },
|
|
254
|
+
examples: [
|
|
255
|
+
'chmod o+r feed_12',
|
|
256
|
+
'chmod o-r /proc/jobs/feed_12',
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
handler: chmod_run,
|
|
260
|
+
});
|
|
261
|
+
/**
|
|
262
|
+
* `chmod` over words already split: the declaration's parse and handler.
|
|
263
|
+
*
|
|
264
|
+
* @param args - The words after `chmod`.
|
|
265
|
+
* @returns An envelope naming what changed, or the refusal of a bad line.
|
|
153
266
|
*
|
|
154
|
-
* @
|
|
155
|
-
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* await builtin_chmod(['o+r', 'feed_12']);
|
|
270
|
+
* ```
|
|
156
271
|
*/
|
|
157
|
-
function
|
|
158
|
-
|
|
159
|
-
const paths = args.filter((token) => !token.startsWith('-'));
|
|
160
|
-
return !flagged && paths.length >= 1;
|
|
272
|
+
export async function builtin_chmod(args) {
|
|
273
|
+
return declaredCommand_run(chmodCommand, args);
|
|
161
274
|
}
|
|
162
275
|
/**
|
|
163
276
|
* Asks which identity a feed should be shared with.
|
|
@@ -179,19 +292,20 @@ async function who_ask(feedIDs) {
|
|
|
179
292
|
return '';
|
|
180
293
|
}
|
|
181
294
|
}
|
|
295
|
+
/** What a `getfacl` line may hold. */
|
|
296
|
+
const GETFACL_GRAMMAR = {
|
|
297
|
+
operands: [FEEDS_OPERAND],
|
|
298
|
+
};
|
|
182
299
|
/**
|
|
183
300
|
* Reports a feed's access list, in `getfacl`'s own shape.
|
|
184
301
|
*
|
|
185
|
-
* @param args -
|
|
302
|
+
* @param args - The line, parsed.
|
|
186
303
|
* @returns An envelope carrying the rendered list.
|
|
187
304
|
*/
|
|
188
|
-
|
|
189
|
-
const paths = args.filter((token) => !token.startsWith('-'));
|
|
190
|
-
if (paths.length === 0)
|
|
191
|
-
return envelope_error(`${GETFACL_USAGE}\n`);
|
|
305
|
+
async function getfacl_run(args) {
|
|
192
306
|
const blocks = [];
|
|
193
307
|
const model = [];
|
|
194
|
-
for (const path of
|
|
308
|
+
for (const path of args.operands.path) {
|
|
195
309
|
const feedID = aclTarget_resolve(path);
|
|
196
310
|
if (feedID === null) {
|
|
197
311
|
return envelope_error(`getfacl: '${path}' does not name a feed\n`);
|
|
@@ -206,4 +320,44 @@ export async function builtin_getfacl(args) {
|
|
|
206
320
|
}
|
|
207
321
|
return envelope_ok(`${blocks.join('\n\n')}\n`, { kind: 'fs.acl', data: model });
|
|
208
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* `getfacl <path>…`: the declaration.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```ts
|
|
328
|
+
* commands_register({ declarations: [getfaclCommand] }, 'backend');
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
export const getfaclCommand = command_declare({
|
|
332
|
+
name: 'getfacl',
|
|
333
|
+
grammar: GETFACL_GRAMMAR,
|
|
334
|
+
help: {
|
|
335
|
+
summary: 'Show who can read a feed: users, groups, and whether it is public',
|
|
336
|
+
description: 'Show who can read a feed, in the familiar block: a # file: line, the owner\'s user:: entry, '
|
|
337
|
+
+ 'one user: line per user and one group: line per group holding access, then other:: '
|
|
338
|
+
+ '(r-- when the feed is public).',
|
|
339
|
+
category: 'Sharing',
|
|
340
|
+
posix: { group: 'Files', differs: 'who a feed or folder is shared with, as ACL entries' },
|
|
341
|
+
examples: [
|
|
342
|
+
'getfacl /home/me/feeds/feed_12',
|
|
343
|
+
],
|
|
344
|
+
},
|
|
345
|
+
// Reading an access list changes nothing of the session.
|
|
346
|
+
holds: [],
|
|
347
|
+
handler: getfacl_run,
|
|
348
|
+
});
|
|
349
|
+
/**
|
|
350
|
+
* `getfacl` over words already split: the declaration's parse and handler.
|
|
351
|
+
*
|
|
352
|
+
* @param args - The words after `getfacl`.
|
|
353
|
+
* @returns The access lists, or the refusal of a bad line.
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```ts
|
|
357
|
+
* await builtin_getfacl(['feed_12']);
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
360
|
+
export async function builtin_getfacl(args) {
|
|
361
|
+
return declaredCommand_run(getfaclCommand, args);
|
|
362
|
+
}
|
|
209
363
|
//# sourceMappingURL=acl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acl.js","sourceRoot":"","sources":["../../../src/builtins/fs/acl.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"acl.js","sourceRoot":"","sources":["../../../src/builtins/fs/acl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAmB,MAAM,eAAe,CAAC;AACnJ,OAAO,EACL,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,UAAU,GAEhE,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAkC,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAmB,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,eAAe,EAA8C,MAAM,kCAAkC,CAAC;AAC/G,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,oEAAoE;AACpE,MAAM,aAAa,GAAG;IACpB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,0EAA0E;CAC3E,CAAC;AAEX,sCAAsC;AACtC,MAAM,eAAe,GAAG;IACtB,QAAQ,EAAE,CAAC,aAAa,CAAC;IACzB,OAAO,EAAE;QACP,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAA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CACrB,CAAC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAc;IAClD,OAAO,mBAAmB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
2
|
+
* @file What of `cat`'s line other modules read without loading cat.
|
|
3
3
|
*
|
|
4
|
-
* Defines the typed
|
|
5
|
-
*
|
|
6
|
-
* This module is intentionally
|
|
7
|
-
*
|
|
4
|
+
* Defines the typed options the core reads, the usage text, and the option
|
|
5
|
+
* predicate redirect filename inference uses. The line itself is parsed
|
|
6
|
+
* against `catCommand`'s grammar (`cat.ts`). This module is intentionally
|
|
7
|
+
* dependency-free so preprocessing can consume it without loading the file
|
|
8
|
+
* reader or syntax highlighter.
|
|
8
9
|
*
|
|
9
10
|
* @module
|
|
10
11
|
*/
|
|
11
12
|
/** Whether syntax highlighting follows TTY detection, is forced, or is disabled. */
|
|
12
13
|
export type CatHighlightMode = 'auto' | 'always' | 'never';
|
|
13
|
-
/**
|
|
14
|
+
/** The typed core's options: which files, and how they are presented. */
|
|
14
15
|
export interface CatArguments {
|
|
15
16
|
binaryMode: boolean;
|
|
16
17
|
highlightMode: CatHighlightMode;
|
|
17
18
|
highlightLanguage?: string;
|
|
18
19
|
filePaths: string[];
|
|
19
20
|
}
|
|
20
|
-
/** Canonical usage shared by
|
|
21
|
+
/** Canonical usage shared by the typed core's refusal and interactive help. */
|
|
21
22
|
export declare const CAT_USAGE: string;
|
|
22
23
|
/**
|
|
23
24
|
* Returns whether an argument belongs to the `cat` option grammar.
|
|
24
25
|
*
|
|
25
26
|
* @param argument - One token from the command line.
|
|
26
27
|
* @returns True for a recognized binary or highlight option.
|
|
27
|
-
*/
|
|
28
|
-
export declare function catArgument_isOption(argument: string): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Parses file paths and presentation options for the `cat` builtin.
|
|
31
|
-
* Later highlight flags take precedence over earlier highlight flags.
|
|
32
28
|
*
|
|
33
|
-
* @
|
|
34
|
-
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* catArgument_isOption('--highlight=python'); // true
|
|
32
|
+
* catArgument_isOption('notes.txt'); // false
|
|
33
|
+
* ```
|
|
35
34
|
*/
|
|
36
|
-
export declare function
|
|
35
|
+
export declare function catArgument_isOption(argument: string): boolean;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
2
|
+
* @file What of `cat`'s line other modules read without loading cat.
|
|
3
3
|
*
|
|
4
|
-
* Defines the typed
|
|
5
|
-
*
|
|
6
|
-
* This module is intentionally
|
|
7
|
-
*
|
|
4
|
+
* Defines the typed options the core reads, the usage text, and the option
|
|
5
|
+
* predicate redirect filename inference uses. The line itself is parsed
|
|
6
|
+
* against `catCommand`'s grammar (`cat.ts`). This module is intentionally
|
|
7
|
+
* dependency-free so preprocessing can consume it without loading the file
|
|
8
|
+
* reader or syntax highlighter.
|
|
8
9
|
*
|
|
9
10
|
* @module
|
|
10
11
|
*/
|
|
11
|
-
/** Canonical usage shared by
|
|
12
|
+
/** Canonical usage shared by the typed core's refusal and interactive help. */
|
|
12
13
|
export const CAT_USAGE = 'cat [--binary] [--highlight[=language] | --no-highlight] <file> [file...]';
|
|
13
14
|
const BINARY_OPTION = '--binary';
|
|
14
15
|
const HIGHLIGHT_OPTION = '--highlight';
|
|
@@ -19,6 +20,12 @@ const NO_HIGHLIGHT_OPTION = '--no-highlight';
|
|
|
19
20
|
*
|
|
20
21
|
* @param argument - One token from the command line.
|
|
21
22
|
* @returns True for a recognized binary or highlight option.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* catArgument_isOption('--highlight=python'); // true
|
|
27
|
+
* catArgument_isOption('notes.txt'); // false
|
|
28
|
+
* ```
|
|
22
29
|
*/
|
|
23
30
|
export function catArgument_isOption(argument) {
|
|
24
31
|
return argument === BINARY_OPTION
|
|
@@ -26,38 +33,4 @@ export function catArgument_isOption(argument) {
|
|
|
26
33
|
|| argument === NO_HIGHLIGHT_OPTION
|
|
27
34
|
|| argument.startsWith(HIGHLIGHT_LANGUAGE_PREFIX);
|
|
28
35
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Parses file paths and presentation options for the `cat` builtin.
|
|
31
|
-
* Later highlight flags take precedence over earlier highlight flags.
|
|
32
|
-
*
|
|
33
|
-
* @param args - Tokens following the `cat` command name.
|
|
34
|
-
* @returns Typed binary, highlighting, language, and file-path selections.
|
|
35
|
-
*/
|
|
36
|
-
export function catArguments_parse(args) {
|
|
37
|
-
let binaryMode = false;
|
|
38
|
-
let highlightMode = 'auto';
|
|
39
|
-
let highlightLanguage;
|
|
40
|
-
const filePaths = [];
|
|
41
|
-
for (const argument of args) {
|
|
42
|
-
if (argument === BINARY_OPTION) {
|
|
43
|
-
binaryMode = true;
|
|
44
|
-
}
|
|
45
|
-
else if (argument === HIGHLIGHT_OPTION) {
|
|
46
|
-
highlightMode = 'always';
|
|
47
|
-
highlightLanguage = undefined;
|
|
48
|
-
}
|
|
49
|
-
else if (argument.startsWith(HIGHLIGHT_LANGUAGE_PREFIX)) {
|
|
50
|
-
highlightMode = 'always';
|
|
51
|
-
highlightLanguage = argument.slice(HIGHLIGHT_LANGUAGE_PREFIX.length);
|
|
52
|
-
}
|
|
53
|
-
else if (argument === NO_HIGHLIGHT_OPTION) {
|
|
54
|
-
highlightMode = 'never';
|
|
55
|
-
highlightLanguage = undefined;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
filePaths.push(argument);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return { binaryMode, highlightMode, highlightLanguage, filePaths };
|
|
62
|
-
}
|
|
63
36
|
//# sourceMappingURL=cat.args.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat.args.js","sourceRoot":"","sources":["../../../src/builtins/fs/cat.args.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cat.args.js","sourceRoot":"","sources":["../../../src/builtins/fs/cat.args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAaH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,SAAS,GACpB,2EAA2E,CAAC;AAE9E,MAAM,aAAa,GAAW,UAAU,CAAC;AACzC,MAAM,gBAAgB,GAAW,aAAa,CAAC;AAC/C,MAAM,yBAAyB,GAAW,cAAc,CAAC;AACzD,MAAM,mBAAmB,GAAW,gBAAgB,CAAC;AAErD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,OAAO,QAAQ,KAAK,aAAa;WAC5B,QAAQ,KAAK,gBAAgB;WAC7B,QAAQ,KAAK,mBAAmB;WAChC,QAAQ,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -8,7 +8,44 @@ export interface CatOutcome {
|
|
|
8
8
|
bytes?: number;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* `cat [--binary] [--highlight[=<language>]] [--no-highlight] <files…>`: the declaration.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* commands_register({ declarations: [catCommand] });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const catCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
|
|
19
|
+
readonly operands: readonly [{
|
|
20
|
+
readonly name: "files";
|
|
21
|
+
readonly kind: "cfsPath";
|
|
22
|
+
readonly repeat: true;
|
|
23
|
+
readonly glob: true;
|
|
24
|
+
readonly summary: "The files to print, in order";
|
|
25
|
+
}];
|
|
26
|
+
readonly options: {
|
|
27
|
+
readonly binary: {
|
|
28
|
+
readonly long: "binary";
|
|
29
|
+
readonly summary: "Force byte-for-byte binary output";
|
|
30
|
+
};
|
|
31
|
+
readonly highlight: {
|
|
32
|
+
readonly long: "highlight";
|
|
33
|
+
readonly summary: "Force highlighting: in a cli-highlight language such as python, typescript, or sql; given none, inferred from the filename or content";
|
|
34
|
+
readonly value: {
|
|
35
|
+
readonly name: "language";
|
|
36
|
+
readonly kind: "word";
|
|
37
|
+
readonly optional: true;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
readonly noHighlight: {
|
|
41
|
+
readonly long: "no-highlight";
|
|
42
|
+
readonly summary: "Disable automatic syntax highlighting (wins over --highlight)";
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Displays the content of one or more files: the declaration's parse and
|
|
48
|
+
* handler over words already split.
|
|
12
49
|
*
|
|
13
50
|
* Supports multiple files and concatenates their output. Binary mode is applied
|
|
14
51
|
* per recognized file, or consistently to all files when `--binary` is specified.
|
|
@@ -17,9 +54,9 @@ export interface CatOutcome {
|
|
|
17
54
|
* and the binary auto-detection notice is emitted live on the err channel so it
|
|
18
55
|
* precedes the bytes it describes.
|
|
19
56
|
*
|
|
20
|
-
* @param args -
|
|
57
|
+
* @param args - The words after `cat`.
|
|
21
58
|
* @returns An envelope whose rendered text carries the (highlighted) file
|
|
22
|
-
* contents and whose model lists per-file outcomes.
|
|
59
|
+
* contents and whose model lists per-file outcomes, or the refusal of a bad line.
|
|
23
60
|
*/
|
|
24
61
|
export declare function builtin_cat(args: string[]): Promise<CommandEnvelope>;
|
|
25
62
|
/**
|