@fnndsc/brasa 0.56.2 → 0.56.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/dist/buildinfo.json +1 -1
  2. package/dist/builtins/berth/berthCube.d.ts +3 -2
  3. package/dist/builtins/berth/berthCube.js +5 -10
  4. package/dist/builtins/berth/berthCube.js.map +1 -1
  5. package/dist/builtins/debug.d.ts +24 -3
  6. package/dist/builtins/debug.js +66 -13
  7. package/dist/builtins/debug.js.map +1 -1
  8. package/dist/builtins/fs/acl.args.d.ts +5 -38
  9. package/dist/builtins/fs/acl.args.js +6 -72
  10. package/dist/builtins/fs/acl.args.js.map +1 -1
  11. package/dist/builtins/fs/acl.d.ts +100 -10
  12. package/dist/builtins/fs/acl.js +222 -68
  13. package/dist/builtins/fs/acl.js.map +1 -1
  14. package/dist/builtins/fs/cat.args.d.ts +14 -15
  15. package/dist/builtins/fs/cat.args.js +13 -40
  16. package/dist/builtins/fs/cat.args.js.map +1 -1
  17. package/dist/builtins/fs/cat.d.ts +40 -3
  18. package/dist/builtins/fs/cat.js +89 -10
  19. package/dist/builtins/fs/cat.js.map +1 -1
  20. package/dist/builtins/fs/cd.d.ts +24 -6
  21. package/dist/builtins/fs/cd.js +71 -18
  22. package/dist/builtins/fs/cd.js.map +1 -1
  23. package/dist/builtins/fs/configWrite.d.ts +24 -8
  24. package/dist/builtins/fs/configWrite.js +77 -36
  25. package/dist/builtins/fs/configWrite.js.map +1 -1
  26. package/dist/builtins/fs/cp.d.ts +39 -4
  27. package/dist/builtins/fs/cp.js +120 -55
  28. package/dist/builtins/fs/cp.js.map +1 -1
  29. package/dist/builtins/fs/du.d.ts +59 -33
  30. package/dist/builtins/fs/du.js +111 -79
  31. package/dist/builtins/fs/du.js.map +1 -1
  32. package/dist/builtins/fs/edit.d.ts +19 -4
  33. package/dist/builtins/fs/edit.js +77 -16
  34. package/dist/builtins/fs/edit.js.map +1 -1
  35. package/dist/builtins/fs/find.d.ts +25 -0
  36. package/dist/builtins/fs/find.js +76 -5
  37. package/dist/builtins/fs/find.js.map +1 -1
  38. package/dist/builtins/fs/mkdir.d.ts +28 -18
  39. package/dist/builtins/fs/mkdir.js +95 -66
  40. package/dist/builtins/fs/mkdir.js.map +1 -1
  41. package/dist/builtins/fs/mv.d.ts +34 -4
  42. package/dist/builtins/fs/mv.js +129 -64
  43. package/dist/builtins/fs/mv.js.map +1 -1
  44. package/dist/builtins/fs/pull.args.d.ts +56 -17
  45. package/dist/builtins/fs/pull.args.js +16 -66
  46. package/dist/builtins/fs/pull.args.js.map +1 -1
  47. package/dist/builtins/fs/pull.d.ts +62 -0
  48. package/dist/builtins/fs/pull.js +86 -22
  49. package/dist/builtins/fs/pull.js.map +1 -1
  50. package/dist/builtins/fs/pwd.d.ts +19 -5
  51. package/dist/builtins/fs/pwd.js +62 -8
  52. package/dist/builtins/fs/pwd.js.map +1 -1
  53. package/dist/builtins/fs/rm.d.ts +58 -21
  54. package/dist/builtins/fs/rm.js +99 -82
  55. package/dist/builtins/fs/rm.js.map +1 -1
  56. package/dist/builtins/fs/rmdir.d.ts +29 -11
  57. package/dist/builtins/fs/rmdir.js +87 -36
  58. package/dist/builtins/fs/rmdir.js.map +1 -1
  59. package/dist/builtins/fs/touch.d.ts +44 -9
  60. package/dist/builtins/fs/touch.js +91 -27
  61. package/dist/builtins/fs/touch.js.map +1 -1
  62. package/dist/builtins/fs/tree.d.ts +36 -9
  63. package/dist/builtins/fs/tree.js +126 -36
  64. package/dist/builtins/fs/tree.js.map +1 -1
  65. package/dist/builtins/fs/upload.d.ts +22 -3
  66. package/dist/builtins/fs/upload.js +82 -14
  67. package/dist/builtins/fs/upload.js.map +1 -1
  68. package/dist/builtins/fs/xattr.args.d.ts +12 -33
  69. package/dist/builtins/fs/xattr.args.js +17 -95
  70. package/dist/builtins/fs/xattr.args.js.map +1 -1
  71. package/dist/builtins/fs/xattr.d.ts +98 -8
  72. package/dist/builtins/fs/xattr.js +163 -24
  73. package/dist/builtins/fs/xattr.js.map +1 -1
  74. package/dist/builtins/games/bytes.d.ts +201 -5
  75. package/dist/builtins/games/bytes.js +255 -54
  76. package/dist/builtins/games/bytes.js.map +1 -1
  77. package/dist/builtins/games/chimes.d.ts +180 -3
  78. package/dist/builtins/games/chimes.js +203 -26
  79. package/dist/builtins/games/chimes.js.map +1 -1
  80. package/dist/builtins/games/chrislab.d.ts +101 -3
  81. package/dist/builtins/games/chrislab.js +117 -17
  82. package/dist/builtins/games/chrislab.js.map +1 -1
  83. package/dist/builtins/games/cowsay.d.ts +93 -2
  84. package/dist/builtins/games/cowsay.js +90 -31
  85. package/dist/builtins/games/cowsay.js.map +1 -1
  86. package/dist/builtins/games/figlet.d.ts +70 -2
  87. package/dist/builtins/games/figlet.js +83 -6
  88. package/dist/builtins/games/figlet.js.map +1 -1
  89. package/dist/builtins/games/lab.d.ts +104 -5
  90. package/dist/builtins/games/lab.js +144 -6
  91. package/dist/builtins/games/lab.js.map +1 -1
  92. package/dist/builtins/games/lolcat.d.ts +61 -1
  93. package/dist/builtins/games/lolcat.js +59 -24
  94. package/dist/builtins/games/lolcat.js.map +1 -1
  95. package/dist/builtins/games/morse.d.ts +36 -1
  96. package/dist/builtins/games/morse.js +50 -2
  97. package/dist/builtins/games/morse.js.map +1 -1
  98. package/dist/builtins/games/numbers.d.ts +241 -5
  99. package/dist/builtins/games/numbers.js +298 -23
  100. package/dist/builtins/games/numbers.js.map +1 -1
  101. package/dist/builtins/games/play.d.ts +96 -6
  102. package/dist/builtins/games/play.js +137 -6
  103. package/dist/builtins/games/play.js.map +1 -1
  104. package/dist/builtins/games/qr.d.ts +40 -1
  105. package/dist/builtins/games/qr.js +51 -2
  106. package/dist/builtins/games/qr.js.map +1 -1
  107. package/dist/builtins/games/show.d.ts +131 -6
  108. package/dist/builtins/games/show.js +208 -20
  109. package/dist/builtins/games/show.js.map +1 -1
  110. package/dist/builtins/games/sky.d.ts +178 -4
  111. package/dist/builtins/games/sky.js +228 -12
  112. package/dist/builtins/games/sky.js.map +1 -1
  113. package/dist/builtins/games/text.d.ts +258 -7
  114. package/dist/builtins/games/text.js +310 -29
  115. package/dist/builtins/games/text.js.map +1 -1
  116. package/dist/builtins/games/trek.d.ts +67 -3
  117. package/dist/builtins/games/trek.js +63 -10
  118. package/dist/builtins/games/trek.js.map +1 -1
  119. package/dist/builtins/games/wtf.d.ts +58 -1
  120. package/dist/builtins/games/wtf.js +67 -6
  121. package/dist/builtins/games/wtf.js.map +1 -1
  122. package/dist/builtins/help.d.ts +38 -2
  123. package/dist/builtins/help.js +76 -769
  124. package/dist/builtins/help.js.map +1 -1
  125. package/dist/builtins/net/connect.d.ts +36 -3
  126. package/dist/builtins/net/connect.js +84 -26
  127. package/dist/builtins/net/connect.js.map +1 -1
  128. package/dist/builtins/net/cubepath.d.ts +49 -5
  129. package/dist/builtins/net/cubepath.js +69 -27
  130. package/dist/builtins/net/cubepath.js.map +1 -1
  131. package/dist/builtins/net/logout.d.ts +13 -4
  132. package/dist/builtins/net/logout.js +49 -3
  133. package/dist/builtins/net/logout.js.map +1 -1
  134. package/dist/builtins/net/netstat.d.ts +29 -4
  135. package/dist/builtins/net/netstat.js +64 -23
  136. package/dist/builtins/net/netstat.js.map +1 -1
  137. package/dist/builtins/net/pacs.d.ts +169 -15
  138. package/dist/builtins/net/pacs.js +92 -33
  139. package/dist/builtins/net/pacs.js.map +1 -1
  140. package/dist/builtins/net/query.args.d.ts +95 -0
  141. package/dist/builtins/net/query.args.js +26 -0
  142. package/dist/builtins/net/query.args.js.map +1 -0
  143. package/dist/builtins/net/query.d.ts +98 -5
  144. package/dist/builtins/net/query.js +89 -83
  145. package/dist/builtins/net/query.js.map +1 -1
  146. package/dist/builtins/net/status.d.ts +5 -3
  147. package/dist/builtins/net/status.js +5 -12
  148. package/dist/builtins/net/status.js.map +1 -1
  149. package/dist/builtins/parametersofplugin.d.ts +82 -3
  150. package/dist/builtins/parametersofplugin.js +79 -23
  151. package/dist/builtins/parametersofplugin.js.map +1 -1
  152. package/dist/builtins/proc.d.ts +210 -3
  153. package/dist/builtins/proc.js +210 -119
  154. package/dist/builtins/proc.js.map +1 -1
  155. package/dist/builtins/res/compute.d.ts +67 -3
  156. package/dist/builtins/res/compute.js +121 -35
  157. package/dist/builtins/res/compute.js.map +1 -1
  158. package/dist/builtins/res/dicom.d.ts +52 -3
  159. package/dist/builtins/res/dicom.js +82 -34
  160. package/dist/builtins/res/dicom.js.map +1 -1
  161. package/dist/builtins/res/expect.d.ts +52 -3
  162. package/dist/builtins/res/expect.js +92 -29
  163. package/dist/builtins/res/expect.js.map +1 -1
  164. package/dist/builtins/res/feed.d.ts +475 -3
  165. package/dist/builtins/res/feed.js +253 -158
  166. package/dist/builtins/res/feed.js.map +1 -1
  167. package/dist/builtins/res/files.d.ts +517 -3
  168. package/dist/builtins/res/files.js +124 -44
  169. package/dist/builtins/res/files.js.map +1 -1
  170. package/dist/builtins/res/gather.d.ts +113 -3
  171. package/dist/builtins/res/gather.js +153 -44
  172. package/dist/builtins/res/gather.js.map +1 -1
  173. package/dist/builtins/res/gather.process.d.ts +27 -19
  174. package/dist/builtins/res/gather.process.js +29 -59
  175. package/dist/builtins/res/gather.process.js.map +1 -1
  176. package/dist/builtins/res/group.d.ts +284 -3
  177. package/dist/builtins/res/group.js +147 -76
  178. package/dist/builtins/res/group.js.map +1 -1
  179. package/dist/builtins/res/image.d.ts +30 -2
  180. package/dist/builtins/res/image.js +62 -10
  181. package/dist/builtins/res/image.js.map +1 -1
  182. package/dist/builtins/res/play.d.ts +71 -9
  183. package/dist/builtins/res/play.js +124 -82
  184. package/dist/builtins/res/play.js.map +1 -1
  185. package/dist/builtins/res/plugininstance.d.ts +307 -2
  186. package/dist/builtins/res/plugininstance.js +122 -50
  187. package/dist/builtins/res/plugininstance.js.map +1 -1
  188. package/dist/builtins/res/pluginmeta.d.ts +244 -2
  189. package/dist/builtins/res/pluginmeta.js +98 -40
  190. package/dist/builtins/res/pluginmeta.js.map +1 -1
  191. package/dist/builtins/res/record.d.ts +37 -3
  192. package/dist/builtins/res/record.js +127 -57
  193. package/dist/builtins/res/record.js.map +1 -1
  194. package/dist/builtins/res/resourceList.d.ts +136 -0
  195. package/dist/builtins/res/resourceList.js +51 -0
  196. package/dist/builtins/res/resourceList.js.map +1 -0
  197. package/dist/builtins/res/tag.d.ts +244 -3
  198. package/dist/builtins/res/tag.js +97 -41
  199. package/dist/builtins/res/tag.js.map +1 -1
  200. package/dist/builtins/res/user.d.ts +122 -3
  201. package/dist/builtins/res/user.js +83 -21
  202. package/dist/builtins/res/user.js.map +1 -1
  203. package/dist/builtins/res/workflow.d.ts +244 -2
  204. package/dist/builtins/res/workflow.js +97 -40
  205. package/dist/builtins/res/workflow.js.map +1 -1
  206. package/dist/builtins/store.d.ts +85 -3
  207. package/dist/builtins/store.js +135 -68
  208. package/dist/builtins/store.js.map +1 -1
  209. package/dist/builtins/sys/apropos.d.ts +80 -5
  210. package/dist/builtins/sys/apropos.js +121 -15
  211. package/dist/builtins/sys/apropos.js.map +1 -1
  212. package/dist/builtins/sys/cal.d.ts +44 -5
  213. package/dist/builtins/sys/cal.js +57 -10
  214. package/dist/builtins/sys/cal.js.map +1 -1
  215. package/dist/builtins/sys/command.d.ts +20 -0
  216. package/dist/builtins/sys/command.js +31 -0
  217. package/dist/builtins/sys/command.js.map +1 -1
  218. package/dist/builtins/sys/context.d.ts +13 -3
  219. package/dist/builtins/sys/context.js +51 -4
  220. package/dist/builtins/sys/context.js.map +1 -1
  221. package/dist/builtins/sys/date.d.ts +56 -5
  222. package/dist/builtins/sys/date.js +63 -9
  223. package/dist/builtins/sys/date.js.map +1 -1
  224. package/dist/builtins/sys/echo.d.ts +63 -2
  225. package/dist/builtins/sys/echo.js +87 -8
  226. package/dist/builtins/sys/echo.js.map +1 -1
  227. package/dist/builtins/sys/fortune.d.ts +27 -2
  228. package/dist/builtins/sys/fortune.js +44 -2
  229. package/dist/builtins/sys/fortune.js.map +1 -1
  230. package/dist/builtins/sys/grep.d.ts +245 -11
  231. package/dist/builtins/sys/grep.js +418 -131
  232. package/dist/builtins/sys/grep.js.map +1 -1
  233. package/dist/builtins/sys/joblets.d.ts +66 -7
  234. package/dist/builtins/sys/joblets.js +101 -14
  235. package/dist/builtins/sys/joblets.js.map +1 -1
  236. package/dist/builtins/sys/motd.d.ts +37 -3
  237. package/dist/builtins/sys/motd.js +49 -8
  238. package/dist/builtins/sys/motd.js.map +1 -1
  239. package/dist/builtins/sys/notes.d.ts +75 -3
  240. package/dist/builtins/sys/notes.js +90 -29
  241. package/dist/builtins/sys/notes.js.map +1 -1
  242. package/dist/builtins/sys/physicalmode.d.ts +24 -3
  243. package/dist/builtins/sys/physicalmode.js +68 -14
  244. package/dist/builtins/sys/physicalmode.js.map +1 -1
  245. package/dist/builtins/sys/tasks.d.ts +74 -5
  246. package/dist/builtins/sys/tasks.js +102 -14
  247. package/dist/builtins/sys/tasks.js.map +1 -1
  248. package/dist/builtins/sys/textFilters.d.ts +673 -41
  249. package/dist/builtins/sys/textFilters.js +718 -263
  250. package/dist/builtins/sys/textFilters.js.map +1 -1
  251. package/dist/builtins/sys/timing.d.ts +24 -3
  252. package/dist/builtins/sys/timing.js +67 -14
  253. package/dist/builtins/sys/timing.js.map +1 -1
  254. package/dist/builtins/sys/variables.d.ts +70 -4
  255. package/dist/builtins/sys/variables.js +103 -31
  256. package/dist/builtins/sys/variables.js.map +1 -1
  257. package/dist/builtins/sys/version.d.ts +27 -2
  258. package/dist/builtins/sys/version.js +48 -3
  259. package/dist/builtins/sys/version.js.map +1 -1
  260. package/dist/builtins/sys/weather.d.ts +92 -15
  261. package/dist/builtins/sys/weather.js +71 -45
  262. package/dist/builtins/sys/weather.js.map +1 -1
  263. package/dist/builtins/sys/whoami.d.ts +38 -18
  264. package/dist/builtins/sys/whoami.js +112 -8
  265. package/dist/builtins/sys/whoami.js.map +1 -1
  266. package/dist/builtins/utils.d.ts +0 -37
  267. package/dist/builtins/utils.js +0 -86
  268. package/dist/builtins/utils.js.map +1 -1
  269. package/dist/chris/chrisCommands.js +58 -152
  270. package/dist/chris/chrisCommands.js.map +1 -1
  271. package/dist/chris/commandFallback.d.ts +12 -0
  272. package/dist/chris/commandFallback.js +47 -0
  273. package/dist/chris/commandFallback.js.map +1 -1
  274. package/dist/chris/filesystem.js +7 -5
  275. package/dist/chris/filesystem.js.map +1 -1
  276. package/dist/chris/help.js +0 -1018
  277. package/dist/chris/help.js.map +1 -1
  278. package/dist/chris/kinds.d.ts +21 -0
  279. package/dist/chris/kinds.js +114 -2
  280. package/dist/chris/kinds.js.map +1 -1
  281. package/dist/chris/mounts.d.ts +4 -4
  282. package/dist/chris/mounts.js +9 -16
  283. package/dist/chris/mounts.js.map +1 -1
  284. package/dist/chris/navigation.d.ts +2 -3
  285. package/dist/chris/navigation.js +6 -20
  286. package/dist/chris/navigation.js.map +1 -1
  287. package/dist/chris/pacsResources.d.ts +259 -0
  288. package/dist/chris/pacsResources.js +168 -0
  289. package/dist/chris/pacsResources.js.map +1 -0
  290. package/dist/core/commandDeclaration.d.ts +97 -7
  291. package/dist/core/commandDeclaration.js +21 -0
  292. package/dist/core/commandDeclaration.js.map +1 -1
  293. package/dist/core/commandParse.js +65 -17
  294. package/dist/core/commandParse.js.map +1 -1
  295. package/dist/core/commandRegistry.d.ts +4 -3
  296. package/dist/core/commandRegistry.js +36 -8
  297. package/dist/core/commandRegistry.js.map +1 -1
  298. package/dist/core/commandSchema.js +5 -2
  299. package/dist/core/commandSchema.js.map +1 -1
  300. package/dist/core/commandUsage.d.ts +15 -0
  301. package/dist/core/commandUsage.js +59 -7
  302. package/dist/core/commandUsage.js.map +1 -1
  303. package/dist/core/coreCommands.js +63 -212
  304. package/dist/core/coreCommands.js.map +1 -1
  305. package/dist/core/paths.d.ts +29 -1
  306. package/dist/core/paths.js +15 -2
  307. package/dist/core/paths.js.map +1 -1
  308. package/dist/core/preprocess.d.ts +3 -4
  309. package/dist/core/preprocess.js +4 -5
  310. package/dist/core/preprocess.js.map +1 -1
  311. package/dist/lib/completer/declared.js +7 -4
  312. package/dist/lib/completer/declared.js.map +1 -1
  313. package/dist/lib/completer/index.js +2 -7
  314. package/dist/lib/completer/index.js.map +1 -1
  315. package/dist/lib/parser.d.ts +0 -8
  316. package/dist/lib/parser.js +0 -11
  317. package/dist/lib/parser.js.map +1 -1
  318. package/dist/lib/vfs/vfs.d.ts +2 -1
  319. package/dist/lib/vfs/vfs.js +5 -4
  320. package/dist/lib/vfs/vfs.js.map +1 -1
  321. package/dist/notes.json +1 -1
  322. package/package.json +3 -3
