@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.
Files changed (361) hide show
  1. package/dist/buildinfo.json +1 -1
  2. package/dist/builtins/berth/berth.d.ts +90 -3
  3. package/dist/builtins/berth/berth.js +129 -76
  4. package/dist/builtins/berth/berth.js.map +1 -1
  5. package/dist/builtins/berth/berthClose.d.ts +25 -6
  6. package/dist/builtins/berth/berthClose.js +8 -64
  7. package/dist/builtins/berth/berthClose.js.map +1 -1
  8. package/dist/builtins/berth/berthCube.d.ts +3 -2
  9. package/dist/builtins/berth/berthCube.js +9 -16
  10. package/dist/builtins/berth/berthCube.js.map +1 -1
  11. package/dist/builtins/berth/berthProcesses.js +33 -3
  12. package/dist/builtins/berth/berthProcesses.js.map +1 -1
  13. package/dist/builtins/debug.d.ts +24 -3
  14. package/dist/builtins/debug.js +66 -13
  15. package/dist/builtins/debug.js.map +1 -1
  16. package/dist/builtins/fs/acl.args.d.ts +5 -38
  17. package/dist/builtins/fs/acl.args.js +6 -72
  18. package/dist/builtins/fs/acl.args.js.map +1 -1
  19. package/dist/builtins/fs/acl.d.ts +100 -10
  20. package/dist/builtins/fs/acl.js +222 -68
  21. package/dist/builtins/fs/acl.js.map +1 -1
  22. package/dist/builtins/fs/cat.args.d.ts +14 -15
  23. package/dist/builtins/fs/cat.args.js +13 -40
  24. package/dist/builtins/fs/cat.args.js.map +1 -1
  25. package/dist/builtins/fs/cat.d.ts +40 -3
  26. package/dist/builtins/fs/cat.js +92 -13
  27. package/dist/builtins/fs/cat.js.map +1 -1
  28. package/dist/builtins/fs/cd.d.ts +24 -6
  29. package/dist/builtins/fs/cd.js +71 -18
  30. package/dist/builtins/fs/cd.js.map +1 -1
  31. package/dist/builtins/fs/configWrite.d.ts +24 -8
  32. package/dist/builtins/fs/configWrite.js +77 -36
  33. package/dist/builtins/fs/configWrite.js.map +1 -1
  34. package/dist/builtins/fs/cp.d.ts +39 -4
  35. package/dist/builtins/fs/cp.js +122 -56
  36. package/dist/builtins/fs/cp.js.map +1 -1
  37. package/dist/builtins/fs/download.d.ts +31 -4
  38. package/dist/builtins/fs/download.js +75 -38
  39. package/dist/builtins/fs/download.js.map +1 -1
  40. package/dist/builtins/fs/du.d.ts +59 -33
  41. package/dist/builtins/fs/du.js +111 -79
  42. package/dist/builtins/fs/du.js.map +1 -1
  43. package/dist/builtins/fs/edit.d.ts +19 -4
  44. package/dist/builtins/fs/edit.js +77 -16
  45. package/dist/builtins/fs/edit.js.map +1 -1
  46. package/dist/builtins/fs/find.d.ts +25 -0
  47. package/dist/builtins/fs/find.js +76 -5
  48. package/dist/builtins/fs/find.js.map +1 -1
  49. package/dist/builtins/fs/ls.d.ts +69 -4
  50. package/dist/builtins/fs/ls.js +84 -45
  51. package/dist/builtins/fs/ls.js.map +1 -1
  52. package/dist/builtins/fs/mkdir.d.ts +28 -18
  53. package/dist/builtins/fs/mkdir.js +95 -66
  54. package/dist/builtins/fs/mkdir.js.map +1 -1
  55. package/dist/builtins/fs/mv.d.ts +34 -4
  56. package/dist/builtins/fs/mv.js +129 -64
  57. package/dist/builtins/fs/mv.js.map +1 -1
  58. package/dist/builtins/fs/pull.args.d.ts +56 -17
  59. package/dist/builtins/fs/pull.args.js +16 -66
  60. package/dist/builtins/fs/pull.args.js.map +1 -1
  61. package/dist/builtins/fs/pull.d.ts +62 -0
  62. package/dist/builtins/fs/pull.js +123 -31
  63. package/dist/builtins/fs/pull.js.map +1 -1
  64. package/dist/builtins/fs/pwd.d.ts +19 -5
  65. package/dist/builtins/fs/pwd.js +62 -8
  66. package/dist/builtins/fs/pwd.js.map +1 -1
  67. package/dist/builtins/fs/rm.d.ts +58 -21
  68. package/dist/builtins/fs/rm.js +99 -82
  69. package/dist/builtins/fs/rm.js.map +1 -1
  70. package/dist/builtins/fs/rmdir.d.ts +29 -11
  71. package/dist/builtins/fs/rmdir.js +87 -36
  72. package/dist/builtins/fs/rmdir.js.map +1 -1
  73. package/dist/builtins/fs/touch.d.ts +44 -9
  74. package/dist/builtins/fs/touch.js +91 -27
  75. package/dist/builtins/fs/touch.js.map +1 -1
  76. package/dist/builtins/fs/tree.d.ts +36 -9
  77. package/dist/builtins/fs/tree.js +126 -36
  78. package/dist/builtins/fs/tree.js.map +1 -1
  79. package/dist/builtins/fs/upload.d.ts +22 -3
  80. package/dist/builtins/fs/upload.js +82 -14
  81. package/dist/builtins/fs/upload.js.map +1 -1
  82. package/dist/builtins/fs/xattr.args.d.ts +12 -33
  83. package/dist/builtins/fs/xattr.args.js +17 -95
  84. package/dist/builtins/fs/xattr.args.js.map +1 -1
  85. package/dist/builtins/fs/xattr.d.ts +98 -8
  86. package/dist/builtins/fs/xattr.js +163 -24
  87. package/dist/builtins/fs/xattr.js.map +1 -1
  88. package/dist/builtins/games/bytes.d.ts +201 -5
  89. package/dist/builtins/games/bytes.js +255 -54
  90. package/dist/builtins/games/bytes.js.map +1 -1
  91. package/dist/builtins/games/chimes.d.ts +180 -3
  92. package/dist/builtins/games/chimes.js +203 -26
  93. package/dist/builtins/games/chimes.js.map +1 -1
  94. package/dist/builtins/games/chrislab.d.ts +101 -3
  95. package/dist/builtins/games/chrislab.js +117 -17
  96. package/dist/builtins/games/chrislab.js.map +1 -1
  97. package/dist/builtins/games/cowsay.d.ts +93 -2
  98. package/dist/builtins/games/cowsay.js +90 -31
  99. package/dist/builtins/games/cowsay.js.map +1 -1
  100. package/dist/builtins/games/figlet.d.ts +70 -2
  101. package/dist/builtins/games/figlet.js +83 -6
  102. package/dist/builtins/games/figlet.js.map +1 -1
  103. package/dist/builtins/games/lab.d.ts +104 -5
  104. package/dist/builtins/games/lab.js +144 -6
  105. package/dist/builtins/games/lab.js.map +1 -1
  106. package/dist/builtins/games/lolcat.d.ts +61 -1
  107. package/dist/builtins/games/lolcat.js +59 -24
  108. package/dist/builtins/games/lolcat.js.map +1 -1
  109. package/dist/builtins/games/morse.d.ts +36 -1
  110. package/dist/builtins/games/morse.js +50 -2
  111. package/dist/builtins/games/morse.js.map +1 -1
  112. package/dist/builtins/games/numbers.d.ts +241 -5
  113. package/dist/builtins/games/numbers.js +298 -23
  114. package/dist/builtins/games/numbers.js.map +1 -1
  115. package/dist/builtins/games/play.d.ts +96 -6
  116. package/dist/builtins/games/play.js +137 -6
  117. package/dist/builtins/games/play.js.map +1 -1
  118. package/dist/builtins/games/qr.d.ts +40 -1
  119. package/dist/builtins/games/qr.js +51 -2
  120. package/dist/builtins/games/qr.js.map +1 -1
  121. package/dist/builtins/games/show.d.ts +131 -6
  122. package/dist/builtins/games/show.js +208 -20
  123. package/dist/builtins/games/show.js.map +1 -1
  124. package/dist/builtins/games/sky.d.ts +178 -4
  125. package/dist/builtins/games/sky.js +228 -12
  126. package/dist/builtins/games/sky.js.map +1 -1
  127. package/dist/builtins/games/text.d.ts +258 -7
  128. package/dist/builtins/games/text.js +310 -29
  129. package/dist/builtins/games/text.js.map +1 -1
  130. package/dist/builtins/games/trek.d.ts +67 -3
  131. package/dist/builtins/games/trek.js +63 -10
  132. package/dist/builtins/games/trek.js.map +1 -1
  133. package/dist/builtins/games/wtf.d.ts +58 -1
  134. package/dist/builtins/games/wtf.js +67 -6
  135. package/dist/builtins/games/wtf.js.map +1 -1
  136. package/dist/builtins/help.d.ts +41 -3
  137. package/dist/builtins/help.js +92 -796
  138. package/dist/builtins/help.js.map +1 -1
  139. package/dist/builtins/net/connect.d.ts +36 -3
  140. package/dist/builtins/net/connect.js +84 -26
  141. package/dist/builtins/net/connect.js.map +1 -1
  142. package/dist/builtins/net/cubepath.d.ts +49 -5
  143. package/dist/builtins/net/cubepath.js +69 -27
  144. package/dist/builtins/net/cubepath.js.map +1 -1
  145. package/dist/builtins/net/logout.d.ts +13 -4
  146. package/dist/builtins/net/logout.js +49 -3
  147. package/dist/builtins/net/logout.js.map +1 -1
  148. package/dist/builtins/net/netstat.d.ts +29 -4
  149. package/dist/builtins/net/netstat.js +64 -23
  150. package/dist/builtins/net/netstat.js.map +1 -1
  151. package/dist/builtins/net/pacs.d.ts +169 -15
  152. package/dist/builtins/net/pacs.js +92 -33
  153. package/dist/builtins/net/pacs.js.map +1 -1
  154. package/dist/builtins/net/query.args.d.ts +95 -0
  155. package/dist/builtins/net/query.args.js +26 -0
  156. package/dist/builtins/net/query.args.js.map +1 -0
  157. package/dist/builtins/net/query.d.ts +98 -5
  158. package/dist/builtins/net/query.js +89 -83
  159. package/dist/builtins/net/query.js.map +1 -1
  160. package/dist/builtins/net/status.d.ts +5 -3
  161. package/dist/builtins/net/status.js +5 -12
  162. package/dist/builtins/net/status.js.map +1 -1
  163. package/dist/builtins/parametersofplugin.d.ts +82 -3
  164. package/dist/builtins/parametersofplugin.js +79 -23
  165. package/dist/builtins/parametersofplugin.js.map +1 -1
  166. package/dist/builtins/proc.d.ts +210 -3
  167. package/dist/builtins/proc.js +210 -119
  168. package/dist/builtins/proc.js.map +1 -1
  169. package/dist/builtins/res/compute.d.ts +67 -3
  170. package/dist/builtins/res/compute.js +121 -35
  171. package/dist/builtins/res/compute.js.map +1 -1
  172. package/dist/builtins/res/dicom.d.ts +55 -7
  173. package/dist/builtins/res/dicom.js +86 -52
  174. package/dist/builtins/res/dicom.js.map +1 -1
  175. package/dist/builtins/res/expect.d.ts +52 -3
  176. package/dist/builtins/res/expect.js +92 -29
  177. package/dist/builtins/res/expect.js.map +1 -1
  178. package/dist/builtins/res/feed.d.ts +475 -3
  179. package/dist/builtins/res/feed.js +253 -158
  180. package/dist/builtins/res/feed.js.map +1 -1
  181. package/dist/builtins/res/files.d.ts +517 -3
  182. package/dist/builtins/res/files.js +124 -44
  183. package/dist/builtins/res/files.js.map +1 -1
  184. package/dist/builtins/res/gather.d.ts +113 -3
  185. package/dist/builtins/res/gather.js +153 -44
  186. package/dist/builtins/res/gather.js.map +1 -1
  187. package/dist/builtins/res/gather.process.d.ts +27 -19
  188. package/dist/builtins/res/gather.process.js +29 -59
  189. package/dist/builtins/res/gather.process.js.map +1 -1
  190. package/dist/builtins/res/group.d.ts +284 -3
  191. package/dist/builtins/res/group.js +147 -76
  192. package/dist/builtins/res/group.js.map +1 -1
  193. package/dist/builtins/res/image.d.ts +30 -2
  194. package/dist/builtins/res/image.js +62 -10
  195. package/dist/builtins/res/image.js.map +1 -1
  196. package/dist/builtins/res/play.d.ts +71 -9
  197. package/dist/builtins/res/play.js +124 -82
  198. package/dist/builtins/res/play.js.map +1 -1
  199. package/dist/builtins/res/plugininstance.d.ts +307 -2
  200. package/dist/builtins/res/plugininstance.js +122 -50
  201. package/dist/builtins/res/plugininstance.js.map +1 -1
  202. package/dist/builtins/res/pluginmeta.d.ts +244 -2
  203. package/dist/builtins/res/pluginmeta.js +98 -40
  204. package/dist/builtins/res/pluginmeta.js.map +1 -1
  205. package/dist/builtins/res/record.d.ts +37 -3
  206. package/dist/builtins/res/record.js +127 -57
  207. package/dist/builtins/res/record.js.map +1 -1
  208. package/dist/builtins/res/resourceList.d.ts +136 -0
  209. package/dist/builtins/res/resourceList.js +51 -0
  210. package/dist/builtins/res/resourceList.js.map +1 -0
  211. package/dist/builtins/res/tag.d.ts +244 -3
  212. package/dist/builtins/res/tag.js +97 -41
  213. package/dist/builtins/res/tag.js.map +1 -1
  214. package/dist/builtins/res/user.d.ts +122 -3
  215. package/dist/builtins/res/user.js +83 -21
  216. package/dist/builtins/res/user.js.map +1 -1
  217. package/dist/builtins/res/workflow.d.ts +244 -2
  218. package/dist/builtins/res/workflow.js +97 -40
  219. package/dist/builtins/res/workflow.js.map +1 -1
  220. package/dist/builtins/store.d.ts +85 -3
  221. package/dist/builtins/store.js +135 -68
  222. package/dist/builtins/store.js.map +1 -1
  223. package/dist/builtins/sys/apropos.d.ts +80 -5
  224. package/dist/builtins/sys/apropos.js +121 -15
  225. package/dist/builtins/sys/apropos.js.map +1 -1
  226. package/dist/builtins/sys/cal.d.ts +44 -5
  227. package/dist/builtins/sys/cal.js +57 -10
  228. package/dist/builtins/sys/cal.js.map +1 -1
  229. package/dist/builtins/sys/command.d.ts +20 -0
  230. package/dist/builtins/sys/command.js +31 -0
  231. package/dist/builtins/sys/command.js.map +1 -1
  232. package/dist/builtins/sys/context.d.ts +13 -3
  233. package/dist/builtins/sys/context.js +51 -4
  234. package/dist/builtins/sys/context.js.map +1 -1
  235. package/dist/builtins/sys/date.d.ts +56 -5
  236. package/dist/builtins/sys/date.js +63 -9
  237. package/dist/builtins/sys/date.js.map +1 -1
  238. package/dist/builtins/sys/echo.d.ts +63 -2
  239. package/dist/builtins/sys/echo.js +87 -8
  240. package/dist/builtins/sys/echo.js.map +1 -1
  241. package/dist/builtins/sys/fortune.d.ts +27 -2
  242. package/dist/builtins/sys/fortune.js +44 -2
  243. package/dist/builtins/sys/fortune.js.map +1 -1
  244. package/dist/builtins/sys/grep.d.ts +245 -11
  245. package/dist/builtins/sys/grep.js +418 -131
  246. package/dist/builtins/sys/grep.js.map +1 -1
  247. package/dist/builtins/sys/joblets.d.ts +66 -7
  248. package/dist/builtins/sys/joblets.js +101 -14
  249. package/dist/builtins/sys/joblets.js.map +1 -1
  250. package/dist/builtins/sys/motd.d.ts +37 -3
  251. package/dist/builtins/sys/motd.js +49 -8
  252. package/dist/builtins/sys/motd.js.map +1 -1
  253. package/dist/builtins/sys/notes.d.ts +75 -3
  254. package/dist/builtins/sys/notes.js +90 -29
  255. package/dist/builtins/sys/notes.js.map +1 -1
  256. package/dist/builtins/sys/physicalmode.d.ts +24 -3
  257. package/dist/builtins/sys/physicalmode.js +68 -14
  258. package/dist/builtins/sys/physicalmode.js.map +1 -1
  259. package/dist/builtins/sys/tasks.d.ts +74 -5
  260. package/dist/builtins/sys/tasks.js +102 -14
  261. package/dist/builtins/sys/tasks.js.map +1 -1
  262. package/dist/builtins/sys/textFilters.d.ts +673 -41
  263. package/dist/builtins/sys/textFilters.js +719 -264
  264. package/dist/builtins/sys/textFilters.js.map +1 -1
  265. package/dist/builtins/sys/timing.d.ts +24 -3
  266. package/dist/builtins/sys/timing.js +67 -14
  267. package/dist/builtins/sys/timing.js.map +1 -1
  268. package/dist/builtins/sys/variables.d.ts +70 -4
  269. package/dist/builtins/sys/variables.js +103 -31
  270. package/dist/builtins/sys/variables.js.map +1 -1
  271. package/dist/builtins/sys/version.d.ts +27 -2
  272. package/dist/builtins/sys/version.js +48 -3
  273. package/dist/builtins/sys/version.js.map +1 -1
  274. package/dist/builtins/sys/weather.d.ts +92 -15
  275. package/dist/builtins/sys/weather.js +71 -45
  276. package/dist/builtins/sys/weather.js.map +1 -1
  277. package/dist/builtins/sys/whoami.d.ts +38 -18
  278. package/dist/builtins/sys/whoami.js +112 -8
  279. package/dist/builtins/sys/whoami.js.map +1 -1
  280. package/dist/builtins/utils.d.ts +1 -38
  281. package/dist/builtins/utils.js +1 -87
  282. package/dist/builtins/utils.js.map +1 -1
  283. package/dist/chris/backend.js +2 -0
  284. package/dist/chris/backend.js.map +1 -1
  285. package/dist/chris/chrisCommands.js +62 -159
  286. package/dist/chris/chrisCommands.js.map +1 -1
  287. package/dist/chris/commandFallback.d.ts +12 -0
  288. package/dist/chris/commandFallback.js +47 -0
  289. package/dist/chris/commandFallback.js.map +1 -1
  290. package/dist/chris/files.js +24 -85
  291. package/dist/chris/files.js.map +1 -1
  292. package/dist/chris/filesystem.js +7 -5
  293. package/dist/chris/filesystem.js.map +1 -1
  294. package/dist/chris/help.js +0 -1082
  295. package/dist/chris/help.js.map +1 -1
  296. package/dist/chris/kinds.d.ts +30 -0
  297. package/dist/chris/kinds.js +154 -0
  298. package/dist/chris/kinds.js.map +1 -0
  299. package/dist/chris/mounts.d.ts +4 -4
  300. package/dist/chris/mounts.js +9 -16
  301. package/dist/chris/mounts.js.map +1 -1
  302. package/dist/chris/navigation.d.ts +2 -3
  303. package/dist/chris/navigation.js +6 -20
  304. package/dist/chris/navigation.js.map +1 -1
  305. package/dist/chris/pacsResources.d.ts +259 -0
  306. package/dist/chris/pacsResources.js +168 -0
  307. package/dist/chris/pacsResources.js.map +1 -0
  308. package/dist/chris/promptContext.d.ts +6 -0
  309. package/dist/chris/promptContext.js +3 -1
  310. package/dist/chris/promptContext.js.map +1 -1
  311. package/dist/core/argumentKinds.d.ts +107 -0
  312. package/dist/core/argumentKinds.js +223 -0
  313. package/dist/core/argumentKinds.js.map +1 -0
  314. package/dist/core/backend.d.ts +4 -1
  315. package/dist/core/backend.js.map +1 -1
  316. package/dist/core/commandDeclaration.d.ts +453 -0
  317. package/dist/core/commandDeclaration.js +52 -0
  318. package/dist/core/commandDeclaration.js.map +1 -0
  319. package/dist/core/commandParse.d.ts +64 -0
  320. package/dist/core/commandParse.js +468 -0
  321. package/dist/core/commandParse.js.map +1 -0
  322. package/dist/core/commandRegistry.d.ts +37 -0
  323. package/dist/core/commandRegistry.js +100 -3
  324. package/dist/core/commandRegistry.js.map +1 -1
  325. package/dist/core/commandSchema.d.ts +32 -0
  326. package/dist/core/commandSchema.js +117 -0
  327. package/dist/core/commandSchema.js.map +1 -0
  328. package/dist/core/commandUsage.d.ts +62 -0
  329. package/dist/core/commandUsage.js +247 -0
  330. package/dist/core/commandUsage.js.map +1 -0
  331. package/dist/core/coreCommands.js +66 -214
  332. package/dist/core/coreCommands.js.map +1 -1
  333. package/dist/core/dispatch.js +15 -8
  334. package/dist/core/dispatch.js.map +1 -1
  335. package/dist/core/paths.d.ts +51 -0
  336. package/dist/core/paths.js +86 -2
  337. package/dist/core/paths.js.map +1 -1
  338. package/dist/core/preprocess.d.ts +10 -9
  339. package/dist/core/preprocess.js +10 -20
  340. package/dist/core/preprocess.js.map +1 -1
  341. package/dist/core/warmupFailures.d.ts +34 -2
  342. package/dist/core/warmupFailures.js +43 -2
  343. package/dist/core/warmupFailures.js.map +1 -1
  344. package/dist/lib/completer/cfsPaths.d.ts +14 -0
  345. package/dist/lib/completer/cfsPaths.js +91 -0
  346. package/dist/lib/completer/cfsPaths.js.map +1 -0
  347. package/dist/lib/completer/declared.d.ts +15 -0
  348. package/dist/lib/completer/declared.js +189 -0
  349. package/dist/lib/completer/declared.js.map +1 -0
  350. package/dist/lib/completer/index.js +33 -79
  351. package/dist/lib/completer/index.js.map +1 -1
  352. package/dist/lib/parser.d.ts +5 -8
  353. package/dist/lib/parser.js +2 -11
  354. package/dist/lib/parser.js.map +1 -1
  355. package/dist/lib/vfs/vfs.d.ts +2 -1
  356. package/dist/lib/vfs/vfs.js +9 -6
  357. package/dist/lib/vfs/vfs.js.map +1 -1
  358. package/dist/lib/wildcard.js +2 -3
  359. package/dist/lib/wildcard.js.map +1 -1
  360. package/dist/notes.json +1 -1
  361. package/package.json +6 -5
