@fnndsc/brasa 0.56.1 → 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/berth.d.ts +90 -3
- package/dist/builtins/berth/berth.js +129 -76
- package/dist/builtins/berth/berth.js.map +1 -1
- package/dist/builtins/berth/berthClose.d.ts +25 -6
- package/dist/builtins/berth/berthClose.js +8 -64
- package/dist/builtins/berth/berthClose.js.map +1 -1
- package/dist/builtins/berth/berthCube.d.ts +3 -2
- package/dist/builtins/berth/berthCube.js +9 -16
- package/dist/builtins/berth/berthCube.js.map +1 -1
- package/dist/builtins/berth/berthProcesses.js +33 -3
- package/dist/builtins/berth/berthProcesses.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 +92 -13
- 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 +122 -56
- package/dist/builtins/fs/cp.js.map +1 -1
- package/dist/builtins/fs/download.d.ts +31 -4
- package/dist/builtins/fs/download.js +75 -38
- 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/ls.d.ts +69 -4
- package/dist/builtins/fs/ls.js +84 -45
- package/dist/builtins/fs/ls.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 +123 -31
- 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 +41 -3
- package/dist/builtins/help.js +92 -796
- 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 +55 -7
- package/dist/builtins/res/dicom.js +86 -52
- 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 +719 -264
- 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 +1 -38
- package/dist/builtins/utils.js +1 -87
- package/dist/builtins/utils.js.map +1 -1
- package/dist/chris/backend.js +2 -0
- package/dist/chris/backend.js.map +1 -1
- package/dist/chris/chrisCommands.js +62 -159
- 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/files.js +24 -85
- package/dist/chris/files.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 -1082
- package/dist/chris/help.js.map +1 -1
- package/dist/chris/kinds.d.ts +30 -0
- package/dist/chris/kinds.js +154 -0
- package/dist/chris/kinds.js.map +1 -0
- 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/chris/promptContext.d.ts +6 -0
- package/dist/chris/promptContext.js +3 -1
- package/dist/chris/promptContext.js.map +1 -1
- package/dist/core/argumentKinds.d.ts +107 -0
- package/dist/core/argumentKinds.js +223 -0
- package/dist/core/argumentKinds.js.map +1 -0
- package/dist/core/backend.d.ts +4 -1
- package/dist/core/backend.js.map +1 -1
- package/dist/core/commandDeclaration.d.ts +453 -0
- package/dist/core/commandDeclaration.js +52 -0
- package/dist/core/commandDeclaration.js.map +1 -0
- package/dist/core/commandParse.d.ts +64 -0
- package/dist/core/commandParse.js +468 -0
- package/dist/core/commandParse.js.map +1 -0
- package/dist/core/commandRegistry.d.ts +37 -0
- package/dist/core/commandRegistry.js +100 -3
- package/dist/core/commandRegistry.js.map +1 -1
- package/dist/core/commandSchema.d.ts +32 -0
- package/dist/core/commandSchema.js +117 -0
- package/dist/core/commandSchema.js.map +1 -0
- package/dist/core/commandUsage.d.ts +62 -0
- package/dist/core/commandUsage.js +247 -0
- package/dist/core/commandUsage.js.map +1 -0
- package/dist/core/coreCommands.js +66 -214
- package/dist/core/coreCommands.js.map +1 -1
- package/dist/core/dispatch.js +15 -8
- package/dist/core/dispatch.js.map +1 -1
- package/dist/core/paths.d.ts +51 -0
- package/dist/core/paths.js +86 -2
- package/dist/core/paths.js.map +1 -1
- package/dist/core/preprocess.d.ts +10 -9
- package/dist/core/preprocess.js +10 -20
- package/dist/core/preprocess.js.map +1 -1
- package/dist/core/warmupFailures.d.ts +34 -2
- package/dist/core/warmupFailures.js +43 -2
- package/dist/core/warmupFailures.js.map +1 -1
- package/dist/lib/completer/cfsPaths.d.ts +14 -0
- package/dist/lib/completer/cfsPaths.js +91 -0
- package/dist/lib/completer/cfsPaths.js.map +1 -0
- package/dist/lib/completer/declared.d.ts +15 -0
- package/dist/lib/completer/declared.js +189 -0
- package/dist/lib/completer/declared.js.map +1 -0
- package/dist/lib/completer/index.js +33 -79
- package/dist/lib/completer/index.js.map +1 -1
- package/dist/lib/parser.d.ts +5 -8
- package/dist/lib/parser.js +2 -11
- package/dist/lib/parser.js.map +1 -1
- package/dist/lib/vfs/vfs.d.ts +2 -1
- package/dist/lib/vfs/vfs.js +9 -6
- package/dist/lib/vfs/vfs.js.map +1 -1
- package/dist/lib/wildcard.js +2 -3
- package/dist/lib/wildcard.js.map +1 -1
- package/dist/notes.json +1 -1
- package/package.json +6 -5
|
@@ -11,6 +11,8 @@ import { surface_get } from '../../core/surface.js';
|
|
|
11
11
|
import { uptime_words } from './lab.js';
|
|
12
12
|
import { BRAIN } from './cowsay.js';
|
|
13
13
|
import { envelope_ok, envelope_error } from '@fnndsc/menu';
|
|
14
|
+
import { command_declare } from '../../core/commandDeclaration.js';
|
|
15
|
+
import { declaredCommand_run } from '../../core/commandParse.js';
|
|
14
16
|
/** Round trips `ping` makes when not told. */
|
|
15
17
|
export const PING_COUNT = 3;
|
|
16
18
|
/** The most round trips `ping` makes however asked. */
|
|
@@ -61,21 +63,76 @@ export function ping_summary(samples) {
|
|
|
61
63
|
}
|
|
62
64
|
return out;
|
|
63
65
|
}
|
|
64
|
-
/** `ping
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
66
|
+
/** What a `ping` line may hold: how many round trips, and the one place it pings. */
|
|
67
|
+
const PING_GRAMMAR = {
|
|
68
|
+
operands: [{ name: 'target', kind: 'enum', values: ['cube'], optional: true, summary: 'What to ping: only cube' }],
|
|
69
|
+
options: {
|
|
70
|
+
count: { short: 'c', summary: `Round trips to make (default ${PING_COUNT}, at most ${PING_MAX})`, value: { name: 'N', kind: 'int', min: 1 } },
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
/** The fetch `ping` uses unless handed another. */
|
|
74
|
+
const defaultFetch = (url, init) => fetch(url, init);
|
|
75
|
+
/**
|
|
76
|
+
* Declares `ping` over a fetch (a test hands in its own).
|
|
77
|
+
*
|
|
78
|
+
* @param fetchFn - The fetch the command round-trips with.
|
|
79
|
+
* @returns The declaration.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const command = pingCommand_make(fakeFetch);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export function pingCommand_make(fetchFn) {
|
|
87
|
+
return command_declare({
|
|
88
|
+
name: 'ping',
|
|
89
|
+
grammar: PING_GRAMMAR,
|
|
90
|
+
help: {
|
|
91
|
+
summary: 'Round trips to CUBE, timed',
|
|
92
|
+
description: "Makes N (3) HTTP round trips to the CUBE this session talks to and times each, then sums up as ping does — and adds the average of this session's own calls to CUBE so far. Only CUBE is pinged from here: a hosted session is not a probe for the network it sits on.",
|
|
93
|
+
examples: ['ping', 'ping -c 10'],
|
|
94
|
+
},
|
|
95
|
+
handler: async (args) => ping_command(args.options.count, fetchFn),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* `ping [-c N] [cube]`: the declaration.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* commands_register({ declarations: [pingCommand] });
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export const pingCommand = pingCommand_make(defaultFetch);
|
|
107
|
+
/**
|
|
108
|
+
* `ping` over words already split: the declaration's parse and handler.
|
|
109
|
+
*
|
|
110
|
+
* @param args - The words after `ping`.
|
|
111
|
+
* @param fetchFn - The fetch to use.
|
|
112
|
+
* @returns The round trips, or the refusal of a bad line.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* await builtin_ping(['-c', '2']);
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export async function builtin_ping(args, fetchFn = defaultFetch) {
|
|
120
|
+
return declaredCommand_run(fetchFn === defaultFetch ? pingCommand : pingCommand_make(fetchFn), args);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Round-trips to the session's CUBE and sums up.
|
|
124
|
+
*
|
|
125
|
+
* @param asked - How many round trips were asked for; absent for the default.
|
|
126
|
+
* @param fetchFn - The fetch to use.
|
|
127
|
+
* @returns The samples and their summary, or a refusal when not connected.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* await ping_command(3, fetch);
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export async function ping_command(asked, fetchFn) {
|
|
135
|
+
const count = Math.min(asked ?? PING_COUNT, PING_MAX);
|
|
79
136
|
const url = await chrisContext.ChRISURL_get();
|
|
80
137
|
if (url === null)
|
|
81
138
|
return envelope_error('', undefined, 'ping: not connected to a CUBE\n');
|
|
@@ -87,8 +144,51 @@ export async function builtin_ping(args, fetchFn = (url, init) => fetch(url, ini
|
|
|
87
144
|
const recent = ledger.total > 0 ? `\nthis session's own calls: ${ledger.total} to CUBE, ${(ledger.ms / ledger.total).toFixed(0)} ms each on average` : '';
|
|
88
145
|
return envelope_ok(`${lines.join('\n')}\n--- cube ping statistics ---\n${ping_summary(samples)}${recent}\n`, { kind: 'games.ping', data: { url, samples } });
|
|
89
146
|
}
|
|
90
|
-
/** `chrisfetch
|
|
91
|
-
|
|
147
|
+
/** `chrisfetch` takes nothing. */
|
|
148
|
+
const CHRISFETCH_GRAMMAR = {};
|
|
149
|
+
/**
|
|
150
|
+
* `chrisfetch`: the declaration.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* commands_register({ declarations: [chrisfetchCommand] });
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export const chrisfetchCommand = command_declare({
|
|
158
|
+
name: 'chrisfetch',
|
|
159
|
+
grammar: CHRISFETCH_GRAMMAR,
|
|
160
|
+
help: {
|
|
161
|
+
summary: "The brain beside the session's facts, neofetch style",
|
|
162
|
+
description: "Who you are and where, feeds by scope, jobs run and the failure rate, the index's state, the surfaces attached, the uptime — beside the ChRIS brain. All from what the session already holds: no extra calls.",
|
|
163
|
+
examples: ['chrisfetch', 'chrisfetch | lolcat'],
|
|
164
|
+
},
|
|
165
|
+
handler: async () => chrisfetch_run(),
|
|
166
|
+
});
|
|
167
|
+
/**
|
|
168
|
+
* `chrisfetch` over words already split: the declaration's parse and handler.
|
|
169
|
+
*
|
|
170
|
+
* @param args - The words after `chrisfetch`: none.
|
|
171
|
+
* @returns The brain beside the facts, or the refusal of a bad line.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* await builtin_chrisfetch([]);
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
export async function builtin_chrisfetch(args) {
|
|
179
|
+
return declaredCommand_run(chrisfetchCommand, args);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The brain beside the session's facts, neofetch style.
|
|
183
|
+
*
|
|
184
|
+
* @returns The brain and the facts.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```ts
|
|
188
|
+
* await chrisfetch_run();
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export async function chrisfetch_run() {
|
|
92
192
|
const user = (await chrisContext.ChRISuser_get()) ?? '?';
|
|
93
193
|
const url = await chrisContext.ChRISURL_get();
|
|
94
194
|
const host = url === null ? '(not connected)' : url.replace(/^https?:\/\//, '').replace(/\/api\/v1\/?$/, '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chrislab.js","sourceRoot":"","sources":["../../../src/builtins/games/chrislab.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAuB,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAoB,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAmB,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"chrislab.js","sourceRoot":"","sources":["../../../src/builtins/games/chrislab.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAuB,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAoB,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAmB,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAuE,MAAM,kCAAkC,CAAC;AACxI,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEj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AAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;AAC/O,CAAC"}
|
|
@@ -20,7 +20,98 @@ export declare function bubble_draw(lines: string[], thought: boolean): string[]
|
|
|
20
20
|
* @param width - Wrap width.
|
|
21
21
|
*/
|
|
22
22
|
export declare function cowsay_render(text: string, thought?: boolean, width?: number): string;
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* `cowsay [-W N] [text]`: the declaration.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* commands_register({ declarations: [cowsayCommand] });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const cowsayCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
|
|
32
|
+
readonly operands: readonly [{
|
|
33
|
+
readonly name: "text";
|
|
34
|
+
readonly kind: "word";
|
|
35
|
+
readonly optional: true;
|
|
36
|
+
readonly repeat: true;
|
|
37
|
+
readonly summary: "What to say (default: what is piped in)";
|
|
38
|
+
}];
|
|
39
|
+
readonly options: {
|
|
40
|
+
readonly width: {
|
|
41
|
+
readonly short: "W";
|
|
42
|
+
readonly summary: "Wrap the bubble at N columns (8 or more)";
|
|
43
|
+
readonly value: {
|
|
44
|
+
readonly name: "N";
|
|
45
|
+
readonly kind: "int";
|
|
46
|
+
readonly min: 8;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* `cowthink [-W N] [text]`: the declaration.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* commands_register({ declarations: [cowthinkCommand] });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const cowthinkCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
|
|
60
|
+
readonly operands: readonly [{
|
|
61
|
+
readonly name: "text";
|
|
62
|
+
readonly kind: "word";
|
|
63
|
+
readonly optional: true;
|
|
64
|
+
readonly repeat: true;
|
|
65
|
+
readonly summary: "What to say (default: what is piped in)";
|
|
66
|
+
}];
|
|
67
|
+
readonly options: {
|
|
68
|
+
readonly width: {
|
|
69
|
+
readonly short: "W";
|
|
70
|
+
readonly summary: "Wrap the bubble at N columns (8 or more)";
|
|
71
|
+
readonly value: {
|
|
72
|
+
readonly name: "N";
|
|
73
|
+
readonly kind: "int";
|
|
74
|
+
readonly min: 8;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* Draws the brain saying or thinking the piped text, else the words.
|
|
81
|
+
*
|
|
82
|
+
* @param name - The command's name, for its refusal.
|
|
83
|
+
* @param words - The words given.
|
|
84
|
+
* @param thought - Thought bubble rather than speech.
|
|
85
|
+
* @param width - The wrap width asked for, or undefined for the default.
|
|
86
|
+
* @returns The picture, or a refusal when there is nothing to say.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```ts
|
|
90
|
+
* await cow_run('cowsay', ['moo'], false, 20);
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function cow_run(name: string, words: ReadonlyArray<string>, thought: boolean, width: number | undefined): Promise<CommandEnvelope>;
|
|
94
|
+
/**
|
|
95
|
+
* `cowsay` over words already split: the declaration's parse and handler.
|
|
96
|
+
*
|
|
97
|
+
* @param args - The words after `cowsay`.
|
|
98
|
+
* @returns The picture, or the refusal of a bad line.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* await builtin_cowsay(['-W', '20', 'moo']);
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
24
105
|
export declare function builtin_cowsay(args: string[]): Promise<CommandEnvelope>;
|
|
25
|
-
/**
|
|
106
|
+
/**
|
|
107
|
+
* `cowthink` over words already split: the declaration's parse and handler.
|
|
108
|
+
*
|
|
109
|
+
* @param args - The words after `cowthink`.
|
|
110
|
+
* @returns The picture, or the refusal of a bad line.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* await builtin_cowthink(['hmm']);
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
26
117
|
export declare function builtin_cowthink(args: string[]): Promise<CommandEnvelope>;
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { text_input } from './stdin.js';
|
|
12
12
|
import { envelope_ok, envelope_error } from '@fnndsc/menu';
|
|
13
|
+
import { command_declare } from '../../core/commandDeclaration.js';
|
|
14
|
+
import { declaredCommand_run } from '../../core/commandParse.js';
|
|
13
15
|
/** The brain, as ASCII has long drawn it. */
|
|
14
16
|
export const BRAIN = [
|
|
15
17
|
' _---~~(~~-_.',
|
|
@@ -85,43 +87,100 @@ export function cowsay_render(text, thought = false, width = COWSAY_WIDTH) {
|
|
|
85
87
|
const trail = thought ? [' o', ' o'] : [' \\', ' \\'];
|
|
86
88
|
return [...bubble_draw(lines, thought), ...trail, ...BRAIN].join('\n') + '\n';
|
|
87
89
|
}
|
|
88
|
-
/**
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
90
|
+
/** The words a cow says: what is piped in, else these. */
|
|
91
|
+
const COW_TEXT = { name: 'text', kind: 'word', optional: true, repeat: true, summary: 'What to say (default: what is piped in)' };
|
|
92
|
+
/** What a `cowsay` or `cowthink` line may hold. */
|
|
93
|
+
const COW_GRAMMAR = {
|
|
94
|
+
operands: [COW_TEXT],
|
|
95
|
+
options: {
|
|
96
|
+
width: { short: 'W', summary: 'Wrap the bubble at N columns (8 or more)', value: { name: 'N', kind: 'int', min: 8 } },
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* `cowsay [-W N] [text]`: the declaration.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* commands_register({ declarations: [cowsayCommand] });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export const cowsayCommand = command_declare({
|
|
108
|
+
name: 'cowsay',
|
|
109
|
+
grammar: COW_GRAMMAR,
|
|
110
|
+
help: {
|
|
111
|
+
summary: 'The ChRIS brain says it — fortune | cowsay',
|
|
112
|
+
description: 'The classic, with the ChRIS brain for a cow: a speech bubble over the mascot. Says what is piped in, else the words given; -W N wraps at N columns (40 by default).',
|
|
113
|
+
examples: ['fortune | cowsay', 'cowsay hello, world', 'motd | cowsay -W 60'],
|
|
114
|
+
},
|
|
115
|
+
holds: [],
|
|
116
|
+
handler: async (args) => cow_run('cowsay', args.operands.text, false, args.options.width),
|
|
117
|
+
});
|
|
118
|
+
/**
|
|
119
|
+
* `cowthink [-W N] [text]`: the declaration.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* commands_register({ declarations: [cowthinkCommand] });
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export const cowthinkCommand = command_declare({
|
|
127
|
+
name: 'cowthink',
|
|
128
|
+
grammar: COW_GRAMMAR,
|
|
129
|
+
help: {
|
|
130
|
+
summary: 'The ChRIS brain thinks it',
|
|
131
|
+
description: 'cowsay with a thought bubble.',
|
|
132
|
+
examples: ['fortune | cowthink'],
|
|
133
|
+
},
|
|
134
|
+
holds: [],
|
|
135
|
+
handler: async (args) => cow_run('cowthink', args.operands.text, true, args.options.width),
|
|
136
|
+
});
|
|
137
|
+
/**
|
|
138
|
+
* Draws the brain saying or thinking the piped text, else the words.
|
|
139
|
+
*
|
|
140
|
+
* @param name - The command's name, for its refusal.
|
|
141
|
+
* @param words - The words given.
|
|
142
|
+
* @param thought - Thought bubble rather than speech.
|
|
143
|
+
* @param width - The wrap width asked for, or undefined for the default.
|
|
144
|
+
* @returns The picture, or a refusal when there is nothing to say.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* await cow_run('cowsay', ['moo'], false, 20);
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export async function cow_run(name, words, thought, width) {
|
|
152
|
+
const text = text_input(words);
|
|
114
153
|
if (text === null)
|
|
115
154
|
return envelope_error('', undefined, `${name}: nothing to say (pipe text in, or give it: fortune | ${name})\n`);
|
|
116
155
|
const said = text.replace(/\n$/, '');
|
|
117
|
-
return envelope_ok(cowsay_render(said, thought,
|
|
156
|
+
return envelope_ok(cowsay_render(said, thought, width ?? COWSAY_WIDTH), { kind: 'games.cowsay', data: { text: said, thought } });
|
|
118
157
|
}
|
|
119
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* `cowsay` over words already split: the declaration's parse and handler.
|
|
160
|
+
*
|
|
161
|
+
* @param args - The words after `cowsay`.
|
|
162
|
+
* @returns The picture, or the refusal of a bad line.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```ts
|
|
166
|
+
* await builtin_cowsay(['-W', '20', 'moo']);
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
120
169
|
export async function builtin_cowsay(args) {
|
|
121
|
-
return
|
|
170
|
+
return declaredCommand_run(cowsayCommand, args);
|
|
122
171
|
}
|
|
123
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* `cowthink` over words already split: the declaration's parse and handler.
|
|
174
|
+
*
|
|
175
|
+
* @param args - The words after `cowthink`.
|
|
176
|
+
* @returns The picture, or the refusal of a bad line.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* await builtin_cowthink(['hmm']);
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
124
183
|
export async function builtin_cowthink(args) {
|
|
125
|
-
return
|
|
184
|
+
return declaredCommand_run(cowthinkCommand, args);
|
|
126
185
|
}
|
|
127
186
|
//# sourceMappingURL=cowsay.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cowsay.js","sourceRoot":"","sources":["../../../src/builtins/games/cowsay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAmB,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"cowsay.js","sourceRoot":"","sources":["../../../src/builtins/games/cowsay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,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,6CAA6C;AAC7C,MAAM,CAAC,MAAM,KAAK,GAA0B;IAC1C,sBAAsB;IACtB,uBAAuB;IACvB,0BAA0B;IAC1B,2BAA2B;IAC3B,2BAA2B;IAC3B,4BAA4B;IAC5B,2BAA2B;IAC3B,0BAA0B;IAC1B,yBAAyB;IACzB,wBAAwB;CACzB,CAAC;AAEF,uCAAuC;AACvC,MAAM,CAAC,MAAM,YAAY,GAAW,EAAE,CAAC;AAEvC,+D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Ac;IACnD,OAAO,mBAAmB,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -9,7 +9,75 @@ export declare const FACE_ROWS: number;
|
|
|
9
9
|
* @returns The five rows (more for several lines).
|
|
10
10
|
*/
|
|
11
11
|
export declare function figlet_render(text: string, ink?: string): string[];
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* `figlet [text]`: the declaration.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* commands_register({ declarations: [figletCommand] });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const figletCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
|
|
21
|
+
readonly operands: readonly [{
|
|
22
|
+
readonly name: "text";
|
|
23
|
+
readonly kind: "word";
|
|
24
|
+
readonly optional: true;
|
|
25
|
+
readonly repeat: true;
|
|
26
|
+
readonly summary: "The words to set (default: what is piped in)";
|
|
27
|
+
}];
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* `banner [text]`: the declaration.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* commands_register({ declarations: [bannerCommand] });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare const bannerCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
|
|
38
|
+
readonly operands: readonly [{
|
|
39
|
+
readonly name: "text";
|
|
40
|
+
readonly kind: "word";
|
|
41
|
+
readonly optional: true;
|
|
42
|
+
readonly repeat: true;
|
|
43
|
+
readonly summary: "The words to set (default: what is piped in)";
|
|
44
|
+
}];
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Sets the piped text, else the words, in big letters.
|
|
48
|
+
*
|
|
49
|
+
* @param name - The command's name, for its refusal.
|
|
50
|
+
* @param words - The words given.
|
|
51
|
+
* @param ink - The character to draw with.
|
|
52
|
+
* @returns The big letters, or a refusal when there is nothing to set.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* await big_run('banner', ['hi'], '#');
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function big_run(name: string, words: ReadonlyArray<string>, ink: string): Promise<CommandEnvelope>;
|
|
60
|
+
/**
|
|
61
|
+
* `figlet` over words already split: the declaration's parse and handler.
|
|
62
|
+
*
|
|
63
|
+
* @param args - The words after `figlet`.
|
|
64
|
+
* @returns The big letters, or the refusal of a bad line.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* await builtin_figlet(['LCARS']);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
13
71
|
export declare function builtin_figlet(args: string[]): Promise<CommandEnvelope>;
|
|
14
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* `banner` over words already split: the declaration's parse and handler.
|
|
74
|
+
*
|
|
75
|
+
* @param args - The words after `banner`.
|
|
76
|
+
* @returns The big letters, or the refusal of a bad line.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* await builtin_banner(['ChRIS']);
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
15
83
|
export declare function builtin_banner(args: string[]): Promise<CommandEnvelope>;
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { text_input } from './stdin.js';
|
|
12
12
|
import { envelope_ok, envelope_error } from '@fnndsc/menu';
|
|
13
|
+
import { command_declare } from '../../core/commandDeclaration.js';
|
|
14
|
+
import { declaredCommand_run } from '../../core/commandParse.js';
|
|
13
15
|
/** The face: each glyph five rows, `#` for ink. */
|
|
14
16
|
const FACE = {
|
|
15
17
|
A: [' ### ', '# #', '#####', '# #', '# #'],
|
|
@@ -91,19 +93,94 @@ export function figlet_render(text, ink = '#') {
|
|
|
91
93
|
rows.pop();
|
|
92
94
|
return rows;
|
|
93
95
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
/** The words to set in big letters: what is piped in, else these. */
|
|
97
|
+
const BIG_TEXT = { name: 'text', kind: 'word', optional: true, repeat: true, summary: 'The words to set (default: what is piped in)' };
|
|
98
|
+
/** What a `figlet` or `banner` line may hold. */
|
|
99
|
+
const BIG_GRAMMAR = { operands: [BIG_TEXT] };
|
|
100
|
+
/**
|
|
101
|
+
* `figlet [text]`: the declaration.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* commands_register({ declarations: [figletCommand] });
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export const figletCommand = command_declare({
|
|
109
|
+
name: 'figlet',
|
|
110
|
+
grammar: BIG_GRAMMAR,
|
|
111
|
+
help: {
|
|
112
|
+
summary: 'Big letters, solid',
|
|
113
|
+
description: 'Sets words in a five-row face of solid blocks. Letters, digits and the punctuation a title needs; lowercase is set as capitals. Reads what is piped in, else the words given.',
|
|
114
|
+
examples: ['figlet LCARS', 'date +%H:%M | figlet'],
|
|
115
|
+
},
|
|
116
|
+
holds: [],
|
|
117
|
+
handler: async (args) => big_run('figlet', args.operands.text, '█'),
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* `banner [text]`: the declaration.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* commands_register({ declarations: [bannerCommand] });
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export const bannerCommand = command_declare({
|
|
128
|
+
name: 'banner',
|
|
129
|
+
grammar: BIG_GRAMMAR,
|
|
130
|
+
help: {
|
|
131
|
+
summary: 'Big letters in #, as banner drew them',
|
|
132
|
+
description: 'figlet in the face banner used: # for ink.',
|
|
133
|
+
examples: ['banner ChRIS'],
|
|
134
|
+
},
|
|
135
|
+
holds: [],
|
|
136
|
+
handler: async (args) => big_run('banner', args.operands.text, '#'),
|
|
137
|
+
});
|
|
138
|
+
/**
|
|
139
|
+
* Sets the piped text, else the words, in big letters.
|
|
140
|
+
*
|
|
141
|
+
* @param name - The command's name, for its refusal.
|
|
142
|
+
* @param words - The words given.
|
|
143
|
+
* @param ink - The character to draw with.
|
|
144
|
+
* @returns The big letters, or a refusal when there is nothing to set.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* await big_run('banner', ['hi'], '#');
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export async function big_run(name, words, ink) {
|
|
152
|
+
const text = text_input(words);
|
|
96
153
|
if (text === null)
|
|
97
154
|
return envelope_error('', undefined, `${name}: nothing to set (give words, or pipe them in)\n`);
|
|
98
155
|
const said = text.replace(/\n$/, '');
|
|
99
156
|
return envelope_ok(`${figlet_render(said, ink).join('\n')}\n`, { kind: 'games.figlet', data: { text: said, ink } });
|
|
100
157
|
}
|
|
101
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* `figlet` over words already split: the declaration's parse and handler.
|
|
160
|
+
*
|
|
161
|
+
* @param args - The words after `figlet`.
|
|
162
|
+
* @returns The big letters, or the refusal of a bad line.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```ts
|
|
166
|
+
* await builtin_figlet(['LCARS']);
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
102
169
|
export async function builtin_figlet(args) {
|
|
103
|
-
return
|
|
170
|
+
return declaredCommand_run(figletCommand, args);
|
|
104
171
|
}
|
|
105
|
-
/**
|
|
172
|
+
/**
|
|
173
|
+
* `banner` over words already split: the declaration's parse and handler.
|
|
174
|
+
*
|
|
175
|
+
* @param args - The words after `banner`.
|
|
176
|
+
* @returns The big letters, or the refusal of a bad line.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* await builtin_banner(['ChRIS']);
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
106
183
|
export async function builtin_banner(args) {
|
|
107
|
-
return
|
|
184
|
+
return declaredCommand_run(bannerCommand, args);
|
|
108
185
|
}
|
|
109
186
|
//# sourceMappingURL=figlet.js.map
|