@@ -12,12 +12,47 @@ export interface CpModelData {
12
12
  failed: number;
13
13
  }
14
14
  /**
15
- * Copies a file or directory.
16
- * Supports multiple sources when destination is a directory.
15
+ * `cp [-rt] [--target-directory <dir>] <paths…>`: the declaration.
17
16
  *
18
- * @param args - [flags, src1, src2, ..., dest]
17
+ * @example
18
+ * ```ts
19
+ * commands_register({ declarations: [cpCommand] });
20
+ * ```
21
+ */
22
+ export declare const cpCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
23
+ readonly operands: readonly [{
24
+ readonly name: "paths";
25
+ readonly kind: "cfsPath";
26
+ readonly repeat: true;
27
+ readonly glob: true;
28
+ readonly summary: "The sources, then the destination; a lone source asks where it goes";
29
+ }];
30
+ readonly options: {
31
+ readonly recursive: {
32
+ readonly short: "r";
33
+ readonly long: "recursive";
34
+ readonly summary: "Recursive copy (for directories)";
35
+ };
36
+ readonly askTarget: {
37
+ readonly short: "t";
38
+ readonly summary: "Every operand is a source; asks for the target directory, and the answer must be one";
39
+ };
40
+ readonly targetDirectory: {
41
+ readonly long: "target-directory";
42
+ readonly summary: "Every operand is a source; copy into this directory";
43
+ readonly value: {
44
+ readonly name: "dir";
45
+ readonly kind: "cfsPath";
46
+ };
47
+ };
48
+ };
49
+ }>;
50
+ /**
51
+ * `cp` over words already split: the declaration's parse and handler.
52
+ *
53
+ * @param args - The words after `cp`.
19
54
  * @returns An envelope whose rendered text reports progress and results and
20
- * whose model carries per-source outcomes.
55
+ * whose model carries per-source outcomes, or the refusal of a bad line.
21
56
  */