@@ -0,0 +1,468 @@
1
+ /**
2
+ * @file Parses a declared command's line against its grammar, and runs it.
3
+ *
4
+ * The words reach here with references already expanded. Then, in order:
5
+ * 1. The line's shape is parsed, GNU `getopt_long` for every command: `-f`,
6
+ * bundled short switches (`-rf`), `--force`; `--name x` and `--name=x`;
7
+ * `--` ends the options; options may stand anywhere among the operands;
8
+ * a word like `-3` is an operand when an operand of the line is numeric,
9
+ * or the value of the option that says `numeral` (`head -3`); a value
10
+ * that may be left out (`--highlight[=lang]`) is only in its own word;
11
+ * a value option that `asks`, given no value, is a question (null).
12
+ * Subcommand words and option names are literal and never globbed.
13
+ * 2. Operands expand by kind: only a path operand that declares `glob` has
14
+ * its wildcards matched.
15
+ * 3. Values are checked by kind.
16
+ * A line that fails a step is refused in plain words, with the usage, before
17
+ * the handler runs.
18
+ *
19
+ * Key components:
20
+ * - commandLine_parse: a line's words to the typed object a handler reads.
21
+ * - declaredCommand_run: parses and runs, refusing a bad line.
22
+ * - declaredHandler_make: the registry's handler for a declared command.
23
+ *
24
+ * Typical usage:
25
+ * ```ts
26
+ * const parsed: LineParse = await commandLine_parse(lsCommand, shellWords_tokenize('-l docs'));
27
+ * const envelope: CommandEnvelope = await declaredCommand_run(lsCommand, ['-l', 'docs']);
28
+ * ```
29
+ *
30
+ * Dependencies: the argument kinds (each a value check and a pathname
31
+ * expansion), the usage renderer, and the shell words' quoting.
32
+ *
33
+ * @module
34
+ */
35
+ import chalk from 'chalk';
36
+ import { envelope_error } from '@fnndsc/menu';
37
+ import { argumentKind_get, argumentWord_check } from './argumentKinds.js';
38
+ import { commandUsage_render } from './commandUsage.js';
39
+ import { exitCode_set } from './handlerRun.js';
40
+ /** A word that reads as a negative number. */
41
+ const NEGATIVE_NUMBER = /^-\d+(?:\.\d+)?$/;
42
+ /** A dash and digits: an option that says `numeral` with that value (`head -5`). */
43
+ const DASH_DIGITS = /^-\d+$/;
44
+ /** A refusal raised while a line is parsed: its words, after `<command>: `. */
45
+ class LineRefusal extends Error {
46
+ /** The subcommand the line chose by then, for the usage that follows. */
47
+ subcommand;
48
+ /**
49
+ * @param message - What was wrong.
50
+ * @param subcommand - The subcommand chosen, if one was.
51
+ */
52
+ constructor(message, subcommand) {
53
+ super(message);
54
+ this.subcommand = subcommand;
55
+ }
56
+ }
57
+ /**
58
+ * The options in reach once a subcommand is chosen, or none is: its own (the
59
+ * bare command's for none), then the command's.
60
+ *
61
+ * @param grammar - The command's grammar.
62
+ * @param subcommand - The subcommand's grammar, or null for the bare command.
63
+ * @returns The options.
64
+ */
65
+ function optionEntries_list(grammar, subcommand) {
66
+ const own = subcommand === null ? (grammar.bare?.options ?? {}) : (subcommand.options ?? {});
67
+ const command = grammar.options ?? {};
68
+ return [...Object.entries(own), ...Object.entries(command)]
69
+ .map(([key, option]) => ({ key, option }));
70
+ }
71
+ /**
72
+ * Whether any operand in reach is numeric, so a negative number is one.
73
+ *
74
+ * @param operands - The operands.
75
+ * @returns True when one is.
76
+ */
77
+ function operands_takeNumbers(operands) {
78
+ return operands.some((operand) => argumentKind_get(operand.kind)?.numeric === true);
79
+ }
80
+ /**
81
+ * Records one option's value: a switch is set; a value is kept with any before it.
82
+ *
83
+ * @param options - The options so far.
84
+ * @param entry - The option.
85
+ * @param value - Its value, or null for a switch.
86
+ */
87
+ function option_record(options, entry, value) {
88
+ if (value === null) {
89
+ options.set(entry.key, true);
90
+ return;
91
+ }
92
+ const held = options.get(entry.key);
93
+ options.set(entry.key, [...(Array.isArray(held) ? held : []), value]);
94
+ }
95
+ /**
96
+ * Whether a value option stands with no value: nothing follows it, or, for
97
+ * one that asks, another option does.
98
+ *
99
+ * @param option - The option.
100
+ * @param next - The word after it, if any.
101
+ * @returns True when it has no value.
102
+ */
103
+ function value_isAbsent(option, next) {
104
+ if (next === undefined)
105
+ return true;
106
+ return option.asks === true && next.value.startsWith('-') && next.value.length > 1;
107
+ }
108
+ /**
109
+ * Reads one long option word, `--name` or `--name=value`, taking its value
110
+ * from the next word when it wants one.
111
+ *
112
+ * @param words - The line's words.
113
+ * @param at - Where the option stands.
114
+ * @param walk - Where the parse stands.
115
+ * @param options - The options so far.
116
+ * @returns Where the next word stands.
117
+ * @throws {LineRefusal} For an unknown option, a missing value, or a value given to a switch.
118
+ */
119
+ function longOption_read(words, at, walk, options) {
120
+ const text = words[at].value.slice(2);
121
+ const equals = text.indexOf('=');
122
+ const name = equals === -1 ? text : text.slice(0, equals);
123
+ const inline = equals === -1 ? null : text.slice(equals + 1);
124
+ const entry = walk.entries.find((one) => one.option.long === name);
125
+ if (entry === undefined)
126
+ throw new LineRefusal(`unrecognized option '--${name}'`, walk.subcommand);
127
+ if (entry.option.value === undefined) {
128
+ if (inline !== null)
129
+ throw new LineRefusal(`option '--${name}' takes no value`, walk.subcommand);
130
+ option_record(options, entry, null);
131
+ return at + 1;
132
+ }
133
+ if (inline !== null || entry.option.value.optional === true) {
134
+ // An optional value is only ever in the option's own word.
135
+ option_record(options, entry, inline ?? '');
136
+ return at + 1;
137
+ }
138
+ const next = words[at + 1];
139
+ if (value_isAbsent(entry.option, next)) {
140
+ if (entry.option.asks !== true)
141
+ throw new LineRefusal(`option '--${name}' wants a value (<${entry.option.value.name}>)`, walk.subcommand);
142
+ options.set(entry.key, null);
143
+ return at + 1;
144
+ }
145
+ option_record(options, entry, next.value);
146
+ return at + 2;
147
+ }
148
+ /**
149
+ * Reads one word of short options, `-l` or bundled `-rf`; an option that
150
+ * takes a value takes the rest of the word, or the next word.
151
+ *
152
+ * @param words - The line's words.
153
+ * @param at - Where the word stands.
154
+ * @param walk - Where the parse stands.
155
+ * @param options - The options so far.
156
+ * @returns Where the next word stands.
157
+ * @throws {LineRefusal} For an unknown option or a missing value.
158
+ */
159
+ function shortOptions_read(words, at, walk, options) {
160
+ const text = words[at].value;
161
+ for (let index = 1; index < text.length; index += 1) {
162
+ const letter = text[index];
163
+ const entry = walk.entries.find((one) => one.option.short === letter);
164
+ if (entry === undefined)
165
+ throw new LineRefusal(`invalid option -- '${letter}'`, walk.subcommand);
166
+ if (entry.option.value === undefined) {
167
+ option_record(options, entry, null);
168
+ continue;
169
+ }
170
+ const rest = text.slice(index + 1);
171
+ if (rest !== '' || entry.option.value.optional === true) {
172
+ option_record(options, entry, rest);
173
+ return at + 1;
174
+ }
175
+ const next = words[at + 1];
176
+ if (value_isAbsent(entry.option, next)) {
177
+ if (entry.option.asks !== true)
178
+ throw new LineRefusal(`option '-${letter}' wants a value (<${entry.option.value.name}>)`, walk.subcommand);
179
+ options.set(entry.key, null);
180
+ return at + 1;
181
+ }
182
+ option_record(options, entry, next.value);
183
+ return at + 2;
184
+ }
185
+ return at + 1;
186
+ }
187
+ /**
188
+ * Takes a word that is not an option: the subcommand, when the line has
189
+ * none yet and the grammar has them; otherwise an operand.
190
+ *
191
+ * @param grammar - The command's grammar.
192
+ * @param word - The word.
193
+ * @param walk - Where the parse stands.
194
+ * @param operands - The operands so far.
195
+ * @param options - The options so far, which a chosen subcommand must take.
196
+ * @throws {LineRefusal} For a word that names no subcommand of a command that takes no bare operand, or a subcommand that does not take an option given before it.
197
+ */
198
+ function plainWord_take(grammar, word, walk, operands, options) {
199
+ const subcommands = grammar.subcommands;
200
+ if (subcommands !== undefined && walk.subcommand === null && operands.length === 0 && !walk.optionsEnded) {
201
+ const chosen = Object.hasOwn(subcommands, word.value) ? subcommands[word.value] : undefined;
202
+ if (chosen !== undefined) {
203
+ const entries = optionEntries_list(grammar, chosen);
204
+ // An option the bare command takes, given before a subcommand that does not take it, is refused, not dropped.
205
+ for (const key of options.keys()) {
206
+ if (entries.some((entry) => entry.key === key))
207
+ continue;
208
+ const given = walk.entries.find((entry) => entry.key === key)?.option;
209
+ const name = given?.long !== undefined ? `--${given.long}` : `-${given?.short ?? key}`;
210
+ throw new LineRefusal(`option '${name}' is not one ${word.value} takes`, word.value);
211
+ }
212
+ walk.subcommand = word.value;
213
+ walk.scope = chosen;
214
+ walk.entries = entries;
215
+ return;
216
+ }
217
+ if ((grammar.operands ?? []).length === 0) {
218
+ throw new LineRefusal(`unknown subcommand '${word.value}' (${Object.keys(subcommands).join(', ')})`, null);
219
+ }
220
+ }
221
+ operands.push(word);
222
+ }
223
+ /**
224
+ * Parses a line's shape: which subcommand, which options with which values,
225
+ * and which words are operands.
226
+ *
227
+ * @param grammar - The command's grammar.
228
+ * @param words - The words after the command.
229
+ * @returns The shape.
230
+ * @throws {LineRefusal} For an unknown option, a missing value, or an unknown subcommand.
231
+ */
232
+ function lineShape_parse(grammar, words) {
233
+ const walk = { subcommand: null, scope: null, entries: optionEntries_list(grammar, null), optionsEnded: false };
234
+ const options = new Map();
235
+ const operands = [];
236
+ let at = 0;
237
+ while (at < words.length) {
238
+ const word = words[at];
239
+ const text = word.value;
240
+ const reach = walk.scope?.operands ?? grammar.operands ?? [];
241
+ if (walk.optionsEnded) {
242
+ plainWord_take(grammar, word, walk, operands, options);
243
+ at += 1;
244
+ }
245
+ else if (text === '--') {
246
+ walk.optionsEnded = true;
247
+ at += 1;
248
+ }
249
+ else if (text.startsWith('--')) {
250
+ at = longOption_read(words, at, walk, options);
251
+ }
252
+ else if (DASH_DIGITS.test(text) && walk.entries.some((entry) => entry.option.numeral === true)) {
253
+ option_record(options, walk.entries.find((entry) => entry.option.numeral === true), text.slice(1));
254
+ at += 1;
255
+ }
256
+ else if (text.startsWith('-') && text.length > 1 && !(NEGATIVE_NUMBER.test(text) && operands_takeNumbers(reach))) {
257
+ at = shortOptions_read(words, at, walk, options);
258
+ }
259
+ else {
260
+ plainWord_take(grammar, word, walk, operands, options);
261
+ at += 1;
262
+ }
263
+ }
264
+ if (grammar.subcommands !== undefined && walk.subcommand === null && grammar.bare === undefined && (grammar.operands ?? []).length === 0) {
265
+ throw new LineRefusal(`missing subcommand (${Object.keys(grammar.subcommands).join(', ')})`, null);
266
+ }
267
+ return { subcommand: walk.subcommand, options, operands };
268
+ }
269
+ /**
270
+ * Hands the operand words to the operands, in order: each required operand
271
+ * one word, each optional one a word while words are left over, and the one
272
+ * that repeats every word left after that.
273
+ *
274
+ * @param operands - The operands, in order.
275
+ * @param words - The operand words.
276
+ * @param subcommand - The subcommand, for a refusal.
277
+ * @returns Each operand's words, by name.
278
+ * @throws {LineRefusal} For too few words, or too many.
279
+ */
280
+ function operandWords_assign(operands, words, subcommand) {
281
+ const required = operands.filter((operand) => operand.optional !== true).length;
282
+ if (words.length < required) {
283
+ const missing = operands.filter((operand) => operand.optional !== true)[words.length];
284
+ throw new LineRefusal(`missing operand <${missing?.name ?? 'operand'}>`, subcommand);
285
+ }
286
+ let spare = words.length - required;
287
+ let at = 0;
288
+ const assigned = new Map();
289
+ for (const operand of operands) {
290
+ let take = operand.optional === true ? 0 : 1;
291
+ if (operand.repeat === true) {
292
+ take += spare;
293
+ spare = 0;
294
+ }
295
+ else if (operand.optional === true && spare > 0) {
296
+ take = 1;
297
+ spare -= 1;
298
+ }
299
+ assigned.set(operand.name, words.slice(at, at + take));
300
+ at += take;
301
+ }
302
+ const extra = words[at];
303
+ if (extra !== undefined)
304
+ throw new LineRefusal(`unexpected operand '${extra.value}'`, subcommand);
305
+ return assigned;
306
+ }
307
+ /**
308
+ * Expands one operand's words by its kind: a path operand that declares
309
+ * `glob` has its wildcards matched; every other word stands as written.
310
+ *
311
+ * @param operand - The operand.
312
+ * @param words - Its words.
313
+ * @param subcommand - The subcommand, for a refusal.
314
+ * @returns Its words after expansion, and whether any came from it.
315
+ * @throws {LineRefusal} When the expansion fails, or gives one-word operand several words.
316
+ */
317
+ async function operandWords_expand(operand, words, subcommand) {
318
+ const kind = argumentKind_get(operand.kind);
319
+ if (operand.glob !== true || kind?.words_expand === undefined || !words.some((word) => word.pathnameExpansion)) {
320
+ return { words, expanded: false };
321
+ }
322
+ const result = await kind.words_expand(words);
323
+ if (!result.ok)
324
+ throw new LineRefusal(result.reason, subcommand);
325
+ if (operand.repeat !== true && result.words.length > 1) {
326
+ throw new LineRefusal(`<${operand.name}> takes one path; '${words[0]?.value ?? ''}' matches ${result.words.length}`, subcommand);
327
+ }
328
+ return { words: result.words, expanded: result.words.some((word) => word.pathnameExpanded) };
329
+ }
330
+ /**
331
+ * Checks one word against its argument, refusing it in the line's words.
332
+ *
333
+ * @param argument - The argument.
334
+ * @param word - The word.
335
+ * @param where - The argument as the refusal names it (`<path>`, `'--sort'`).
336
+ * @param subcommand - The subcommand, for a refusal.
337
+ * @returns The value.
338
+ * @throws {LineRefusal} When the word is not one of the kind.
339
+ */
340
+ function word_check(argument, word, where, subcommand) {
341
+ const checked = argumentWord_check(argument, word);
342
+ if (!checked.ok)
343
+ throw new LineRefusal(`invalid argument '${word}' for ${where} (${checked.reason})`, subcommand);
344
+ return checked.value;
345
+ }
346
+ /**
347
+ * The options' values, checked: a switch true or false, a value option its
348
+ * last value (or every value when it repeats), absent as undefined (or none).
349
+ *
350
+ * @param entries - The options in reach.
351
+ * @param given - What the line gave.
352
+ * @param subcommand - The subcommand, for a refusal.
353
+ * @returns The values, by property.
354
+ * @throws {LineRefusal} For a value not of its kind.
355
+ */
356
+ function optionValues_check(entries, given, subcommand) {
357
+ const values = {};
358
+ for (const { key, option } of entries) {
359
+ const held = given.get(key);
360
+ if (option.value === undefined) {
361
+ values[key] = held === true;
362
+ continue;
363
+ }
364
+ if (held === null) {
365
+ values[key] = option.repeat === true ? [] : null;
366
+ continue;
367
+ }
368
+ const where = option.long !== undefined ? `'--${option.long}'` : `'-${option.short ?? ''}'`;
369
+ const checked = (Array.isArray(held) ? held : []).map((word) => word_check(option.value, word, where, subcommand));
370
+ values[key] = option.repeat === true ? checked : checked.at(-1);
371
+ }
372
+ return values;
373
+ }
374
+ /**
375
+ * Parses a declared command's line into the object its handler reads.
376
+ *
377
+ * @param declaration - The command.
378
+ * @param words - The words after the command, references expanded, quoting kept.
379
+ * @returns The handler's argument, or the refusal (`ls: unrecognized option '--x'; usage: …`).
380
+ *
381
+ * @example
382
+ * ```ts
383
+ * const parsed: LineParse = await commandLine_parse(lsCommand, [shellWord_literal('-l')]);
384
+ * if (parsed.ok) parsed.args.options['long']; // true
385
+ * ```
386
+ */
387
+ export async function commandLine_parse(declaration, words) {
388
+ const grammar = declaration.grammar;
389
+ try {
390
+ const shape = lineShape_parse(grammar, words);
391
+ const scope = shape.subcommand === null ? null : (grammar.subcommands?.[shape.subcommand] ?? null);
392
+ // An operand that stands only without an option is gone when the option is given.
393
+ const operandGrammars = (scope !== null ? (scope.operands ?? []) : (grammar.operands ?? []))
394
+ .filter((operand) => operand.unless === undefined || !shape.options.has(operand.unless));
395
+ const assigned = operandWords_assign(operandGrammars, shape.operands, shape.subcommand);
396
+ const operands = {};
397
+ const expanded = {};
398
+ for (const operand of operandGrammars) {
399
+ const own = await operandWords_expand(operand, assigned.get(operand.name) ?? [], shape.subcommand);
400
+ if (operand.glob === true)
401
+ expanded[operand.name] = own.expanded;
402
+ const values = own.words.map((word) => word_check(operand, word.value, `<${operand.name}>`, shape.subcommand));
403
+ operands[operand.name] = operand.repeat === true ? values : values[0];
404
+ }
405
+ const options = optionValues_check(optionEntries_list(grammar, scope), shape.options, shape.subcommand);
406
+ return { ok: true, args: { subcommand: shape.subcommand, operands, options, expanded } };
407
+ }
408
+ catch (error) {
409
+ if (!(error instanceof LineRefusal))
410
+ throw error;
411
+ const where = error.subcommand === null ? declaration.name : `${declaration.name}: ${error.subcommand}`;
412
+ return { ok: false, refusal: `${where}: ${error.message}; usage: ${commandUsage_render(declaration, error.subcommand)}` };
413
+ }
414
+ }
415
+ /**
416
+ * Words as a line hands them on: the shell words the line carried, quoting
417
+ * kept, when they came with it; otherwise each string as a literal word,
418
+ * which globs nothing (a caller that split its own words expands nothing).
419
+ *
420
+ * @param args - The arguments.
421
+ * @returns The words.
422
+ */
423
+ function argumentWords_read(args) {
424
+ const carried = args.words;
425
+ if (carried !== undefined && carried.length === args.length)
426
+ return [...carried];
427
+ return args.map((value) => ({ value, globPattern: value.replace(/[\\*?[\]]/g, '\\$&'), pathnameExpansion: false, pathnameExpanded: false }));
428
+ }
429
+ /**
430
+ * Parses a line against its declaration and runs the handler on it; a bad
431
+ * line is refused on the error channel, the handler never called.
432
+ *
433
+ * @param declaration - The command.
434
+ * @param args - The words after the command.
435
+ * @returns The handler's envelope, or the refusal's.
436
+ *
437
+ * @example
438
+ * ```ts
439
+ * await declaredCommand_run(lsCommand, ['--nosuch']); // renderedErr: "ls: unrecognized option '--nosuch'; usage: …"
440
+ * ```
441
+ */
442
+ export async function declaredCommand_run(declaration, args) {
443
+ const parsed = await commandLine_parse(declaration, argumentWords_read(args));
444
+ if (!parsed.ok) {
445
+ exitCode_set(1);
446
+ return envelope_error('', undefined, `${chalk.red(parsed.refusal)}\n`);
447
+ }
448
+ // The grammar's types are put on the object here, the one place the
449
+ // parse meets them: the parse built it from that same grammar.
450
+ return declaration.handler(parsed.args);
451
+ }
452
+ /**
453
+ * The registry's handler for a declared command: the words a line hands
454
+ * on, parsed against the declaration.
455
+ *
456
+ * @param declaration - The command.
457
+ * @returns The handler.
458
+ *
459
+ * @example
460
+ * ```ts
461
+ * const handler = declaredHandler_make(lsCommand);
462
+ * await handler(['-l']);
463
+ * ```
464
+ */
465
+ export function declaredHandler_make(declaration) {
466
+ return (args) => declaredCommand_run(declaration, args);
467
+ }
468
+ //# sourceMappingURL=commandParse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandParse.js","sourceRoot":"","sources":["../../src/core/commandParse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AM,CAAC,IAAwC,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,oBAAoB,CAAC,WAA+B;IAClE,OAAO,CAAC,IAAc,EAA4B,EAAE,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;AAC9F,CAAC"}
@@ -14,6 +14,13 @@
14
14
  * builtin too; that is how the tables behaved, and changing it is a decision of
