@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
|
@@ -2,24 +2,69 @@
|
|
|
2
2
|
* @file Builtin version.
|
|
3
3
|
* Reports the mise stack versions (the chell surface, the brasa engine, its
|
|
4
4
|
* chili/salsa/cumin layers, and the calypso sibling surface) as a command
|
|
5
|
-
* envelope — the in-shell counterpart of `chell --version`.
|
|
5
|
+
* envelope — the in-shell counterpart of `chell --version`. Declared in one
|
|
6
|
+
* record (`versionCommand`).
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
6
9
|
*/
|
|
7
10
|
import { versionReport_build, versions_get } from '../../core/version.js';
|
|
8
11
|
import { envelope_ok } from '@fnndsc/menu';
|
|
12
|
+
import { command_declare } from '../../core/commandDeclaration.js';
|
|
13
|
+
import { declaredCommand_run } from '../../core/commandParse.js';
|
|
14
|
+
/** What a `version` line may hold: nothing. */
|
|
15
|
+
const VERSION_GRAMMAR = {};
|
|
16
|
+
/**
|
|
17
|
+
* `version`: the declaration.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* commands_register({ declarations: [versionCommand] });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export const versionCommand = command_declare({
|
|
25
|
+
name: 'version',
|
|
26
|
+
grammar: VERSION_GRAMMAR,
|
|
27
|
+
help: {
|
|
28
|
+
summary: 'Report the versions of the mise stack layers running this session',
|
|
29
|
+
description: 'Report the versions of the mise stack layers running this session',
|
|
30
|
+
category: 'General',
|
|
31
|
+
examples: ['version'],
|
|
32
|
+
},
|
|
33
|
+
holds: [],
|
|
34
|
+
handler: async () => version_run(),
|
|
35
|
+
});
|
|
9
36
|
/**
|
|
10
37
|
* Reports the version of chell and the brasa engine, its layers, and the
|
|
11
38
|
* calypso sibling surface it runs with — the same report as `chell --version`,
|
|
12
39
|
* available from inside the shell.
|
|
13
40
|
*
|
|
14
|
-
* @param _args - Unused.
|
|
15
41
|
* @returns An envelope carrying the multi-line version report and a typed model
|
|
16
42
|
* of each layer's version.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* (await version_run()).model?.kind; // 'sys.version'
|
|
47
|
+
* ```
|
|
17
48
|
*/
|
|
18
|
-
export async function
|
|
49
|
+
export async function version_run() {
|
|
19
50
|
const versions = versions_get();
|
|
20
51
|
return envelope_ok(`${versionReport_build()}\n`, {
|
|
21
52
|
kind: 'sys.version',
|
|
22
53
|
data: versions,
|
|
23
54
|
});
|
|
24
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* `version` over words already split: the declaration's parse and handler.
|
|
58
|
+
*
|
|
59
|
+
* @param args - The words after `version` (none).
|
|
60
|
+
* @returns The report, or the refusal of a bad line.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* await builtin_version([]);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export async function builtin_version(args) {
|
|
68
|
+
return declaredCommand_run(versionCommand, args);
|
|
69
|
+
}
|
|
25
70
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/builtins/sys/version.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/builtins/sys/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAsB,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EAAmB,WAAW,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,+CAA+C;AAC/C,MAAM,eAAe,GAAG,EAAoC,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;IAC5C,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,eAAe;IACxB,IAAI,EAAE;QACJ,OAAO,EAAE,mEAAmE;QAC5E,WAAW,EAAE,mEAAmE;QAChF,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,CAAC,SAAS,CAAC;KACtB;IACD,KAAK,EAAE,EAAE;IACT,OAAO,EAAE,KAAK,IAA8B,EAAE,CAAC,WAAW,EAAE;CAC7D,CAAC,CAAC;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,QAAQ,GAAkB,YAAY,EAAE,CAAC;IAC/C,OAAO,WAAW,CAAC,GAAG,mBAAmB,EAAE,IAAI,EAAE;QAC/C,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,QAAQ;KACf,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAc;IAClD,OAAO,mBAAmB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CommandEnvelope } from '@fnndsc/menu';
|
|
2
|
+
import { type CommandArguments } from '../../core/commandDeclaration.js';
|
|
2
3
|
/**
|
|
3
4
|
* @file Builtin weather.
|
|
4
5
|
*
|
|
@@ -62,12 +63,6 @@ export interface WeatherReport {
|
|
|
62
63
|
now: WeatherNow;
|
|
63
64
|
days: WeatherDay[];
|
|
64
65
|
}
|
|
65
|
-
/** The words a call line was parsed into. */
|
|
66
|
-
interface WeatherArgs {
|
|
67
|
-
place: string;
|
|
68
|
-
units: WeatherUnits;
|
|
69
|
-
days: number;
|
|
70
|
-
}
|
|
71
66
|
/**
|
|
72
67
|
* Words a WMO weather code.
|
|
73
68
|
*
|
|
@@ -82,15 +77,6 @@ export declare function condition_resolve(code: number): string;
|
|
|
82
77
|
* @returns The compass point.
|
|
83
78
|
*/
|
|
84
79
|
export declare function compass_convertFromDegrees(degrees: number): string;
|
|
85
|
-
/**
|
|
86
|
-
* Parses the call line: a place in as many words as it takes, `--units`
|
|
87
|
-
* for the system, `-d N` for the days shown. Any other flag is refused by
|
|
88
|
-
* name.
|
|
89
|
-
*
|
|
90
|
-
* @param args - The words after `weather`.
|
|
91
|
-
* @returns The parsed call, or the refusal to print.
|
|
92
|
-
*/
|
|
93
|
-
export declare function weatherArgs_parse(args: string[]): WeatherArgs | string;
|
|
94
80
|
/**
|
|
95
81
|
* Finds a place by name.
|
|
96
82
|
*
|
|
@@ -118,6 +104,79 @@ export declare function report_fetch(fetchFn: WeatherFetch, place: WeatherPlace,
|
|
|
118
104
|
* @returns The text, with a trailing newline.
|
|
119
105
|
*/
|
|
120
106
|
export declare function report_render(report: WeatherReport): string;
|
|
107
|
+
/** What a `weather` line may hold. */
|
|
108
|
+
declare const WEATHER_GRAMMAR: {
|
|
109
|
+
readonly operands: readonly [{
|
|
110
|
+
readonly name: "place";
|
|
111
|
+
readonly kind: "word";
|
|
112
|
+
readonly optional: true;
|
|
113
|
+
readonly repeat: true;
|
|
114
|
+
readonly summary: "The place, in as many words as it takes (default Boston)";
|
|
115
|
+
}];
|
|
116
|
+
readonly options: {
|
|
117
|
+
readonly units: {
|
|
118
|
+
readonly short: "u";
|
|
119
|
+
readonly long: "units";
|
|
120
|
+
readonly summary: "metric (default: °C, km/h) or imperial (°F, mph)";
|
|
121
|
+
readonly value: {
|
|
122
|
+
readonly name: "system";
|
|
123
|
+
readonly kind: "enum";
|
|
124
|
+
readonly values: readonly ["metric", "imperial"];
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
readonly days: {
|
|
128
|
+
readonly short: "d";
|
|
129
|
+
readonly long: "days";
|
|
130
|
+
readonly summary: "Days of forecast to show (default 3, at most 16)";
|
|
131
|
+
readonly value: {
|
|
132
|
+
readonly name: "N";
|
|
133
|
+
readonly kind: "int";
|
|
134
|
+
readonly min: 1;
|
|
135
|
+
readonly max: number;
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* `weather [place] [-u|--units metric|imperial] [-d|--days N]`: the declaration.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* commands_register({ declarations: [weatherCommand] });
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export declare const weatherCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
|
|
149
|
+
readonly operands: readonly [{
|
|
150
|
+
readonly name: "place";
|
|
151
|
+
readonly kind: "word";
|
|
152
|
+
readonly optional: true;
|
|
153
|
+
readonly repeat: true;
|
|
154
|
+
readonly summary: "The place, in as many words as it takes (default Boston)";
|
|
155
|
+
}];
|
|
156
|
+
readonly options: {
|
|
157
|
+
readonly units: {
|
|
158
|
+
readonly short: "u";
|
|
159
|
+
readonly long: "units";
|
|
160
|
+
readonly summary: "metric (default: °C, km/h) or imperial (°F, mph)";
|
|
161
|
+
readonly value: {
|
|
162
|
+
readonly name: "system";
|
|
163
|
+
readonly kind: "enum";
|
|
164
|
+
readonly values: readonly ["metric", "imperial"];
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
readonly days: {
|
|
168
|
+
readonly short: "d";
|
|
169
|
+
readonly long: "days";
|
|
170
|
+
readonly summary: "Days of forecast to show (default 3, at most 16)";
|
|
171
|
+
readonly value: {
|
|
172
|
+
readonly name: "N";
|
|
173
|
+
readonly kind: "int";
|
|
174
|
+
readonly min: 1;
|
|
175
|
+
readonly max: number;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
}>;
|
|
121
180
|
/**
|
|
122
181
|
* Reports the weather at a place.
|
|
123
182
|
*
|
|
@@ -127,6 +186,24 @@ export declare function report_render(report: WeatherReport): string;
|
|
|
127
186
|
* @returns An envelope carrying the rendered report and the typed report
|
|
128
187
|
* beneath it; an error envelope when a flag is unknown, the place is not
|
|
129
188
|
* found, or the service cannot be reached.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```ts
|
|
192
|
+
* await builtin_weather(['Paris', '-d', '7']);
|
|
193
|
+
* ```
|
|
130
194
|
*/
|
|
131
195
|
export declare function builtin_weather(args: string[], fetchFn?: WeatherFetch): Promise<CommandEnvelope>;
|
|
196
|
+
/**
|
|
197
|
+
* Reports the weather for a line already parsed.
|
|
198
|
+
*
|
|
199
|
+
* @param args - The typed line.
|
|
200
|
+
* @param fetchFn - The fetch to go through.
|
|
201
|
+
* @returns The report, or an error envelope when the place is not found or the service cannot be reached.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts
|
|
205
|
+
* await weather_run({ subcommand: null, operands: { place: ['Paris'] }, options: { units: undefined, days: 7 }, expanded: {} }, fetch);
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
export declare function weather_run(args: CommandArguments<typeof WEATHER_GRAMMAR>, fetchFn: WeatherFetch): Promise<CommandEnvelope>;
|
|
132
209
|
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { envelope_error, envelope_ok } from '@fnndsc/menu';
|
|
2
|
+
import { command_declare } from '../../core/commandDeclaration.js';
|
|
3
|
+
import { declaredCommand_run } from '../../core/commandParse.js';
|
|
2
4
|
/**
|
|
3
5
|
* @file Builtin weather.
|
|
4
6
|
*
|
|
@@ -100,44 +102,6 @@ function number_read(value) {
|
|
|
100
102
|
function string_read(value) {
|
|
101
103
|
return typeof value === 'string' ? value : '';
|
|
102
104
|
}
|
|
103
|
-
/**
|
|
104
|
-
* Parses the call line: a place in as many words as it takes, `--units`
|
|
105
|
-
* for the system, `-d N` for the days shown. Any other flag is refused by
|
|
106
|
-
* name.
|
|
107
|
-
*
|
|
108
|
-
* @param args - The words after `weather`.
|
|
109
|
-
* @returns The parsed call, or the refusal to print.
|
|
110
|
-
*/
|
|
111
|
-
export function weatherArgs_parse(args) {
|
|
112
|
-
const words = [];
|
|
113
|
-
let units = WEATHER_UNITS_DEFAULT;
|
|
114
|
-
let days = DAYS_DEFAULT;
|
|
115
|
-
for (let i = 0; i < args.length; i++) {
|
|
116
|
-
const arg = args[i];
|
|
117
|
-
if (arg === '-u' || arg === '--units' || arg.startsWith('--units=')) {
|
|
118
|
-
const value = arg.startsWith('--units=') ? arg.slice('--units='.length) : (args[++i] ?? '');
|
|
119
|
-
if (value !== 'metric' && value !== 'imperial') {
|
|
120
|
-
return `weather: --units takes metric or imperial, not '${value}'`;
|
|
121
|
-
}
|
|
122
|
-
units = value;
|
|
123
|
-
}
|
|
124
|
-
else if (arg === '-d' || arg === '--days') {
|
|
125
|
-
const value = parseInt(args[i + 1] ?? '', 10);
|
|
126
|
-
if (!Number.isFinite(value) || value < 1 || value > DAYS_MAX) {
|
|
127
|
-
return `weather: ${arg} takes a number of days, 1 to ${DAYS_MAX}`;
|
|
128
|
-
}
|
|
129
|
-
days = value;
|
|
130
|
-
i++;
|
|
131
|
-
}
|
|
132
|
-
else if (arg.startsWith('-')) {
|
|
133
|
-
return `weather: unknown option '${arg}' (usage: weather [place] [-u|--units metric|imperial] [-d|--days N])`;
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
words.push(arg);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return { place: words.length > 0 ? words.join(' ') : WEATHER_DEFAULT_PLACE, units, days };
|
|
140
|
-
}
|
|
141
105
|
/**
|
|
142
106
|
* Fetches one JSON answer, bounded in time.
|
|
143
107
|
*
|
|
@@ -268,6 +232,48 @@ export function report_render(report) {
|
|
|
268
232
|
});
|
|
269
233
|
return `${lines.join('\n')}\n`;
|
|
270
234
|
}
|
|
235
|
+
/** What a `weather` line may hold. */
|
|
236
|
+
const WEATHER_GRAMMAR = {
|
|
237
|
+
operands: [{ name: 'place', kind: 'word', optional: true, repeat: true, summary: 'The place, in as many words as it takes (default Boston)' }],
|
|
238
|
+
options: {
|
|
239
|
+
units: { short: 'u', long: 'units', summary: 'metric (default: °C, km/h) or imperial (°F, mph)', value: { name: 'system', kind: 'enum', values: ['metric', 'imperial'] } },
|
|
240
|
+
days: { short: 'd', long: 'days', summary: 'Days of forecast to show (default 3, at most 16)', value: { name: 'N', kind: 'int', min: 1, max: DAYS_MAX } },
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* `weather [place] [-u|--units metric|imperial] [-d|--days N]`: the declaration.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* commands_register({ declarations: [weatherCommand] });
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
export const weatherCommand = command_declare({
|
|
252
|
+
name: 'weather',
|
|
253
|
+
grammar: WEATHER_GRAMMAR,
|
|
254
|
+
help: {
|
|
255
|
+
summary: 'The weather at a place, now and the next few days',
|
|
256
|
+
description: 'Reports the current conditions and a short forecast for a place, from Open-Meteo (no key, no account). The place is found by name; with none given it is Boston. Metric (°C, km/h) unless --units imperial asks for °F and mph. The call is made from the session host, so it needs that host to reach the internet.',
|
|
257
|
+
examples: ['weather', 'weather Cape Town', 'weather Boston --units imperial', 'weather Paris -d 7'],
|
|
258
|
+
category: 'Games',
|
|
259
|
+
},
|
|
260
|
+
handler: async (args) => weather_run(args, fetch_global),
|
|
261
|
+
});
|
|
262
|
+
/**
|
|
263
|
+
* The global fetch, as the report goes through it unless a test hands in its own.
|
|
264
|
+
*
|
|
265
|
+
* @param url - What to ask.
|
|
266
|
+
* @param init - The request's options.
|
|
267
|
+
* @returns The answer.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```ts
|
|
271
|
+
* const answer: Response = await fetch_global('https://example.org');
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
function fetch_global(url, init) {
|
|
275
|
+
return fetch(url, init);
|
|
276
|
+
}
|
|
271
277
|
/**
|
|
272
278
|
* Reports the weather at a place.
|
|
273
279
|
*
|
|
@@ -277,16 +283,36 @@ export function report_render(report) {
|
|
|
277
283
|
* @returns An envelope carrying the rendered report and the typed report
|
|
278
284
|
* beneath it; an error envelope when a flag is unknown, the place is not
|
|
279
285
|
* found, or the service cannot be reached.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* await builtin_weather(['Paris', '-d', '7']);
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
export async function builtin_weather(args, fetchFn = fetch_global) {
|
|
293
|
+
return declaredCommand_run({ ...weatherCommand, handler: (typed) => weather_run(typed, fetchFn) }, args);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Reports the weather for a line already parsed.
|
|
297
|
+
*
|
|
298
|
+
* @param args - The typed line.
|
|
299
|
+
* @param fetchFn - The fetch to go through.
|
|
300
|
+
* @returns The report, or an error envelope when the place is not found or the service cannot be reached.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```ts
|
|
304
|
+
* await weather_run({ subcommand: null, operands: { place: ['Paris'] }, options: { units: undefined, days: 7 }, expanded: {} }, fetch);
|
|
305
|
+
* ```
|
|
280
306
|
*/
|
|
281
|
-
export async function
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
307
|
+
export async function weather_run(args, fetchFn) {
|
|
308
|
+
const placeName = args.operands.place.length > 0 ? args.operands.place.join(' ') : WEATHER_DEFAULT_PLACE;
|
|
309
|
+
const units = args.options.units ?? WEATHER_UNITS_DEFAULT;
|
|
310
|
+
const days = args.options.days ?? DAYS_DEFAULT;
|
|
285
311
|
try {
|
|
286
|
-
const place = await place_find(fetchFn,
|
|
312
|
+
const place = await place_find(fetchFn, placeName);
|
|
287
313
|
if (place === null)
|
|
288
|
-
return envelope_error(`weather: no such place '${
|
|
289
|
-
const report = await report_fetch(fetchFn, place,
|
|
314
|
+
return envelope_error(`weather: no such place '${placeName}'\n`);
|
|
315
|
+
const report = await report_fetch(fetchFn, place, units, days);
|
|
290
316
|
return envelope_ok(report_render(report), { kind: 'sys.weather', data: report });
|
|
291
317
|
}
|
|
292
318
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"weather.js","sourceRoot":"","sources":["../../../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,CAAC,KAAK,CAAC,CAAC;QAC9E,OAAO,cAAc,CAAC,YAAY,MAAM,IAAI,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
import { type CommandEnvelope } from '@fnndsc/menu';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* `id`: the declaration.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* commands_register({ declarations: [idCommand] }, 'backend');
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare const idCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{}>;
|
|
11
|
+
/**
|
|
12
|
+
* `whoami`: the declaration.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* commands_register({ declarations: [whoamiCommand] }, 'backend');
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const whoamiCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{}>;
|
|
20
|
+
/**
|
|
21
|
+
* `whereami`: the declaration.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* commands_register({ declarations: [whereamiCommand] }, 'backend');
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const whereamiCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{}>;
|
|
29
|
+
/**
|
|
30
|
+
* `id` over words already split: the declaration's parse and handler.
|
|
8
31
|
*
|
|
9
|
-
* @param
|
|
10
|
-
* @returns
|
|
11
|
-
* membership, or an error envelope when identity cannot be resolved.
|
|
32
|
+
* @param args - The words after `id`: none.
|
|
33
|
+
* @returns The identity, or the refusal of a bad line.
|
|
12
34
|
*/
|
|
13
|
-
export declare function builtin_id(
|
|
35
|
+
export declare function builtin_id(args: string[]): Promise<CommandEnvelope>;
|
|
14
36
|
/**
|
|
15
|
-
*
|
|
37
|
+
* `whoami` over words already split: the declaration's parse and handler.
|
|
16
38
|
*
|
|
17
|
-
* @param
|
|
18
|
-
* @returns
|
|
19
|
-
* not-connected notice when no user is authenticated.
|
|
39
|
+
* @param args - The words after `whoami`: none.
|
|
40
|
+
* @returns The username, or the refusal of a bad line.
|
|
20
41
|
*/
|
|
21
|
-
export declare function builtin_whoami(
|
|
42
|
+
export declare function builtin_whoami(args: string[]): Promise<CommandEnvelope>;
|
|
22
43
|
/**
|
|
23
|
-
*
|
|
44
|
+
* `whereami` over words already split: the declaration's parse and handler.
|
|
24
45
|
*
|
|
25
|
-
* @param
|
|
26
|
-
* @returns
|
|
27
|
-
* not-connected notice when no connection exists.
|
|
46
|
+
* @param args - The words after `whereami`: none.
|
|
47
|
+
* @returns The CUBE URL, or the refusal of a bad line.
|
|
28
48
|
*/
|
|
29
|
-
export declare function builtin_whereami(
|
|
49
|
+
export declare function builtin_whereami(args: string[]): Promise<CommandEnvelope>;
|
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
2
|
+
* @file `id`, `whoami` and `whereami`: who the session is on CUBE, and
|
|
3
|
+
* which CUBE, each in a line.
|
|
4
|
+
*
|
|
5
|
+
* Declared in one record each (`idCommand`, `whoamiCommand`,
|
|
6
|
+
* `whereamiCommand`): none takes an operand or an option.
|
|
7
|
+
*
|
|
8
|
+
* Key components:
|
|
9
|
+
* - idCommand, whoamiCommand, whereamiCommand: the declarations.
|
|
10
|
+
* - builtin_id, builtin_whoami, builtin_whereami: each declaration run over words already split.
|
|
11
|
+
*
|
|
12
|
+
* Typical usage:
|
|
13
|
+
* ```ts
|
|
14
|
+
* await builtin_whoami([]);
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Dependencies: the session's context and identity (salsa, cumin).
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
4
20
|
*/
|
|
5
21
|
import chalk from 'chalk';
|
|
6
22
|
import { context_getSingle } from '@fnndsc/salsa';
|
|
7
23
|
import { currentIdentity_get } from '@fnndsc/cumin';
|
|
8
24
|
import { envelope_error, envelope_ok } from '@fnndsc/menu';
|
|
9
25
|
import { exitCode_set } from '../../core/handlerRun.js';
|
|
26
|
+
import { command_declare } from '../../core/commandDeclaration.js';
|
|
27
|
+
import { declaredCommand_run } from '../../core/commandParse.js';
|
|
28
|
+
/** What an `id`, `whoami` or `whereami` line may hold: nothing after the command. */
|
|
29
|
+
const IDENTITY_GRAMMAR = {};
|
|
10
30
|
/**
|
|
11
31
|
* Reports the current ChRIS identity using Unix `id` notation.
|
|
12
32
|
*
|
|
@@ -14,11 +34,10 @@ import { exitCode_set } from '../../core/handlerRun.js';
|
|
|
14
34
|
* uses the same POSIX projection as `/etc/passwd`: the primary GID and group
|
|
15
35
|
* name equal the user's ID and username.
|
|
16
36
|
*
|
|
17
|
-
* @param _args - Unused.
|
|
18
37
|
* @returns An envelope carrying numeric UID/GID identity and every CUBE group
|
|
19
38
|
* membership, or an error envelope when identity cannot be resolved.
|
|
20
39
|
*/
|
|
21
|
-
|
|
40
|
+
async function id_run() {
|
|
22
41
|
const result = await currentIdentity_get();
|
|
23
42
|
if (!result.ok) {
|
|
24
43
|
exitCode_set(1);
|
|
@@ -55,11 +74,10 @@ export async function builtin_id(_args) {
|
|
|
55
74
|
/**
|
|
56
75
|
* Reports the current authenticated ChRIS username.
|
|
57
76
|
*
|
|
58
|
-
* @param _args - Unused.
|
|
59
77
|
* @returns An envelope carrying the username, or an error envelope with a
|
|
60
78
|
* not-connected notice when no user is authenticated.
|
|
61
79
|
*/
|
|
62
|
-
|
|
80
|
+
async function whoami_run() {
|
|
63
81
|
const context = await context_getSingle();
|
|
64
82
|
if (context.user) {
|
|
65
83
|
return envelope_ok(`${chalk.cyan(context.user)}\n`, {
|
|
@@ -73,11 +91,10 @@ export async function builtin_whoami(_args) {
|
|
|
73
91
|
/**
|
|
74
92
|
* Reports the current CUBE URI.
|
|
75
93
|
*
|
|
76
|
-
* @param _args - Unused.
|
|
77
94
|
* @returns An envelope carrying the CUBE URL, or an error envelope with a
|
|
78
95
|
* not-connected notice when no connection exists.
|
|
79
96
|
*/
|
|
80
|
-
|
|
97
|
+
async function whereami_run() {
|
|
81
98
|
const context = await context_getSingle();
|
|
82
99
|
if (context.URL) {
|
|
83
100
|
return envelope_ok(`${chalk.blue(context.URL)}\n`, {
|
|
@@ -88,4 +105,91 @@ export async function builtin_whereami(_args) {
|
|
|
88
105
|
exitCode_set(1);
|
|
89
106
|
return envelope_error(`${chalk.gray('(not connected)')}\n`);
|
|
90
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* `id`: the declaration.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* commands_register({ declarations: [idCommand] }, 'backend');
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export const idCommand = command_declare({
|
|
117
|
+
name: 'id',
|
|
118
|
+
grammar: IDENTITY_GRAMMAR,
|
|
119
|
+
help: {
|
|
120
|
+
summary: 'Print the CUBE user as a Unix-style uid, gid and groups',
|
|
121
|
+
description: 'Print the current CUBE user as a Unix-style UID, projected primary GID, and complete list of CUBE group memberships.',
|
|
122
|
+
category: 'Connection',
|
|
123
|
+
examples: ['id'],
|
|
124
|
+
},
|
|
125
|
+
holds: [],
|
|
126
|
+
handler: async () => id_run(),
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* `whoami`: the declaration.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* commands_register({ declarations: [whoamiCommand] }, 'backend');
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export const whoamiCommand = command_declare({
|
|
137
|
+
name: 'whoami',
|
|
138
|
+
grammar: IDENTITY_GRAMMAR,
|
|
139
|
+
help: {
|
|
140
|
+
summary: 'Print the currently authenticated ChRIS username',
|
|
141
|
+
description: 'Print the currently authenticated ChRIS username; a session not connected says so.',
|
|
142
|
+
category: 'Connection',
|
|
143
|
+
examples: ['whoami'],
|
|
144
|
+
},
|
|
145
|
+
holds: [],
|
|
146
|
+
handler: async () => whoami_run(),
|
|
147
|
+
});
|
|
148
|
+
/**
|
|
149
|
+
* `whereami`: the declaration.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* commands_register({ declarations: [whereamiCommand] }, 'backend');
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export const whereamiCommand = command_declare({
|
|
157
|
+
name: 'whereami',
|
|
158
|
+
grammar: IDENTITY_GRAMMAR,
|
|
159
|
+
help: {
|
|
160
|
+
summary: 'Print the current CUBE URL',
|
|
161
|
+
description: 'Print the URL of the CUBE this session talks to; a session not connected says so.',
|
|
162
|
+
category: 'Connection',
|
|
163
|
+
examples: ['whereami'],
|
|
164
|
+
},
|
|
165
|
+
holds: [],
|
|
166
|
+
handler: async () => whereami_run(),
|
|
167
|
+
});
|
|
168
|
+
/**
|
|
169
|
+
* `id` over words already split: the declaration's parse and handler.
|
|
170
|
+
*
|
|
171
|
+
* @param args - The words after `id`: none.
|
|
172
|
+
* @returns The identity, or the refusal of a bad line.
|
|
173
|
+
*/
|
|
174
|
+
export async function builtin_id(args) {
|
|
175
|
+
return declaredCommand_run(idCommand, args);
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* `whoami` over words already split: the declaration's parse and handler.
|
|
179
|
+
*
|
|
180
|
+
* @param args - The words after `whoami`: none.
|
|
181
|
+
* @returns The username, or the refusal of a bad line.
|
|
182
|
+
*/
|
|
183
|
+
export async function builtin_whoami(args) {
|
|
184
|
+
return declaredCommand_run(whoamiCommand, args);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* `whereami` over words already split: the declaration's parse and handler.
|
|
188
|
+
*
|
|
189
|
+
* @param args - The words after `whereami`: none.
|
|
190
|
+
* @returns The CUBE URL, or the refusal of a bad line.
|
|
191
|
+
*/
|
|
192
|
+
export async function builtin_whereami(args) {
|
|
193
|
+
return declaredCommand_run(whereamiCommand, args);
|
|
194
|
+
}
|
|
91
195
|
//# sourceMappingURL=whoami.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../../src/builtins/sys/whoami.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../../src/builtins/sys/whoami.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAA2D,MAAM,eAAe,CAAC;AAE7G,OAAO,EAAE,cAAc,EAAE,WAAW,EAAwB,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAuB,MAAM,kCAAkC,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,qFAAqF;AACrF,MAAM,gBAAgB,GAAG,EAAoC,CAAC;AAQ9D;;;;;;;;;GASG;AACH,KAAK,UAAU,MAAM;IACnB,MAAM,MAAM,GAA0B,MAAM,mBAAmB,EAAE,CAAC;IAClE,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QACf,YAAY,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO,cAAc,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;IAED,MAAM,QAAQ,GAAkB,MAAM,CAAC,KAAK,CAAC;IAC7C,MAAM,YAAY,GAAuB;QACvC,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;QACrB,KAAK,EAAE,QAAQ,CAAC,IAAI,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