22
57
  export declare function builtin_cp(args: string[]): Promise<CommandEnvelope>;
23
58
  /** Typed invocation options for cp. */
@@ -1,59 +1,77 @@
1
1
  /**
2
- * @file Builtin cp command.
3
- * Copies files or directories, reported as a command envelope.
2
+ * @file `cp`: copies files and folders within ChRIS's filesystem (CFS),
3
+ * reported as a command envelope.
4
+ *
5
+ * Declared in one record (`cpCommand`): the sources, then the destination,
6
+ * each a path that may be a wildcard; a lone source, or `-t`, asks where.
7
+ * Each path is acted on where the store keeps it (`storePath_resolve`): a
8
+ * source through a link is what the link points at, and a destination
9
+ * through a link lands in the link's target. What cp says names the paths
10
+ * as the session resolves them.
11
+ *
12
+ * Key components:
13
+ * - cpCommand: the declaration.
14
+ * - builtin_cp: the declaration run over words already split.
15
+ * - cp_run: the typed core behind both, and the typed API.
16
+ *
17
+ * Typical usage:
18
+ * ```ts
19
+ * await builtin_cp(['-r', 'data', 'backup/']);
20
+ * await cp_run({ sources: ['a.txt'], dest: 'b.txt' });
21
+ * ```
22
+ *
23
+ * Dependencies: the session's filesystem and listing cache, and the
24
+ * destination question.
25
+ *
26
+ * @module
4
27
  */