15
15
  * its own, not a side effect of moving the lookup here.
16
16
  *
17
+ * A command may instead register its declaration (`commandDeclaration.ts`):
18
+ * one record holding its grammar, kinds, handler, holds and help prose. The
19
+ * registry answers its name with a handler that parses the line against the
20
+ * grammar first, and its help is generated from the same record, so help and
21
+ * behaviour cannot drift apart. Completion and the tool schema read the
22
+ * declaration itself (`commandDeclaration_get`).
23
+ *
17
24
  * Listing order is kept explicitly (`commandOrder_set`), apart from which
18
25
  * group registered a name, so the core's and a backend's commands registering
19
26
  * separately do not reorder what the shell offers; an unlisted name lists
@@ -23,6 +30,7 @@
23
30
  * @module
24
31
  */
25
32
  import type { CommandEnvelope } from '@fnndsc/menu';
33
+ import { type AnyCommandDeclaration } from './commandDeclaration.js';
26
34
  /** A builtin that returns its outcome as an envelope. */
27
35
  export type EnvelopeHandler = (args: string[]) => Promise<CommandEnvelope>;
28
36
  /** A builtin that may print, and returns an envelope or nothing. */
@@ -68,6 +76,11 @@ export interface CommandGroup {
68
76
  * side by side. A command not named here holds the whole session.
69
77
  */
70
78
  holds?: Record<string, readonly SessionPiece[]>;
79
+ /**
80
+ * Commands declared in one record each: handler, help and holds come from
81
+ * the declaration, so a declared name appears in none of the records above.
82
+ */
83
+ declarations?: ReadonlyArray<AnyCommandDeclaration>;
71
84
  }
72
85
  /**
73
86
  * A piece of session state a line may change: the working directory, or
@@ -109,6 +122,30 @@ export declare function commandOrder_set(order: {
109
122
  * @throws {Error} When a backend's group names a core command.
110
123
  */
111
124
  export declare function commands_register(group: CommandGroup, owner?: CommandOwner): void;
125
+ /**
126
+ * A command's declaration, when it has one, by its name or an alias.
127
+ *
128
+ * @param name - The command name, or an alias of it (`feeds`).
129
+ * @returns The declaration (an alias's named as the alias), or undefined for a command not yet declared in one record.
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * commandDeclaration_get('ls')?.grammar;
134
+ * commandDeclaration_get('feeds')?.name; // 'feeds', the feed command under that word
135
+ * ```
136
+ */
137
+ export declare function commandDeclaration_get(name: string): AnyCommandDeclaration | undefined;
138
+ /**
139
+ * Every declared command, in registration order.
140
+ *
141
+ * @returns The declarations.
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * commandDeclarations_list().map((declaration) => declaration.name);
146
+ * ```
147
+ */
148
+ export declare function commandDeclarations_list(): AnyCommandDeclaration[];
112
149
  /**
113
150
  * What a command holds of the session while it runs.
114
151
  * @param name - The command name.