5
28
  import chalk from 'chalk';
6
29
  import path from 'path';
7
- import { commandArgs_process, optionsUnknown_refusal, path_resolve, storePath_resolve } from '../utils.js';
30
+ import { path_resolve, storePath_resolve } from '../utils.js';
31
+ import { command_declare } from '../../core/commandDeclaration.js';
32
+ import { declaredCommand_run } from '../../core/commandParse.js';
8
33
  import { listingCache_get, vfsDispatcher_get } from '../../core/filesystem.js';
9
34
  import { destination_ask, destination_missing, operands_fix } from './destination.js';
10
35
  import { cp_render, vfsRefusal_text } from '@fnndsc/fond';
11
36
  import { pathEntry_find, entry_isFolder } from './entries.js';
12
37
  import { envelope_ok, envelope_error } from '@fnndsc/menu';
13
38
  import { exitCode_set } from '../../core/handlerRun.js';
39
+ /** What a `cp` line may hold. */
40
+ const CP_GRAMMAR = {
41
+ operands: [
42
+ { name: 'paths', kind: 'cfsPath', repeat: true, glob: true, summary: 'The sources, then the destination; a lone source asks where it goes' },
43
+ ],
44
+ options: {
45
+ recursive: { short: 'r', long: 'recursive', summary: 'Recursive copy (for directories)' },
46
+ askTarget: { short: 't', summary: 'Every operand is a source; asks for the target directory, and the answer must be one' },
47
+ targetDirectory: { long: 'target-directory', summary: 'Every operand is a source; copy into this directory', value: { name: 'dir', kind: 'cfsPath' } },
48
+ },
49
+ };
14
50
  /**
15
- * Copies a file or directory.
16
- * Supports multiple sources when destination is a directory.
51
+ * Runs a parsed `cp` line: into a target directory given or asked for, to a
52
+ * destination asked for a lone source, or to the last operand.
17
53
  *
18
- * @param args - [flags, src1, src2, ..., dest]
19
- * @returns An envelope whose rendered text reports progress and results and
20
- * whose model carries per-source outcomes.
54
+ * @param args - The typed line.
55
+ * @returns The copy's envelope, or the refusal of an abandoned question.
21
56
  */
22
- export async function builtin_cp(args) {
23
- const parsed = commandArgs_process(args, { booleanLongOptions: ['recursive'] });
24
- const refusal = optionsUnknown_refusal('cp', parsed, ['t', 'r', 'recursive']);
25
- if (refusal !== null)
26
- return envelope_error('', undefined, `${chalk.red(refusal)}\n`);
27
- const pathArgs = parsed._;
28
- // `-t <dir>` names the TARGET DIRECTORY, so every operand is a source —
29
- // the shell's own answer to "several things, one destination". Given no
30
- // value it is a question (an-absent-value-is-a-question), and the answer
31
- // wants a directory: `cp a b` without it means rename a ONTO b, which
32
- // is the right reading of that line and the wrong thing for a set.
33
- const target = parsed.t;
34
- if (target !== undefined && pathArgs.length > 0) {
35
- if (typeof target === 'string' && target !== '') {
36
- return cp_run({ sources: pathArgs, dest: target });
37
- }
38
- // The sources are fixed before the question: other commands run while it is open.
39
- const sources = await operands_fix(pathArgs);
40
- const chosen = await destination_ask({
41
- verb: 'cp', commit: 'COPY HERE', sources, wantsDirectory: true,
42
- });
43
- if (chosen === '') {
44
- exitCode_set(1);
45
- return envelope_error('', undefined, `${chalk.red(destination_missing('cp'))}\n`);
46
- }
47
- return cp_run({ sources, dest: chosen });
48
- }
49
- const recursive = !!parsed['r'] || !!parsed['recursive'];
50
- // One operand names what to copy and not where: a question, not a usage
51
- // error. See `destination_ask`.
52
- if (pathArgs.length === 1) {
57
+ async function cp_handle(args) {
58
+ const paths = args.operands.paths;
59
+ const recursive = args.options.recursive;
60
+ // `--target-directory <dir>` names the TARGET DIRECTORY, so every operand
61
+ // is a source: the shell's own answer to "several things, one destination".
62
+ const target = args.options.targetDirectory;
63
+ if (target !== undefined)
64
+ return cp_run({ sources: paths, dest: target, recursive });
65
+ // `-t` alone is that line with the directory not said: a question
66
+ // (an-absent-value-is-a-question), and the answer wants a directory:
67
+ // `cp a b` without it means copy a ONTO b, the right reading of that line
68
+ // and the wrong thing for a set. One operand names what to copy and not
69
+ // where: a question too, not a usage error. See `destination_ask`.
70
+ if (args.options.askTarget || paths.length === 1) {
53
71
  // The sources are fixed before the question: other commands run while it is open.
54
- const sources = await operands_fix(pathArgs);
72
+ const sources = await operands_fix(paths);
55
73
  const chosen = await destination_ask({
56
- verb: 'cp', commit: 'COPY HERE', sources,
74
+ verb: 'cp', commit: 'COPY HERE', sources, ...(args.options.askTarget ? { wantsDirectory: true } : {}),
57
75
  });
58
76
  if (chosen === '') {
59
77
  exitCode_set(1);
@@ -61,12 +79,61 @@ export async function builtin_cp(args) {
61
79
  }
62
80
  return cp_run({ sources, dest: chosen, recursive });
63
81
  }
64
- // Last arg is destination, all others are sources
65
- return cp_run({
66
- sources: pathArgs.slice(0, -1),
67
- dest: pathArgs.length > 0 ? pathArgs[pathArgs.length - 1] : '',
68
- recursive,
69
- });
82
+ // The last operand is the destination, all others are sources.
83
+ return cp_run({ sources: paths.slice(0, -1), dest: paths[paths.length - 1] ?? '', recursive });
84
+ }
85
+ /**
86
+ * `cp [-rt] [--target-directory <dir>] <paths…>`: the declaration.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * commands_register({ declarations: [cpCommand] });
91
+ * ```
92
+ */
93
+ export const cpCommand = command_declare({
94
+ name: 'cp',
95
+ grammar: CP_GRAMMAR,
96
+ help: {
97
+ summary: 'Copy files or directories (supports wildcards and multiple sources)',
98
+ description: "Copies files or folders within ChRIS's filesystem: the last operand is the destination, and several sources want a folder there. Given only a source, the destination is asked for. A path through a link is the link's target: a copy into a linked folder lands in the folder it points at. PACS sources: a /net/pacs/queries/... source names query results, not stored files, and cp materializes the series: if its DICOMs are not yet in CUBE it fires a PACS retrieve and waits for them to land (the same engine as pull), then copies the landed files to the destination. A series already fully in CUBE is copied without a retrieve.",
99
+ category: 'Files',
100
+ posix: { group: 'Files', differs: 'copies within CFS; -r for folders' },
101
+ examples: [
102
+ 'cp file.txt copy.txt # Copy single file',
103
+ 'cp -r dir1/ dir2/ # Copy directory recursively',
104
+ 'cp file1 file2 file3 dest/ # Copy multiple files',
105
+ 'cp uploads/*.txt backup/ # Copy with wildcard',
106
+ 'cp --target-directory backup/ a b # Copy several into one folder',
107
+ 'cp -t a.txt b.txt # Ask which folder they go to',
108
+ 'cp "file with spaces.txt" dest/ # Use quotes for spaces',
109
+ 'cp -r /net/pacs/queries/AccessionNumber:123_qid:7/Study_1.2.3_Head/Series_1.2.3.4_AX_T2 results/',
110
+ ' # Retrieve-if-needed, then copy the series',
111
+ ],
112
+ },
113
+ handler: cp_handle,
114
+ });
115
+ /**
116
+ * `cp` over words already split: the declaration's parse and handler.
117
+ *
118
+ * @param args - The words after `cp`.
119
+ * @returns An envelope whose rendered text reports progress and results and
120
+ * whose model carries per-source outcomes, or the refusal of a bad line.
121
+ */
122
+ export async function builtin_cp(args) {
123
+ return declaredCommand_run(cpCommand, args);
124
+ }
125
+ /**
126
+ * Forgets the cached listings a write to a destination changes: beneath it
127
+ * (a recursive copy replaces them) and of its parent, by each name it has.
128
+ *
129
+ * @param listCache - The session's listing cache.
130
+ * @param names - The destination as the session names it and as the store keeps it.
131
+ */
132
+ function destination_invalidate(listCache, names) {
133
+ for (const name of new Set(names)) {
134
+ listCache.cache_invalidateTree?.(name);
135
+ listCache.cache_invalidate?.(path.posix.dirname(name));
136
+ }
70
137
  }
71
138
  /**
72
139
  * Copies files or directories: the shared typed core behind the parsed
@@ -84,6 +151,8 @@ export async function cp_run(options) {
84
151
  }
85
152
  const recursive = options.recursive ?? false;
86
153
  const destPath = await path_resolve(dest);
154
+ // Written where the store keeps it: into a linked folder lands in the link's target.
155
+ const destStore = await storePath_resolve(destPath);
87
156
  const listCache = listingCache_get();
88
157
  let successCount = 0;
89
158
  let failCount = 0;
@@ -102,9 +171,9 @@ export async function cp_run(options) {
102
171
  }
103
172
  // Into a folder the destination names, the copy keeps its name.
104
173
  const dispatcher = vfsDispatcher_get();
105
- const finalDest = entry_isFolder(await pathEntry_find(dispatcher, destPath)) && !dispatcher.path_isVirtual(destPath)
106
- ? path.posix.join(destPath, path.posix.basename(srcPath))
107
- : destPath;
174
+ const finalDest = entry_isFolder(await pathEntry_find(dispatcher, destStore)) && !dispatcher.path_isVirtual(destStore)
175
+ ? path.posix.join(destStore, path.posix.basename(srcPath))
176
+ : destStore;
108
177
  // Copied from where the store keeps it (a /proc data path, a link); named as it was asked.
109
178
  const copied = await dispatcher.cp(await storePath_resolve(srcPath), finalDest, { recursive });
110
179
  const success = copied.ok;
@@ -132,11 +201,7 @@ export async function cp_run(options) {
132
201
  failCount++;
133
202
  }
134
203
  }
135
- // Invalidate the destination subtree (a recursive copy replaces whatever
136
- // listings were cached beneath it) and its parent.
137
- listCache.cache_invalidateTree?.(destPath);
138
- const destParent = path.posix.dirname(destPath);
139
- listCache.cache_invalidate?.(destParent);
204
+ destination_invalidate(listCache, [destPath, destStore]);
140
205
  // Summary for multiple files
141
206
  if (sources.length > 1) {
142
207
  if (failCount === 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"cp.js","sourceRoot":"","sources":["../../../src/builtins/fs/cp.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO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eAAe,QAAQ,EAAE,CAAC,IAAI,CAAC;QACpF,CAAC;aAAM,CAAC;YACN,QAAQ,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,YAAY,YAAY,aAAa,SAAS,SAAS,CAAC,IAAI,CAAC;QAC3F,CAAC;IACH,CAAC;IAED,MAAM,SAAS,GAAgB,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACrG,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QAClB,MAAM,QAAQ,GAAoB,cAAc,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,IAAI,SAAS,CAAC,CAAC;QAChG,QAAQ,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACpD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,WAAW,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;AACnE,CAAC"}
@@ -1,4 +1,3 @@
1
- import { ParsedArgs } from '../utils.js';
2
1
  import { type ScanRecord } from '@fnndsc/chili/path/pathCommand.js';
3
2
  import { type CommandEnvelope } from '@fnndsc/menu';
4
3
  /**
@@ -13,14 +12,67 @@ export interface DuOptions {
13
12
  maxDepth: number | undefined;
14
13
  }
15
14
  /**
16
- * Spells `-d N` and `-dN` as `--max-depth=N`, the one form the parser
17
- * takes a value for: a short flag is otherwise a switch, and the depth
18
- * read as a path to measure.
15
+ * `du [-hsacS] [-d <N>] [path…]`: the declaration.
19
16
  *
20
- * @param args - du's words.
21
- * @returns The words, the depth spelled long.
17
+ * @example
18
+ * ```ts
19
+ * commands_register({ declarations: [duCommand] }, 'backend');
20
+ * ```
22
21
  */
23
- export declare function depthOption_normalize(args: string[]): string[];
22
+ export declare const duCommand: import("../../core/commandDeclaration.js").CommandDeclaration<{
23
+ readonly operands: readonly [{
24
+ readonly name: "path";
25
+ readonly kind: "cfsPath";
26
+ readonly optional: true;
27
+ readonly repeat: true;
28
+ readonly glob: true;
29
+ readonly summary: "What to measure; the working directory when none is given";
30
+ }];
31
+ readonly options: {
32
+ readonly humanReadable: {
33
+ readonly short: "h";
34
+ readonly long: "human-readable";
35
+ readonly summary: "Print sizes in human readable format";
36
+ };
37
+ readonly summarize: {
38
+ readonly short: "s";
39
+ readonly long: "summarize";
40
+ readonly summary: "Display only total for each argument";
41
+ };
42
+ readonly all: {
43
+ readonly short: "a";
44
+ readonly long: "all";
45
+ readonly summary: "Show counts for all files, not just directories";
46
+ };
47
+ readonly total: {
48
+ readonly short: "c";
49
+ readonly long: "total";
50
+ readonly summary: "Produce a grand total";
51
+ };
52
+ readonly separateDirs: {
53
+ readonly short: "S";
54
+ readonly long: "separate-dirs";
55
+ readonly summary: "Do not include size of subdirectories";
56
+ };
57
+ readonly maxDepth: {
58
+ readonly short: "d";
59
+ readonly long: "max-depth";
60
+ readonly summary: "Print total only if N or fewer levels below";
61
+ readonly value: {
62
+ readonly name: "N";
63
+ readonly kind: "int";
64
+ readonly min: 0;
65
+ };
66
+ };
67
+ };
68
+ }>;
69
+ /**
70
+ * `du` over words already split: the declaration's parse and handler.
71
+ *
72
+ * @param args - The words after `du`.
73
+ * @returns The sizes, or the refusal of a bad line.
74
+ */
75
+ export declare function builtin_du(args: string[]): Promise<CommandEnvelope>;
24
76
  /**
25
77
  * Formats a byte count for `du` output: human-readable string or KB integer,
26
78
  * right-padded to 12 characters for column alignment.
@@ -30,13 +82,6 @@ export declare function depthOption_normalize(args: string[]): string[];
30
82
  * @returns Right-aligned size string.
31
83
  */
32
84
  export declare function duSize_format(bytes: number, humanReadable: boolean): string;
33
- /**
34
- * Extracts `du` flags from parsed command arguments.
35
- *
36
- * @param parsed - The parsed command arguments.
37
- * @returns The resolved du options.
38
- */
39
- export declare function duOptions_parse(parsed: ParsedArgs): DuOptions;
40
85
  /**
41
86
  * Accumulates per-directory sizes from a scan result, attributing each file's
42
87
  * size to its ancestor directories up to (and including) the target path.
@@ -47,22 +92,3 @@ export declare function duOptions_parse(parsed: ParsedArgs): DuOptions;
47
92
  * @returns A map of directory path to accumulated size.
48
93
  */
49
94
  export declare function dirSizes_compute(scanResult: ScanRecord, targetPath: string, opts: DuOptions): Map<string, number>;
50
- /**
51
- * Displays disk usage statistics for ChRIS filesystem directories.
52
- * Mimics standard Linux du command behavior and flags.
53
- * Uses chili's scan_do machinery for recursive filesystem traversal.
54
- *
55
- * @param args - Command line arguments (optional path and flags).
56
- * @returns A Promise that resolves when disk usage is displayed.
57
- *
58
- * @example
59
- * ```
60
- * du # Disk usage of current directory
61
- * du -h # Human-readable sizes
62
- * du -s /home/user/data # Summary only
63
- * du -a # Show all files, not just directories
64
- * du -c # Show grand total
65
- * du -d 2 # Max depth of 2 levels
66
- * ```
67
- */
68
- export declare function builtin_du(args: string[]): Promise<CommandEnvelope>;