zod-args-parser 2.0.0-beta.0 → 2.0.0-beta.2

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 (475) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +230 -289
  3. package/lib/esm/autocomplete-scripts/bash-autocomplete-script.js +74 -2
  4. package/lib/esm/autocomplete-scripts/bash-autocomplete-script.js.map +7 -1
  5. package/lib/esm/autocomplete-scripts/powershell-autocomplete-script.js +90 -2
  6. package/lib/esm/autocomplete-scripts/powershell-autocomplete-script.js.map +7 -1
  7. package/lib/esm/autocomplete-scripts/zsh-autocomplete-script.js +39 -13
  8. package/lib/esm/autocomplete-scripts/zsh-autocomplete-script.js.map +7 -1
  9. package/lib/esm/cli-error/cli-error.js +38 -0
  10. package/lib/esm/cli-error/cli-error.js.map +7 -0
  11. package/lib/esm/cli-error/error-cause.js +12 -0
  12. package/lib/esm/cli-error/error-cause.js.map +7 -0
  13. package/lib/esm/cli-error/error-code/definition-error-code.js +23 -0
  14. package/lib/esm/cli-error/error-code/definition-error-code.js.map +7 -0
  15. package/lib/esm/cli-error/error-code/internal-error-code.js +10 -0
  16. package/lib/esm/cli-error/error-code/internal-error-code.js.map +7 -0
  17. package/lib/esm/cli-error/error-code/parse-error-code.js +18 -0
  18. package/lib/esm/cli-error/error-code/parse-error-code.js.map +7 -0
  19. package/lib/esm/cli-error/error-code/validation-error-code.js +17 -0
  20. package/lib/esm/cli-error/error-code/validation-error-code.js.map +7 -0
  21. package/lib/esm/cli-error/error-message/definition-error-message.js +70 -0
  22. package/lib/esm/cli-error/error-message/definition-error-message.js.map +7 -0
  23. package/lib/esm/cli-error/error-message/internal-error-message.js +16 -0
  24. package/lib/esm/cli-error/error-message/internal-error-message.js.map +7 -0
  25. package/lib/esm/cli-error/error-message/parse-error-message.js +40 -0
  26. package/lib/esm/cli-error/error-message/parse-error-message.js.map +7 -0
  27. package/lib/esm/cli-error/error-message/validation-error-message.js +60 -0
  28. package/lib/esm/cli-error/error-message/validation-error-message.js.map +7 -0
  29. package/lib/esm/coerce/coerce-methods.js +197 -2
  30. package/lib/esm/coerce/coerce-methods.js.map +7 -1
  31. package/lib/esm/coerce/string-to-array.js +17 -2
  32. package/lib/esm/coerce/string-to-array.js.map +7 -1
  33. package/lib/esm/coerce/string-to-primitive.js +73 -2
  34. package/lib/esm/coerce/string-to-primitive.js.map +7 -1
  35. package/lib/esm/coerce/string-to-set.js +17 -2
  36. package/lib/esm/coerce/string-to-set.js.map +7 -1
  37. package/lib/esm/definitions/define-arguments.js +10 -2
  38. package/lib/esm/definitions/define-arguments.js.map +7 -1
  39. package/lib/esm/definitions/define-cli.js +89 -2
  40. package/lib/esm/definitions/define-cli.js.map +7 -1
  41. package/lib/esm/definitions/define-options.js +10 -2
  42. package/lib/esm/definitions/define-options.js.map +7 -1
  43. package/lib/esm/definitions/define-subcommand.js +56 -2
  44. package/lib/esm/definitions/define-subcommand.js.map +7 -1
  45. package/lib/esm/definitions/validate-cli-definition.js +360 -2
  46. package/lib/esm/definitions/validate-cli-definition.js.map +7 -1
  47. package/lib/esm/help-message/format-arguments.js +48 -2
  48. package/lib/esm/help-message/format-arguments.js.map +7 -1
  49. package/lib/esm/help-message/format-options.js +50 -2
  50. package/lib/esm/help-message/format-options.js.map +7 -1
  51. package/lib/esm/help-message/format-subcommands.js +37 -2
  52. package/lib/esm/help-message/format-subcommands.js.map +7 -1
  53. package/lib/esm/help-message/generate-for-cli.js +71 -2
  54. package/lib/esm/help-message/generate-for-cli.js.map +7 -1
  55. package/lib/esm/help-message/generate-for-subcommand.js +23 -2
  56. package/lib/esm/help-message/generate-for-subcommand.js.map +7 -1
  57. package/lib/esm/help-message/print-help.js +14 -2
  58. package/lib/esm/help-message/print-help.js.map +7 -1
  59. package/lib/esm/help-message/set-defaults.js +29 -2
  60. package/lib/esm/help-message/set-defaults.js.map +7 -1
  61. package/lib/esm/help-message/styles.js +154 -2
  62. package/lib/esm/help-message/styles.js.map +7 -1
  63. package/lib/esm/help-message/terminal-markdown.js +121 -2
  64. package/lib/esm/help-message/terminal-markdown.js.map +7 -1
  65. package/lib/esm/index.js +52 -2
  66. package/lib/esm/index.js.map +7 -1
  67. package/lib/esm/markdown/generate-markdown.js +153 -2
  68. package/lib/esm/markdown/generate-markdown.js.map +7 -1
  69. package/lib/esm/metadata/arguments-metadata.js +26 -2
  70. package/lib/esm/metadata/arguments-metadata.js.map +7 -1
  71. package/lib/esm/metadata/cli-metadata.js +24 -2
  72. package/lib/esm/metadata/cli-metadata.js.map +7 -1
  73. package/lib/esm/metadata/options-metadata.js +35 -2
  74. package/lib/esm/metadata/options-metadata.js.map +7 -1
  75. package/lib/esm/metadata/subcommands-metadata.js +32 -2
  76. package/lib/esm/metadata/subcommands-metadata.js.map +7 -1
  77. package/lib/esm/parse/context/cli-context-builder.js +283 -2
  78. package/lib/esm/parse/context/cli-context-builder.js.map +7 -1
  79. package/lib/esm/parse/context/object-context-builder.js +62 -2
  80. package/lib/esm/parse/context/object-context-builder.js.map +7 -1
  81. package/lib/esm/parse/parser-utilities.js +108 -2
  82. package/lib/esm/parse/parser-utilities.js.map +7 -1
  83. package/lib/esm/parse/safe-parse.js +57 -2
  84. package/lib/esm/parse/safe-parse.js.map +7 -1
  85. package/lib/esm/parse/validation/validate-context.js +17 -2
  86. package/lib/esm/parse/validation/validate-context.js.map +7 -1
  87. package/lib/esm/parse/validation/validators/arguments.js +67 -2
  88. package/lib/esm/parse/validation/validators/arguments.js.map +7 -1
  89. package/lib/esm/parse/validation/validators/conflict.js +38 -2
  90. package/lib/esm/parse/validation/validators/conflict.js.map +7 -1
  91. package/lib/esm/parse/validation/validators/exclusive.js +39 -2
  92. package/lib/esm/parse/validation/validators/exclusive.js.map +7 -1
  93. package/lib/esm/parse/validation/validators/explicitly-passed.js +18 -2
  94. package/lib/esm/parse/validation/validators/explicitly-passed.js.map +7 -1
  95. package/lib/esm/parse/validation/validators/options.js +67 -2
  96. package/lib/esm/parse/validation/validators/options.js.map +7 -1
  97. package/lib/esm/parse/validation/validators/requires.js +43 -2
  98. package/lib/esm/parse/validation/validators/requires.js.map +7 -1
  99. package/lib/esm/utilities/parse-argv.js +61 -0
  100. package/lib/esm/utilities/parse-argv.js.map +7 -0
  101. package/lib/esm/utilities/schema-utilities.js +57 -0
  102. package/lib/esm/utilities/schema-utilities.js.map +7 -0
  103. package/lib/esm/utilities/utilities.js +122 -0
  104. package/lib/esm/utilities/utilities.js.map +7 -0
  105. package/lib/iife/index.js +1 -1
  106. package/lib/iife/index.js.map +1 -1
  107. package/lib/mjs/autocomplete-scripts/bash-autocomplete-script.mjs +74 -2
  108. package/lib/mjs/autocomplete-scripts/bash-autocomplete-script.mjs.map +7 -1
  109. package/lib/mjs/autocomplete-scripts/powershell-autocomplete-script.mjs +90 -2
  110. package/lib/mjs/autocomplete-scripts/powershell-autocomplete-script.mjs.map +7 -1
  111. package/lib/mjs/autocomplete-scripts/zsh-autocomplete-script.mjs +39 -13
  112. package/lib/mjs/autocomplete-scripts/zsh-autocomplete-script.mjs.map +7 -1
  113. package/lib/mjs/cli-error/cli-error.mjs +38 -0
  114. package/lib/mjs/cli-error/cli-error.mjs.map +7 -0
  115. package/lib/mjs/cli-error/error-cause.mjs +12 -0
  116. package/lib/mjs/cli-error/error-cause.mjs.map +7 -0
  117. package/lib/mjs/cli-error/error-code/definition-error-code.mjs +23 -0
  118. package/lib/mjs/cli-error/error-code/definition-error-code.mjs.map +7 -0
  119. package/lib/mjs/cli-error/error-code/internal-error-code.mjs +10 -0
  120. package/lib/mjs/cli-error/error-code/internal-error-code.mjs.map +7 -0
  121. package/lib/mjs/cli-error/error-code/parse-error-code.mjs +18 -0
  122. package/lib/mjs/cli-error/error-code/parse-error-code.mjs.map +7 -0
  123. package/lib/mjs/cli-error/error-code/validation-error-code.mjs +17 -0
  124. package/lib/mjs/cli-error/error-code/validation-error-code.mjs.map +7 -0
  125. package/lib/mjs/cli-error/error-message/definition-error-message.mjs +70 -0
  126. package/lib/mjs/cli-error/error-message/definition-error-message.mjs.map +7 -0
  127. package/lib/mjs/cli-error/error-message/internal-error-message.mjs +16 -0
  128. package/lib/mjs/cli-error/error-message/internal-error-message.mjs.map +7 -0
  129. package/lib/mjs/cli-error/error-message/parse-error-message.mjs +40 -0
  130. package/lib/mjs/cli-error/error-message/parse-error-message.mjs.map +7 -0
  131. package/lib/mjs/cli-error/error-message/validation-error-message.mjs +60 -0
  132. package/lib/mjs/cli-error/error-message/validation-error-message.mjs.map +7 -0
  133. package/lib/mjs/coerce/coerce-methods.mjs +197 -2
  134. package/lib/mjs/coerce/coerce-methods.mjs.map +7 -1
  135. package/lib/mjs/coerce/string-to-array.mjs +17 -2
  136. package/lib/mjs/coerce/string-to-array.mjs.map +7 -1
  137. package/lib/mjs/coerce/string-to-primitive.mjs +73 -2
  138. package/lib/mjs/coerce/string-to-primitive.mjs.map +7 -1
  139. package/lib/mjs/coerce/string-to-set.mjs +17 -2
  140. package/lib/mjs/coerce/string-to-set.mjs.map +7 -1
  141. package/lib/mjs/definitions/define-arguments.mjs +10 -2
  142. package/lib/mjs/definitions/define-arguments.mjs.map +7 -1
  143. package/lib/mjs/definitions/define-cli.mjs +89 -2
  144. package/lib/mjs/definitions/define-cli.mjs.map +7 -1
  145. package/lib/mjs/definitions/define-options.mjs +10 -2
  146. package/lib/mjs/definitions/define-options.mjs.map +7 -1
  147. package/lib/mjs/definitions/define-subcommand.mjs +56 -2
  148. package/lib/mjs/definitions/define-subcommand.mjs.map +7 -1
  149. package/lib/mjs/definitions/validate-cli-definition.mjs +360 -2
  150. package/lib/mjs/definitions/validate-cli-definition.mjs.map +7 -1
  151. package/lib/mjs/help-message/format-arguments.mjs +48 -2
  152. package/lib/mjs/help-message/format-arguments.mjs.map +7 -1
  153. package/lib/mjs/help-message/format-options.mjs +50 -2
  154. package/lib/mjs/help-message/format-options.mjs.map +7 -1
  155. package/lib/mjs/help-message/format-subcommands.mjs +37 -2
  156. package/lib/mjs/help-message/format-subcommands.mjs.map +7 -1
  157. package/lib/mjs/help-message/generate-for-cli.mjs +71 -2
  158. package/lib/mjs/help-message/generate-for-cli.mjs.map +7 -1
  159. package/lib/mjs/help-message/generate-for-subcommand.mjs +23 -2
  160. package/lib/mjs/help-message/generate-for-subcommand.mjs.map +7 -1
  161. package/lib/mjs/help-message/print-help.mjs +14 -2
  162. package/lib/mjs/help-message/print-help.mjs.map +7 -1
  163. package/lib/mjs/help-message/set-defaults.mjs +29 -2
  164. package/lib/mjs/help-message/set-defaults.mjs.map +7 -1
  165. package/lib/mjs/help-message/styles.mjs +154 -2
  166. package/lib/mjs/help-message/styles.mjs.map +7 -1
  167. package/lib/mjs/help-message/terminal-markdown.mjs +121 -2
  168. package/lib/mjs/help-message/terminal-markdown.mjs.map +7 -1
  169. package/lib/mjs/index.mjs +52 -2
  170. package/lib/mjs/index.mjs.map +7 -1
  171. package/lib/mjs/markdown/generate-markdown.mjs +153 -2
  172. package/lib/mjs/markdown/generate-markdown.mjs.map +7 -1
  173. package/lib/mjs/metadata/arguments-metadata.mjs +26 -2
  174. package/lib/mjs/metadata/arguments-metadata.mjs.map +7 -1
  175. package/lib/mjs/metadata/cli-metadata.mjs +24 -2
  176. package/lib/mjs/metadata/cli-metadata.mjs.map +7 -1
  177. package/lib/mjs/metadata/options-metadata.mjs +35 -2
  178. package/lib/mjs/metadata/options-metadata.mjs.map +7 -1
  179. package/lib/mjs/metadata/subcommands-metadata.mjs +32 -2
  180. package/lib/mjs/metadata/subcommands-metadata.mjs.map +7 -1
  181. package/lib/mjs/parse/context/cli-context-builder.mjs +283 -2
  182. package/lib/mjs/parse/context/cli-context-builder.mjs.map +7 -1
  183. package/lib/mjs/parse/context/object-context-builder.mjs +62 -2
  184. package/lib/mjs/parse/context/object-context-builder.mjs.map +7 -1
  185. package/lib/mjs/parse/parser-utilities.mjs +108 -2
  186. package/lib/mjs/parse/parser-utilities.mjs.map +7 -1
  187. package/lib/mjs/parse/safe-parse.mjs +57 -2
  188. package/lib/mjs/parse/safe-parse.mjs.map +7 -1
  189. package/lib/mjs/parse/validation/validate-context.mjs +17 -2
  190. package/lib/mjs/parse/validation/validate-context.mjs.map +7 -1
  191. package/lib/mjs/parse/validation/validators/arguments.mjs +67 -2
  192. package/lib/mjs/parse/validation/validators/arguments.mjs.map +7 -1
  193. package/lib/mjs/parse/validation/validators/conflict.mjs +38 -2
  194. package/lib/mjs/parse/validation/validators/conflict.mjs.map +7 -1
  195. package/lib/mjs/parse/validation/validators/exclusive.mjs +39 -2
  196. package/lib/mjs/parse/validation/validators/exclusive.mjs.map +7 -1
  197. package/lib/mjs/parse/validation/validators/explicitly-passed.mjs +18 -2
  198. package/lib/mjs/parse/validation/validators/explicitly-passed.mjs.map +7 -1
  199. package/lib/mjs/parse/validation/validators/options.mjs +67 -2
  200. package/lib/mjs/parse/validation/validators/options.mjs.map +7 -1
  201. package/lib/mjs/parse/validation/validators/requires.mjs +43 -2
  202. package/lib/mjs/parse/validation/validators/requires.mjs.map +7 -1
  203. package/lib/mjs/utilities/parse-argv.mjs +61 -0
  204. package/lib/mjs/utilities/parse-argv.mjs.map +7 -0
  205. package/lib/mjs/utilities/schema-utilities.mjs +57 -0
  206. package/lib/mjs/utilities/schema-utilities.mjs.map +7 -0
  207. package/lib/mjs/utilities/utilities.mjs +122 -0
  208. package/lib/mjs/utilities/utilities.mjs.map +7 -0
  209. package/lib/{typescript → types}/autocomplete-scripts/bash-autocomplete-script.d.ts.map +1 -1
  210. package/lib/types/autocomplete-scripts/powershell-autocomplete-script.d.ts +15 -0
  211. package/lib/{typescript → types}/autocomplete-scripts/powershell-autocomplete-script.d.ts.map +1 -1
  212. package/lib/types/autocomplete-scripts/zsh-autocomplete-script.d.ts +4 -0
  213. package/lib/{typescript → types}/autocomplete-scripts/zsh-autocomplete-script.d.ts.map +1 -1
  214. package/lib/types/cli-error/cli-error.d.ts +152 -0
  215. package/lib/types/cli-error/cli-error.d.ts.map +1 -0
  216. package/lib/types/cli-error/error-cause.d.ts +5 -0
  217. package/lib/types/cli-error/error-cause.d.ts.map +1 -0
  218. package/lib/types/cli-error/error-code/definition-error-code.d.ts +5 -0
  219. package/lib/types/cli-error/error-code/definition-error-code.d.ts.map +1 -0
  220. package/lib/types/cli-error/error-code/internal-error-code.d.ts +5 -0
  221. package/lib/types/cli-error/error-code/internal-error-code.d.ts.map +1 -0
  222. package/lib/types/cli-error/error-code/parse-error-code.d.ts +5 -0
  223. package/lib/types/cli-error/error-code/parse-error-code.d.ts.map +1 -0
  224. package/lib/types/cli-error/error-code/validation-error-code.d.ts +5 -0
  225. package/lib/types/cli-error/error-code/validation-error-code.d.ts.map +1 -0
  226. package/lib/types/cli-error/error-message/definition-error-message.d.ts +3 -0
  227. package/lib/types/cli-error/error-message/definition-error-message.d.ts.map +1 -0
  228. package/lib/types/cli-error/error-message/internal-error-message.d.ts +3 -0
  229. package/lib/types/cli-error/error-message/internal-error-message.d.ts.map +1 -0
  230. package/lib/types/cli-error/error-message/parse-error-message.d.ts +3 -0
  231. package/lib/types/cli-error/error-message/parse-error-message.d.ts.map +1 -0
  232. package/lib/types/cli-error/error-message/validation-error-message.d.ts +3 -0
  233. package/lib/types/cli-error/error-message/validation-error-message.d.ts.map +1 -0
  234. package/lib/types/coerce/coerce-methods.d.ts +122 -0
  235. package/lib/types/coerce/coerce-methods.d.ts.map +1 -0
  236. package/lib/{typescript → types}/coerce/string-to-array.d.ts +2 -2
  237. package/lib/types/coerce/string-to-array.d.ts.map +1 -0
  238. package/lib/types/coerce/string-to-primitive.d.ts +21 -0
  239. package/lib/types/coerce/string-to-primitive.d.ts.map +1 -0
  240. package/lib/{typescript → types}/coerce/string-to-set.d.ts +2 -2
  241. package/lib/{typescript → types}/coerce/string-to-set.d.ts.map +1 -1
  242. package/lib/{typescript → types}/definitions/define-cli.d.ts +2 -6
  243. package/lib/types/definitions/define-cli.d.ts.map +1 -0
  244. package/lib/{typescript → types}/definitions/define-subcommand.d.ts +2 -4
  245. package/lib/types/definitions/define-subcommand.d.ts.map +1 -0
  246. package/lib/{typescript → types}/definitions/validate-cli-definition.d.ts +1 -1
  247. package/lib/types/definitions/validate-cli-definition.d.ts.map +1 -0
  248. package/lib/{typescript → types}/help-message/terminal-markdown.d.ts.map +1 -1
  249. package/lib/{typescript → types}/index.d.ts +7 -0
  250. package/lib/{typescript → types}/index.d.ts.map +1 -1
  251. package/lib/{typescript → types}/metadata/arguments-metadata.d.ts.map +1 -1
  252. package/lib/{typescript → types}/metadata/options-metadata.d.ts.map +1 -1
  253. package/lib/{typescript → types}/parse/context/cli-context-builder.d.ts +1 -1
  254. package/lib/{typescript → types}/parse/context/cli-context-builder.d.ts.map +1 -1
  255. package/lib/{typescript → types}/parse/context/object-context-builder.d.ts +1 -1
  256. package/lib/types/parse/context/object-context-builder.d.ts.map +1 -0
  257. package/lib/{typescript → types}/parse/parser-utilities.d.ts +9 -0
  258. package/lib/{typescript → types}/parse/parser-utilities.d.ts.map +1 -1
  259. package/lib/{typescript → types}/parse/safe-parse.d.ts.map +1 -1
  260. package/lib/{typescript → types}/parse/validation/validate-context.d.ts +1 -1
  261. package/lib/{typescript → types}/parse/validation/validate-context.d.ts.map +1 -1
  262. package/lib/{typescript → types}/parse/validation/validators/arguments.d.ts +1 -1
  263. package/lib/{typescript → types}/parse/validation/validators/arguments.d.ts.map +1 -1
  264. package/lib/{typescript → types}/parse/validation/validators/conflict.d.ts +3 -3
  265. package/lib/{typescript → types}/parse/validation/validators/conflict.d.ts.map +1 -1
  266. package/lib/{typescript → types}/parse/validation/validators/exclusive.d.ts +3 -3
  267. package/lib/{typescript → types}/parse/validation/validators/exclusive.d.ts.map +1 -1
  268. package/lib/{typescript → types}/parse/validation/validators/options.d.ts +1 -1
  269. package/lib/{typescript → types}/parse/validation/validators/options.d.ts.map +1 -1
  270. package/lib/{typescript → types}/parse/validation/validators/requires.d.ts +3 -3
  271. package/lib/{typescript → types}/parse/validation/validators/requires.d.ts.map +1 -1
  272. package/lib/{typescript → types}/types/definitions-types.d.ts +35 -4
  273. package/lib/types/types/definitions-types.d.ts.map +1 -0
  274. package/lib/types/types/error-types.d.ts +275 -0
  275. package/lib/types/types/error-types.d.ts.map +1 -0
  276. package/lib/{typescript → types}/types/io-types.d.ts +1 -1
  277. package/lib/types/types/types.d.ts +146 -0
  278. package/lib/types/types/types.d.ts.map +1 -0
  279. package/lib/{typescript → types}/types/utilities-types.d.ts +0 -2
  280. package/lib/{typescript → types}/types/utilities-types.d.ts.map +1 -1
  281. package/lib/types/utilities/parse-argv.d.ts +3 -0
  282. package/lib/types/utilities/parse-argv.d.ts.map +1 -0
  283. package/lib/types/utilities/schema-utilities.d.ts +15 -0
  284. package/lib/types/utilities/schema-utilities.d.ts.map +1 -0
  285. package/lib/{typescript → types/utilities}/utilities.d.ts +12 -15
  286. package/lib/types/utilities/utilities.d.ts.map +1 -0
  287. package/package.json +7 -7
  288. package/src/autocomplete-scripts/bash-autocomplete-script.ts +14 -12
  289. package/src/autocomplete-scripts/powershell-autocomplete-script.ts +67 -33
  290. package/src/autocomplete-scripts/zsh-autocomplete-script.ts +39 -31
  291. package/src/cli-error/cli-error.ts +44 -0
  292. package/src/cli-error/error-cause.ts +10 -0
  293. package/src/cli-error/error-code/definition-error-code.ts +21 -0
  294. package/src/cli-error/error-code/internal-error-code.ts +8 -0
  295. package/src/cli-error/error-code/parse-error-code.ts +16 -0
  296. package/src/cli-error/error-code/validation-error-code.ts +15 -0
  297. package/src/cli-error/error-message/definition-error-message.ts +144 -0
  298. package/src/cli-error/error-message/internal-error-message.ts +19 -0
  299. package/src/cli-error/error-message/parse-error-message.ts +76 -0
  300. package/src/cli-error/error-message/validation-error-message.ts +104 -0
  301. package/src/coerce/coerce-methods.ts +194 -39
  302. package/src/coerce/string-to-array.ts +2 -2
  303. package/src/coerce/string-to-primitive.ts +72 -13
  304. package/src/coerce/string-to-set.ts +2 -2
  305. package/src/definitions/define-arguments.ts +1 -1
  306. package/src/definitions/define-cli.ts +65 -30
  307. package/src/definitions/define-options.ts +1 -1
  308. package/src/definitions/define-subcommand.ts +47 -17
  309. package/src/definitions/validate-cli-definition.ts +287 -172
  310. package/src/help-message/format-arguments.ts +1 -1
  311. package/src/help-message/format-options.ts +1 -1
  312. package/src/help-message/format-subcommands.ts +1 -1
  313. package/src/help-message/generate-for-cli.ts +1 -1
  314. package/src/help-message/terminal-markdown.ts +3 -4
  315. package/src/index.ts +16 -0
  316. package/src/markdown/generate-markdown.ts +5 -4
  317. package/src/metadata/arguments-metadata.ts +2 -1
  318. package/src/metadata/options-metadata.ts +2 -1
  319. package/src/parse/context/cli-context-builder.ts +166 -39
  320. package/src/parse/context/object-context-builder.ts +37 -11
  321. package/src/parse/parser-utilities.ts +24 -10
  322. package/src/parse/safe-parse.ts +3 -6
  323. package/src/parse/validation/validate-context.ts +1 -1
  324. package/src/parse/validation/validators/arguments.ts +42 -14
  325. package/src/parse/validation/validators/conflict.ts +11 -20
  326. package/src/parse/validation/validators/exclusive.ts +16 -25
  327. package/src/parse/validation/validators/options.ts +40 -12
  328. package/src/parse/validation/validators/requires.ts +11 -20
  329. package/src/types/definitions-types.ts +36 -8
  330. package/src/types/error-types.ts +326 -0
  331. package/src/types/io-types.ts +1 -1
  332. package/src/types/types.ts +100 -7
  333. package/src/types/utilities-types.ts +0 -10
  334. package/src/utilities/parse-argv.ts +79 -0
  335. package/src/utilities/schema-utilities.ts +72 -0
  336. package/src/{utilities.ts → utilities/utilities.ts} +25 -138
  337. package/lib/cjs/autocomplete-scripts/bash-autocomplete-script.cjs +0 -2
  338. package/lib/cjs/autocomplete-scripts/bash-autocomplete-script.cjs.map +0 -1
  339. package/lib/cjs/autocomplete-scripts/powershell-autocomplete-script.cjs +0 -2
  340. package/lib/cjs/autocomplete-scripts/powershell-autocomplete-script.cjs.map +0 -1
  341. package/lib/cjs/autocomplete-scripts/zsh-autocomplete-script.cjs +0 -42
  342. package/lib/cjs/autocomplete-scripts/zsh-autocomplete-script.cjs.map +0 -1
  343. package/lib/cjs/coerce/coerce-methods.cjs +0 -2
  344. package/lib/cjs/coerce/coerce-methods.cjs.map +0 -1
  345. package/lib/cjs/coerce/string-to-array.cjs +0 -2
  346. package/lib/cjs/coerce/string-to-array.cjs.map +0 -1
  347. package/lib/cjs/coerce/string-to-primitive.cjs +0 -2
  348. package/lib/cjs/coerce/string-to-primitive.cjs.map +0 -1
  349. package/lib/cjs/coerce/string-to-set.cjs +0 -2
  350. package/lib/cjs/coerce/string-to-set.cjs.map +0 -1
  351. package/lib/cjs/definitions/define-arguments.cjs +0 -2
  352. package/lib/cjs/definitions/define-arguments.cjs.map +0 -1
  353. package/lib/cjs/definitions/define-cli.cjs +0 -2
  354. package/lib/cjs/definitions/define-cli.cjs.map +0 -1
  355. package/lib/cjs/definitions/define-options.cjs +0 -2
  356. package/lib/cjs/definitions/define-options.cjs.map +0 -1
  357. package/lib/cjs/definitions/define-subcommand.cjs +0 -2
  358. package/lib/cjs/definitions/define-subcommand.cjs.map +0 -1
  359. package/lib/cjs/definitions/validate-cli-definition.cjs +0 -2
  360. package/lib/cjs/definitions/validate-cli-definition.cjs.map +0 -1
  361. package/lib/cjs/help-message/format-arguments.cjs +0 -2
  362. package/lib/cjs/help-message/format-arguments.cjs.map +0 -1
  363. package/lib/cjs/help-message/format-options.cjs +0 -2
  364. package/lib/cjs/help-message/format-options.cjs.map +0 -1
  365. package/lib/cjs/help-message/format-subcommands.cjs +0 -2
  366. package/lib/cjs/help-message/format-subcommands.cjs.map +0 -1
  367. package/lib/cjs/help-message/generate-for-cli.cjs +0 -2
  368. package/lib/cjs/help-message/generate-for-cli.cjs.map +0 -1
  369. package/lib/cjs/help-message/generate-for-subcommand.cjs +0 -2
  370. package/lib/cjs/help-message/generate-for-subcommand.cjs.map +0 -1
  371. package/lib/cjs/help-message/print-help.cjs +0 -2
  372. package/lib/cjs/help-message/print-help.cjs.map +0 -1
  373. package/lib/cjs/help-message/set-defaults.cjs +0 -2
  374. package/lib/cjs/help-message/set-defaults.cjs.map +0 -1
  375. package/lib/cjs/help-message/styles.cjs +0 -2
  376. package/lib/cjs/help-message/styles.cjs.map +0 -1
  377. package/lib/cjs/help-message/terminal-markdown.cjs +0 -2
  378. package/lib/cjs/help-message/terminal-markdown.cjs.map +0 -1
  379. package/lib/cjs/index.cjs +0 -2
  380. package/lib/cjs/index.cjs.map +0 -1
  381. package/lib/cjs/markdown/generate-markdown.cjs +0 -2
  382. package/lib/cjs/markdown/generate-markdown.cjs.map +0 -1
  383. package/lib/cjs/metadata/arguments-metadata.cjs +0 -2
  384. package/lib/cjs/metadata/arguments-metadata.cjs.map +0 -1
  385. package/lib/cjs/metadata/cli-metadata.cjs +0 -2
  386. package/lib/cjs/metadata/cli-metadata.cjs.map +0 -1
  387. package/lib/cjs/metadata/options-metadata.cjs +0 -2
  388. package/lib/cjs/metadata/options-metadata.cjs.map +0 -1
  389. package/lib/cjs/metadata/subcommands-metadata.cjs +0 -2
  390. package/lib/cjs/metadata/subcommands-metadata.cjs.map +0 -1
  391. package/lib/cjs/parse/context/cli-context-builder.cjs +0 -2
  392. package/lib/cjs/parse/context/cli-context-builder.cjs.map +0 -1
  393. package/lib/cjs/parse/context/object-context-builder.cjs +0 -2
  394. package/lib/cjs/parse/context/object-context-builder.cjs.map +0 -1
  395. package/lib/cjs/parse/parser-utilities.cjs +0 -2
  396. package/lib/cjs/parse/parser-utilities.cjs.map +0 -1
  397. package/lib/cjs/parse/safe-parse.cjs +0 -2
  398. package/lib/cjs/parse/safe-parse.cjs.map +0 -1
  399. package/lib/cjs/parse/validation/validate-context.cjs +0 -2
  400. package/lib/cjs/parse/validation/validate-context.cjs.map +0 -1
  401. package/lib/cjs/parse/validation/validators/arguments.cjs +0 -2
  402. package/lib/cjs/parse/validation/validators/arguments.cjs.map +0 -1
  403. package/lib/cjs/parse/validation/validators/conflict.cjs +0 -2
  404. package/lib/cjs/parse/validation/validators/conflict.cjs.map +0 -1
  405. package/lib/cjs/parse/validation/validators/exclusive.cjs +0 -2
  406. package/lib/cjs/parse/validation/validators/exclusive.cjs.map +0 -1
  407. package/lib/cjs/parse/validation/validators/explicitly-passed.cjs +0 -2
  408. package/lib/cjs/parse/validation/validators/explicitly-passed.cjs.map +0 -1
  409. package/lib/cjs/parse/validation/validators/options.cjs +0 -2
  410. package/lib/cjs/parse/validation/validators/options.cjs.map +0 -1
  411. package/lib/cjs/parse/validation/validators/requires.cjs +0 -2
  412. package/lib/cjs/parse/validation/validators/requires.cjs.map +0 -1
  413. package/lib/cjs/utilities.cjs +0 -2
  414. package/lib/cjs/utilities.cjs.map +0 -1
  415. package/lib/esm/utilities.js +0 -2
  416. package/lib/esm/utilities.js.map +0 -1
  417. package/lib/mjs/utilities.mjs +0 -2
  418. package/lib/mjs/utilities.mjs.map +0 -1
  419. package/lib/typescript/autocomplete-scripts/powershell-autocomplete-script.d.ts +0 -14
  420. package/lib/typescript/autocomplete-scripts/zsh-autocomplete-script.d.ts +0 -11
  421. package/lib/typescript/coerce/coerce-methods.d.ts +0 -20
  422. package/lib/typescript/coerce/coerce-methods.d.ts.map +0 -1
  423. package/lib/typescript/coerce/string-to-array.d.ts.map +0 -1
  424. package/lib/typescript/coerce/string-to-primitive.d.ts +0 -5
  425. package/lib/typescript/coerce/string-to-primitive.d.ts.map +0 -1
  426. package/lib/typescript/definitions/define-cli.d.ts.map +0 -1
  427. package/lib/typescript/definitions/define-subcommand.d.ts.map +0 -1
  428. package/lib/typescript/definitions/validate-cli-definition.d.ts.map +0 -1
  429. package/lib/typescript/parse/context/object-context-builder.d.ts.map +0 -1
  430. package/lib/typescript/types/definitions-types.d.ts.map +0 -1
  431. package/lib/typescript/types/types.d.ts +0 -61
  432. package/lib/typescript/types/types.d.ts.map +0 -1
  433. package/lib/typescript/utilities.d.ts.map +0 -1
  434. /package/lib/{typescript → types}/autocomplete-scripts/bash-autocomplete-script.d.ts +0 -0
  435. /package/lib/{typescript → types}/definitions/define-arguments.d.ts +0 -0
  436. /package/lib/{typescript → types}/definitions/define-arguments.d.ts.map +0 -0
  437. /package/lib/{typescript → types}/definitions/define-options.d.ts +0 -0
  438. /package/lib/{typescript → types}/definitions/define-options.d.ts.map +0 -0
  439. /package/lib/{typescript → types}/help-message/format-arguments.d.ts +0 -0
  440. /package/lib/{typescript → types}/help-message/format-arguments.d.ts.map +0 -0
  441. /package/lib/{typescript → types}/help-message/format-options.d.ts +0 -0
  442. /package/lib/{typescript → types}/help-message/format-options.d.ts.map +0 -0
  443. /package/lib/{typescript → types}/help-message/format-subcommands.d.ts +0 -0
  444. /package/lib/{typescript → types}/help-message/format-subcommands.d.ts.map +0 -0
  445. /package/lib/{typescript → types}/help-message/generate-for-cli.d.ts +0 -0
  446. /package/lib/{typescript → types}/help-message/generate-for-cli.d.ts.map +0 -0
  447. /package/lib/{typescript → types}/help-message/generate-for-subcommand.d.ts +0 -0
  448. /package/lib/{typescript → types}/help-message/generate-for-subcommand.d.ts.map +0 -0
  449. /package/lib/{typescript → types}/help-message/print-help.d.ts +0 -0
  450. /package/lib/{typescript → types}/help-message/print-help.d.ts.map +0 -0
  451. /package/lib/{typescript → types}/help-message/set-defaults.d.ts +0 -0
  452. /package/lib/{typescript → types}/help-message/set-defaults.d.ts.map +0 -0
  453. /package/lib/{typescript → types}/help-message/styles.d.ts +0 -0
  454. /package/lib/{typescript → types}/help-message/styles.d.ts.map +0 -0
  455. /package/lib/{typescript → types}/help-message/terminal-markdown.d.ts +0 -0
  456. /package/lib/{typescript → types}/markdown/generate-markdown.d.ts +0 -0
  457. /package/lib/{typescript → types}/markdown/generate-markdown.d.ts.map +0 -0
  458. /package/lib/{typescript → types}/metadata/arguments-metadata.d.ts +0 -0
  459. /package/lib/{typescript → types}/metadata/cli-metadata.d.ts +0 -0
  460. /package/lib/{typescript → types}/metadata/cli-metadata.d.ts.map +0 -0
  461. /package/lib/{typescript → types}/metadata/options-metadata.d.ts +0 -0
  462. /package/lib/{typescript → types}/metadata/subcommands-metadata.d.ts +0 -0
  463. /package/lib/{typescript → types}/metadata/subcommands-metadata.d.ts.map +0 -0
  464. /package/lib/{typescript → types}/parse/safe-parse.d.ts +0 -0
  465. /package/lib/{typescript → types}/parse/validation/validators/explicitly-passed.d.ts +0 -0
  466. /package/lib/{typescript → types}/parse/validation/validators/explicitly-passed.d.ts.map +0 -0
  467. /package/lib/{typescript → types}/types/context-types.d.ts +0 -0
  468. /package/lib/{typescript → types}/types/context-types.d.ts.map +0 -0
  469. /package/lib/{typescript → types}/types/help-message-types.d.ts +0 -0
  470. /package/lib/{typescript → types}/types/help-message-types.d.ts.map +0 -0
  471. /package/lib/{typescript → types}/types/io-types.d.ts.map +0 -0
  472. /package/lib/{typescript → types}/types/metadata-types.d.ts +0 -0
  473. /package/lib/{typescript → types}/types/metadata-types.d.ts.map +0 -0
  474. /package/lib/{typescript → types}/types/schema-types.d.ts +0 -0
  475. /package/lib/{typescript → types}/types/schema-types.d.ts.map +0 -0
@@ -1,2 +1,18 @@
1
- function isArgumentExplicitlyPassed(i,t){return!!t.arguments&&(i in t.arguments&&"default"!==t.arguments[i].source)}function isOptionExplicitlyPassed(i,t){return!!t.options&&(i in t.options&&"default"!==t.options[i].source)}function isOptionOrArgumentExplicitlyPassed(i,t){return isOptionExplicitlyPassed(i,t)||isArgumentExplicitlyPassed(i,t)}export{isArgumentExplicitlyPassed,isOptionExplicitlyPassed,isOptionOrArgumentExplicitlyPassed};
2
- //# sourceMappingURL=explicitly-passed.mjs.map
1
+ // src/parse/validation/validators/explicitly-passed.ts
2
+ function isArgumentExplicitlyPassed(name, context) {
3
+ if (!context.arguments) return false;
4
+ return name in context.arguments && context.arguments[name].source !== "default";
5
+ }
6
+ function isOptionExplicitlyPassed(name, context) {
7
+ if (!context.options) return false;
8
+ return name in context.options && context.options[name].source !== "default";
9
+ }
10
+ function isOptionOrArgumentExplicitlyPassed(name, context) {
11
+ return isOptionExplicitlyPassed(name, context) || isArgumentExplicitlyPassed(name, context);
12
+ }
13
+ export {
14
+ isArgumentExplicitlyPassed,
15
+ isOptionExplicitlyPassed,
16
+ isOptionOrArgumentExplicitlyPassed
17
+ };
18
+ //# sourceMappingURL=explicitly-passed.mjs.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["isArgumentExplicitlyPassed","name","context","arguments","source","isOptionExplicitlyPassed","options","isOptionOrArgumentExplicitlyPassed"],"sources":["../../../../../src/parse/validation/validators/explicitly-passed.ts"],"sourcesContent":["import type { ContextWide } from \"../../../types/context-types.ts\";\n\nexport function isArgumentExplicitlyPassed(name: string, context: ContextWide) {\n if (!context.arguments) return false;\n return name in context.arguments && context.arguments[name].source !== \"default\";\n}\n\nexport function isOptionExplicitlyPassed(name: string, context: ContextWide) {\n if (!context.options) return false;\n return name in context.options && context.options[name].source !== \"default\";\n}\n\nexport function isOptionOrArgumentExplicitlyPassed(name: string, context: ContextWide) {\n return isOptionExplicitlyPassed(name, context) || isArgumentExplicitlyPassed(name, context);\n}\n"],"mappings":"AAEO,SAASA,2BAA2BC,EAAcC,GACvD,QAAKA,EAAQC,YACNF,KAAQC,EAAQC,WAAgD,YAAnCD,EAAQC,UAAUF,GAAMG,OAC9D,CAEO,SAASC,yBAAyBJ,EAAcC,GACrD,QAAKA,EAAQI,UACNL,KAAQC,EAAQI,SAA4C,YAAjCJ,EAAQI,QAAQL,GAAMG,OAC1D,CAEO,SAASG,mCAAmCN,EAAcC,GAC/D,OAAOG,yBAAyBJ,EAAMC,IAAYF,2BAA2BC,EAAMC,EACrF,Q","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/parse/validation/validators/explicitly-passed.ts"],
4
+ "sourcesContent": ["import type { ContextWide } from \"../../../types/context-types.ts\";\n\nexport function isArgumentExplicitlyPassed(name: string, context: ContextWide) {\n if (!context.arguments) return false;\n return name in context.arguments && context.arguments[name].source !== \"default\";\n}\n\nexport function isOptionExplicitlyPassed(name: string, context: ContextWide) {\n if (!context.options) return false;\n return name in context.options && context.options[name].source !== \"default\";\n}\n\nexport function isOptionOrArgumentExplicitlyPassed(name: string, context: ContextWide) {\n return isOptionExplicitlyPassed(name, context) || isArgumentExplicitlyPassed(name, context);\n}\n"],
5
+ "mappings": ";AAEO,SAAS,2BAA2B,MAAc,SAAsB;AAC7E,MAAI,CAAC,QAAQ,UAAW,QAAO;AAC/B,SAAO,QAAQ,QAAQ,aAAa,QAAQ,UAAU,IAAI,EAAE,WAAW;AACzE;AAEO,SAAS,yBAAyB,MAAc,SAAsB;AAC3E,MAAI,CAAC,QAAQ,QAAS,QAAO;AAC7B,SAAO,QAAQ,QAAQ,WAAW,QAAQ,QAAQ,IAAI,EAAE,WAAW;AACrE;AAEO,SAAS,mCAAmC,MAAc,SAAsB;AACrF,SAAO,yBAAyB,MAAM,OAAO,KAAK,2BAA2B,MAAM,OAAO;AAC5F;",
6
+ "names": []
7
+ }
@@ -1,2 +1,67 @@
1
- import{validateSync}from"../../../utilities.mjs";import{validateConflictWith}from"./conflict.mjs";import{validateExclusive}from"./exclusive.mjs";import{validateRequires}from"./requires.mjs";function validateOptions({commandDefinition:o,context:t,output:e}){if(!t.options)return;e.options??(e.options={});const i=o.options;if(!i)throw new Error(`subcommand "${t.subcommand}" does not have options`);for(const[e,n]of Object.entries(i))validateRequires({name:e,commandDefinition:o,optionOrArgument:n,context:t,type:"option"}),validateExclusive({name:e,optionOrArgument:n,context:t,type:"option"}),validateConflictWith({name:e,optionOrArgument:n,context:t,type:"option"});const n=Object.entries(t.options);for(const[o,{passedValue:r,stringValue:a,flag:s,source:p,schema:m}]of n){const n=i[o];if(!n)throw new Error(`subcommand "${t.subcommand}" does not have option "${o}"`);if(!n._preparedType)throw new Error(`internal error: missing prepared type for option "${o}"`);const c="programmatic"===p,l=c?validateSync(m,r):n._preparedType.validate(a);if(l.issues)throw new Error(`invalid value ${c?"":`"${a}"`} for "${c?o:s}": ${l.issues.map(o=>o.message).join(", ")}`);e.options[o]=l.value}}export{validateOptions};
2
- //# sourceMappingURL=options.mjs.map
1
+ // src/parse/validation/validators/options.ts
2
+ import { CliError } from "../../../cli-error/cli-error.mjs";
3
+ import { ErrorCause } from "../../../cli-error/error-cause.mjs";
4
+ import { InternalErrorCode } from "../../../cli-error/error-code/internal-error-code.mjs";
5
+ import { ValidationErrorCode } from "../../../cli-error/error-code/validation-error-code.mjs";
6
+ import { validateSync } from "../../../utilities/schema-utilities.mjs";
7
+ import { validateConflictWith } from "./conflict.mjs";
8
+ import { validateExclusive } from "./exclusive.mjs";
9
+ import { validateRequires } from "./requires.mjs";
10
+ function validateOptions({ commandDefinition, context, output }) {
11
+ if (!context.options) return;
12
+ output.options ??= {};
13
+ const commandKind = "cliName" in commandDefinition ? "command" : "subcommand";
14
+ const commandName = "cliName" in commandDefinition ? commandDefinition.cliName : commandDefinition.name;
15
+ const optionsDefinition = commandDefinition.options;
16
+ if (!optionsDefinition) {
17
+ throw new CliError({
18
+ cause: ErrorCause.Validation,
19
+ code: ValidationErrorCode.NoOptionsToValidate,
20
+ context: { commandKind, commandName }
21
+ });
22
+ }
23
+ for (const [optionName, option] of Object.entries(optionsDefinition)) {
24
+ validateRequires({ name: optionName, commandDefinition, optionOrArgument: option, context, kind: "option" });
25
+ validateExclusive({ name: optionName, optionOrArgument: option, context, kind: "option" });
26
+ validateConflictWith({ name: optionName, optionOrArgument: option, context, kind: "option" });
27
+ }
28
+ const optionContextEntries = Object.entries(context.options);
29
+ for (const [optionName, { passedValue, stringValue, source, schema }] of optionContextEntries) {
30
+ const option = optionsDefinition[optionName];
31
+ if (!option) {
32
+ throw new CliError({
33
+ cause: ErrorCause.Validation,
34
+ code: ValidationErrorCode.UnknownOptionValidation,
35
+ context: { commandKind, commandName, optionName }
36
+ });
37
+ }
38
+ if (!option._preparedType) {
39
+ throw new CliError({
40
+ cause: ErrorCause.Internal,
41
+ code: InternalErrorCode.MissingPreparedTypes,
42
+ context: { commandKind, commandName, kind: "option", name: optionName }
43
+ });
44
+ }
45
+ const isProgrammatic = source === "programmatic";
46
+ const safeParseResult = isProgrammatic ? validateSync(schema, passedValue) : option._preparedType.validate(stringValue);
47
+ if (safeParseResult.issues) {
48
+ throw new CliError({
49
+ cause: ErrorCause.Validation,
50
+ code: ValidationErrorCode.SchemaValidationFailed,
51
+ context: {
52
+ commandKind,
53
+ commandName,
54
+ kind: "option",
55
+ name: optionName,
56
+ inputValue: isProgrammatic ? passedValue : stringValue,
57
+ issues: safeParseResult.issues
58
+ }
59
+ });
60
+ }
61
+ output.options[optionName] = safeParseResult.value;
62
+ }
63
+ }
64
+ export {
65
+ validateOptions
66
+ };
67
+ //# sourceMappingURL=options.mjs.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["validateSync","validateConflictWith","validateExclusive","validateRequires","validateOptions","commandDefinition","context","output","options","optionsDefinition","Error","subcommand","optionName","option","Object","entries","name","optionOrArgument","type","optionContextEntries","passedValue","stringValue","flag","source","schema","_preparedType","isProgrammatic","safeParseResult","validate","issues","map","issue","message","join","value"],"sources":["../../../../../src/parse/validation/validators/options.ts"],"sourcesContent":["import { validateSync } from \"../../../utilities.ts\";\nimport { validateConflictWith } from \"./conflict.ts\";\nimport { validateExclusive } from \"./exclusive.ts\";\nimport { validateRequires } from \"./requires.ts\";\n\nimport type { ContextWide } from \"../../../types/context-types.ts\";\nimport type { Cli, Subcommand } from \"../../../types/definitions-types.ts\";\nimport type { OutputTypeWide } from \"../../../types/io-types.ts\";\n\ninterface ValidateOptions {\n commandDefinition: Subcommand | Cli;\n context: ContextWide;\n output: OutputTypeWide;\n}\n\n/** @throws {Error} */\nexport function validateOptions({ commandDefinition, context, output }: ValidateOptions) {\n if (!context.options) return;\n\n output.options ??= {};\n\n const optionsDefinition = commandDefinition.options;\n if (!optionsDefinition) {\n throw new Error(`subcommand \"${context.subcommand}\" does not have options`);\n }\n\n for (const [optionName, option] of Object.entries(optionsDefinition)) {\n validateRequires({ name: optionName, commandDefinition, optionOrArgument: option, context, type: \"option\" });\n validateExclusive({ name: optionName, optionOrArgument: option, context, type: \"option\" });\n validateConflictWith({ name: optionName, optionOrArgument: option, context, type: \"option\" });\n }\n\n const optionContextEntries = Object.entries(context.options);\n\n for (const [optionName, { passedValue, stringValue, flag, source, schema }] of optionContextEntries) {\n const option = optionsDefinition[optionName];\n if (!option) {\n throw new Error(`subcommand \"${context.subcommand}\" does not have option \"${optionName}\"`);\n }\n\n if (!option._preparedType) {\n throw new Error(`internal error: missing prepared type for option \"${optionName}\"`);\n }\n\n const isProgrammatic = source === \"programmatic\";\n\n const safeParseResult = isProgrammatic\n ? validateSync(schema, passedValue)\n : option._preparedType.validate(stringValue);\n\n if (safeParseResult.issues) {\n throw new Error(\n `invalid value ${isProgrammatic ? \"\" : `\"${stringValue}\"`} for \"${isProgrammatic ? optionName : flag}\": ${safeParseResult.issues.map(issue => issue.message).join(\", \")}`,\n );\n }\n\n output.options[optionName] = safeParseResult.value;\n }\n}\n"],"mappings":"OAASA,iBAAoB,gCACpBC,yBAA4B,wBAC5BC,sBAAyB,yBACzBC,qBAAwB,iBAa1B,SAASC,iBAAgBC,kBAAEA,EAAAC,QAAmBA,EAAAC,OAASA,IAC5D,IAAKD,EAAQE,QAAS,OAEtBD,EAAOC,UAAPD,EAAOC,QAAY,CAAC,GAEpB,MAAMC,EAAoBJ,EAAkBG,QAC5C,IAAKC,EACH,MAAM,IAAIC,MAAM,eAAeJ,EAAQK,qCAGzC,UAAYC,EAAYC,KAAWC,OAAOC,QAAQN,GAChDN,iBAAiB,CAAEa,KAAMJ,EAAYP,oBAAmBY,iBAAkBJ,EAAQP,UAASY,KAAM,WACjGhB,kBAAkB,CAAEc,KAAMJ,EAAYK,iBAAkBJ,EAAQP,UAASY,KAAM,WAC/EjB,qBAAqB,CAAEe,KAAMJ,EAAYK,iBAAkBJ,EAAQP,UAASY,KAAM,WAGpF,MAAMC,EAAuBL,OAAOC,QAAQT,EAAQE,SAEpD,UAAYI,GAAYQ,YAAEA,EAAAC,YAAaA,EAAAC,KAAaA,EAAAC,OAAMA,EAAAC,OAAQA,MAAaL,EAAsB,CACnG,MAAMN,EAASJ,EAAkBG,GACjC,IAAKC,EACH,MAAM,IAAIH,MAAM,eAAeJ,EAAQK,qCAAqCC,MAG9E,IAAKC,EAAOY,cACV,MAAM,IAAIf,MAAM,qDAAqDE,MAGvE,MAAMc,EAA4B,iBAAXH,EAEjBI,EAAkBD,EACpB1B,aAAawB,EAAQJ,GACrBP,EAAOY,cAAcG,SAASP,GAElC,GAAIM,EAAgBE,OAClB,MAAM,IAAInB,MACR,iBAAiBgB,EAAiB,GAAK,IAAIL,aAAuBK,EAAiBd,EAAaU,OAAUK,EAAgBE,OAAOC,IAAIC,GAASA,EAAMC,SAASC,KAAK,SAItK1B,EAAOC,QAAQI,GAAce,EAAgBO,KAC/C,CACF,Q","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/parse/validation/validators/options.ts"],
4
+ "sourcesContent": ["import { CliError } from \"../../../cli-error/cli-error.ts\";\nimport { ErrorCause } from \"../../../cli-error/error-cause.ts\";\nimport { InternalErrorCode } from \"../../../cli-error/error-code/internal-error-code.ts\";\nimport { ValidationErrorCode } from \"../../../cli-error/error-code/validation-error-code.ts\";\nimport { validateSync } from \"../../../utilities/schema-utilities.ts\";\nimport { validateConflictWith } from \"./conflict.ts\";\nimport { validateExclusive } from \"./exclusive.ts\";\nimport { validateRequires } from \"./requires.ts\";\n\nimport type { ContextWide } from \"../../../types/context-types.ts\";\nimport type { Cli, Subcommand } from \"../../../types/definitions-types.ts\";\nimport type { OutputTypeWide } from \"../../../types/io-types.ts\";\n\ninterface ValidateOptions {\n commandDefinition: Subcommand | Cli;\n context: ContextWide;\n output: OutputTypeWide;\n}\n\n/** @throws {CliError} */\nexport function validateOptions({ commandDefinition, context, output }: ValidateOptions) {\n if (!context.options) return;\n\n output.options ??= {};\n\n const commandKind = \"cliName\" in commandDefinition ? \"command\" : \"subcommand\";\n const commandName = \"cliName\" in commandDefinition ? commandDefinition.cliName : commandDefinition.name;\n\n const optionsDefinition = commandDefinition.options;\n if (!optionsDefinition) {\n throw new CliError({\n cause: ErrorCause.Validation,\n code: ValidationErrorCode.NoOptionsToValidate,\n context: { commandKind, commandName },\n });\n }\n\n for (const [optionName, option] of Object.entries(optionsDefinition)) {\n validateRequires({ name: optionName, commandDefinition, optionOrArgument: option, context, kind: \"option\" });\n validateExclusive({ name: optionName, optionOrArgument: option, context, kind: \"option\" });\n validateConflictWith({ name: optionName, optionOrArgument: option, context, kind: \"option\" });\n }\n\n const optionContextEntries = Object.entries(context.options);\n\n for (const [optionName, { passedValue, stringValue, source, schema }] of optionContextEntries) {\n const option = optionsDefinition[optionName];\n if (!option) {\n throw new CliError({\n cause: ErrorCause.Validation,\n code: ValidationErrorCode.UnknownOptionValidation,\n context: { commandKind, commandName, optionName },\n });\n }\n\n if (!option._preparedType) {\n throw new CliError({\n cause: ErrorCause.Internal,\n code: InternalErrorCode.MissingPreparedTypes,\n context: { commandKind, commandName, kind: \"option\", name: optionName },\n });\n }\n\n const isProgrammatic = source === \"programmatic\";\n\n const safeParseResult = isProgrammatic\n ? validateSync(schema, passedValue)\n : option._preparedType.validate(stringValue);\n\n if (safeParseResult.issues) {\n throw new CliError({\n cause: ErrorCause.Validation,\n code: ValidationErrorCode.SchemaValidationFailed,\n context: {\n commandKind,\n commandName,\n kind: \"option\",\n name: optionName,\n inputValue: isProgrammatic ? passedValue : stringValue,\n issues: safeParseResult.issues,\n },\n });\n }\n\n output.options[optionName] = safeParseResult.value;\n }\n}\n"],
5
+ "mappings": ";AAAA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAC7B,SAAS,4BAA4B;AACrC,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAa1B,SAAS,gBAAgB,EAAE,mBAAmB,SAAS,OAAO,GAAoB;AACvF,MAAI,CAAC,QAAQ,QAAS;AAEtB,SAAO,YAAY,CAAC;AAEpB,QAAM,cAAc,aAAa,oBAAoB,YAAY;AACjE,QAAM,cAAc,aAAa,oBAAoB,kBAAkB,UAAU,kBAAkB;AAEnG,QAAM,oBAAoB,kBAAkB;AAC5C,MAAI,CAAC,mBAAmB;AACtB,UAAM,IAAI,SAAS;AAAA,MACjB,OAAO,WAAW;AAAA,MAClB,MAAM,oBAAoB;AAAA,MAC1B,SAAS,EAAE,aAAa,YAAY;AAAA,IACtC,CAAC;AAAA,EACH;AAEA,aAAW,CAAC,YAAY,MAAM,KAAK,OAAO,QAAQ,iBAAiB,GAAG;AACpE,qBAAiB,EAAE,MAAM,YAAY,mBAAmB,kBAAkB,QAAQ,SAAS,MAAM,SAAS,CAAC;AAC3G,sBAAkB,EAAE,MAAM,YAAY,kBAAkB,QAAQ,SAAS,MAAM,SAAS,CAAC;AACzF,yBAAqB,EAAE,MAAM,YAAY,kBAAkB,QAAQ,SAAS,MAAM,SAAS,CAAC;AAAA,EAC9F;AAEA,QAAM,uBAAuB,OAAO,QAAQ,QAAQ,OAAO;AAE3D,aAAW,CAAC,YAAY,EAAE,aAAa,aAAa,QAAQ,OAAO,CAAC,KAAK,sBAAsB;AAC7F,UAAM,SAAS,kBAAkB,UAAU;AAC3C,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,SAAS;AAAA,QACjB,OAAO,WAAW;AAAA,QAClB,MAAM,oBAAoB;AAAA,QAC1B,SAAS,EAAE,aAAa,aAAa,WAAW;AAAA,MAClD,CAAC;AAAA,IACH;AAEA,QAAI,CAAC,OAAO,eAAe;AACzB,YAAM,IAAI,SAAS;AAAA,QACjB,OAAO,WAAW;AAAA,QAClB,MAAM,kBAAkB;AAAA,QACxB,SAAS,EAAE,aAAa,aAAa,MAAM,UAAU,MAAM,WAAW;AAAA,MACxE,CAAC;AAAA,IACH;AAEA,UAAM,iBAAiB,WAAW;AAElC,UAAM,kBAAkB,iBACpB,aAAa,QAAQ,WAAW,IAChC,OAAO,cAAc,SAAS,WAAW;AAE7C,QAAI,gBAAgB,QAAQ;AAC1B,YAAM,IAAI,SAAS;AAAA,QACjB,OAAO,WAAW;AAAA,QAClB,MAAM,oBAAoB;AAAA,QAC1B,SAAS;AAAA,UACP;AAAA,UACA;AAAA,UACA,MAAM;AAAA,UACN,MAAM;AAAA,UACN,YAAY,iBAAiB,cAAc;AAAA,UAC3C,QAAQ,gBAAgB;AAAA,QAC1B;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WAAO,QAAQ,UAAU,IAAI,gBAAgB;AAAA,EAC/C;AACF;",
6
+ "names": []
7
+ }
@@ -1,2 +1,43 @@
1
- import{isArgumentExplicitlyPassed,isOptionExplicitlyPassed,isOptionOrArgumentExplicitlyPassed}from"./explicitly-passed.mjs";function validateRequires({name:t,commandDefinition:i,optionOrArgument:n,context:e,type:s}){const o=n.requires;if(!o||0===o.length)return;if(!isOptionOrArgumentExplicitlyPassed(t,e))return;const r=i.options??{},p=[],l=[];for(const t of o){const i=t in r;(i?isOptionExplicitlyPassed(t,e):isArgumentExplicitlyPassed(t,e))||(i?p.push(t):l.push(t))}if(0===p.length&&0===l.length)return;const u=[];if(p.length>0){const t=p.map(t=>`"${t}"`).join(", "),i=p.length>1?"s":"";u.push(`option${i} ${t}`)}if(l.length>0){const t=l.map(t=>`"${t}"`).join(", "),i=l.length>1?"s":"";u.push(`argument${i} ${t}`)}const c=u.join(" and ");throw new Error(`${s} "${t}" cannot be used without the required ${c}.`)}export{validateRequires};
2
- //# sourceMappingURL=requires.mjs.map
1
+ // src/parse/validation/validators/requires.ts
2
+ import { CliError } from "../../../cli-error/cli-error.mjs";
3
+ import { ErrorCause } from "../../../cli-error/error-cause.mjs";
4
+ import { ValidationErrorCode } from "../../../cli-error/error-code/validation-error-code.mjs";
5
+ import {
6
+ isArgumentExplicitlyPassed,
7
+ isOptionExplicitlyPassed,
8
+ isOptionOrArgumentExplicitlyPassed
9
+ } from "./explicitly-passed.mjs";
10
+ function validateRequires({
11
+ name,
12
+ commandDefinition,
13
+ optionOrArgument,
14
+ context,
15
+ kind
16
+ }) {
17
+ const requires = optionOrArgument.requires;
18
+ if (!requires || requires.length === 0) return;
19
+ if (!isOptionOrArgumentExplicitlyPassed(name, context)) return;
20
+ const optionsDefinition = commandDefinition.options ?? {};
21
+ const missingOptions = [];
22
+ const missingArguments = [];
23
+ for (const requiredName of requires) {
24
+ const isOption = requiredName in optionsDefinition;
25
+ const provided = isOption ? isOptionExplicitlyPassed(requiredName, context) : isArgumentExplicitlyPassed(requiredName, context);
26
+ if (provided) continue;
27
+ if (isOption) {
28
+ missingOptions.push(requiredName);
29
+ continue;
30
+ }
31
+ missingArguments.push(requiredName);
32
+ }
33
+ if (missingOptions.length === 0 && missingArguments.length === 0) return;
34
+ throw new CliError({
35
+ cause: ErrorCause.Validation,
36
+ code: ValidationErrorCode.RequiredDependencyMissing,
37
+ context: { kind, name, missingArguments, missingOptions }
38
+ });
39
+ }
40
+ export {
41
+ validateRequires
42
+ };
43
+ //# sourceMappingURL=requires.mjs.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["isArgumentExplicitlyPassed","isOptionExplicitlyPassed","isOptionOrArgumentExplicitlyPassed","validateRequires","name","commandDefinition","optionOrArgument","context","type","requires","length","optionsDefinition","options","missingOptions","missingArguments","requiredName","isOption","push","parts","formatted","map","o","join","s","a","joinedParts","Error"],"sources":["../../../../../src/parse/validation/validators/requires.ts"],"sourcesContent":["import {\n isArgumentExplicitlyPassed,\n isOptionExplicitlyPassed,\n isOptionOrArgumentExplicitlyPassed,\n} from \"./explicitly-passed.ts\";\n\nimport type { ContextWide } from \"../../../types/context-types.ts\";\nimport type { Argument, Cli, Option, Subcommand } from \"../../../types/definitions-types.ts\";\n\ninterface ValidateRequiresOptions {\n /** The option or argument name to check its `requires` */\n name: string;\n\n /** The subcommand or cli configuration */\n commandDefinition: Subcommand | Cli;\n\n /** The option or argument to check */\n optionOrArgument: Option | Argument;\n\n /** The parsed context */\n context: ContextWide;\n\n /** What we're checking */\n type: \"option\" | \"argument\";\n}\n\n/** @throws {Error} */\nexport function validateRequires({\n name,\n commandDefinition,\n optionOrArgument,\n context,\n type,\n}: ValidateRequiresOptions) {\n const requires = optionOrArgument.requires;\n if (!requires || requires.length === 0) return;\n\n // Check if the options/argument is passed\n if (!isOptionOrArgumentExplicitlyPassed(name, context)) return;\n\n const optionsDefinition = commandDefinition.options ?? {};\n\n const missingOptions: string[] = [];\n const missingArguments: string[] = [];\n\n for (const requiredName of requires) {\n const isOption = requiredName in optionsDefinition;\n\n const provided = isOption\n ? isOptionExplicitlyPassed(requiredName, context)\n : isArgumentExplicitlyPassed(requiredName, context);\n\n if (provided) continue;\n\n if (isOption) {\n missingOptions.push(requiredName);\n continue;\n }\n\n missingArguments.push(requiredName);\n }\n\n if (missingOptions.length === 0 && missingArguments.length === 0) return; // OK\n\n const parts: string[] = [];\n\n if (missingOptions.length > 0) {\n const formatted = missingOptions.map(o => `\"${o}\"`).join(\", \");\n const s = missingOptions.length > 1 ? \"s\" : \"\";\n parts.push(`option${s} ${formatted}`);\n }\n\n if (missingArguments.length > 0) {\n const formatted = missingArguments.map(a => `\"${a}\"`).join(\", \");\n const s = missingArguments.length > 1 ? \"s\" : \"\";\n parts.push(`argument${s} ${formatted}`);\n }\n\n const joinedParts = parts.join(\" and \");\n\n throw new Error(`${type} \"${name}\" cannot be used without the required ${joinedParts}.`);\n}\n"],"mappings":"OACEA,2BACAC,yBACAC,uCACK,0BAuBA,SAASC,kBAAiBC,KAC/BA,EAAAC,kBACAA,EAAAC,iBACAA,EAAAC,QACAA,EAAAC,KACAA,IAEA,MAAMC,EAAWH,EAAiBG,SAClC,IAAKA,GAAgC,IAApBA,EAASC,OAAc,OAGxC,IAAKR,mCAAmCE,EAAMG,GAAU,OAExD,MAAMI,EAAoBN,EAAkBO,SAAW,CAAC,EAElDC,EAA2B,GAC3BC,EAA6B,GAEnC,UAAWC,KAAgBN,EAAU,CACnC,MAAMO,EAAWD,KAAgBJ,GAEhBK,EACbf,yBAAyBc,EAAcR,GACvCP,2BAA2Be,EAAcR,MAIzCS,EACFH,EAAeI,KAAKF,GAItBD,EAAiBG,KAAKF,GACxB,CAEA,GAA8B,IAA1BF,EAAeH,QAA4C,IAA5BI,EAAiBJ,OAAc,OAElE,MAAMQ,EAAkB,GAExB,GAAIL,EAAeH,OAAS,EAAG,CAC7B,MAAMS,EAAYN,EAAeO,IAAIC,GAAK,IAAIA,MAAMC,KAAK,MACnDC,EAAIV,EAAeH,OAAS,EAAI,IAAM,GAC5CQ,EAAMD,KAAK,SAASM,KAAKJ,IAC3B,CAEA,GAAIL,EAAiBJ,OAAS,EAAG,CAC/B,MAAMS,EAAYL,EAAiBM,IAAII,GAAK,IAAIA,MAAMF,KAAK,MACrDC,EAAIT,EAAiBJ,OAAS,EAAI,IAAM,GAC9CQ,EAAMD,KAAK,WAAWM,KAAKJ,IAC7B,CAEA,MAAMM,EAAcP,EAAMI,KAAK,SAE/B,MAAM,IAAII,MAAM,GAAGlB,MAASJ,0CAA6CqB,KAC3E,Q","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/parse/validation/validators/requires.ts"],
4
+ "sourcesContent": ["import { CliError } from \"../../../cli-error/cli-error.ts\";\nimport { ErrorCause } from \"../../../cli-error/error-cause.ts\";\nimport { ValidationErrorCode } from \"../../../cli-error/error-code/validation-error-code.ts\";\nimport {\n isArgumentExplicitlyPassed,\n isOptionExplicitlyPassed,\n isOptionOrArgumentExplicitlyPassed,\n} from \"./explicitly-passed.ts\";\n\nimport type { ContextWide } from \"../../../types/context-types.ts\";\nimport type { Argument, Cli, Option, Subcommand } from \"../../../types/definitions-types.ts\";\n\ninterface ValidateRequiresOptions {\n /** The option or argument name to check its `requires` */\n name: string;\n\n /** The subcommand or cli configuration */\n commandDefinition: Subcommand | Cli;\n\n /** The option or argument to check */\n optionOrArgument: Option | Argument;\n\n /** The parsed context */\n context: ContextWide;\n\n /** What we're checking */\n kind: \"option\" | \"argument\";\n}\n\n/** @throws {CliError} */\nexport function validateRequires({\n name,\n commandDefinition,\n optionOrArgument,\n context,\n kind,\n}: ValidateRequiresOptions) {\n const requires = optionOrArgument.requires;\n if (!requires || requires.length === 0) return;\n\n // Check if the options/argument is passed\n if (!isOptionOrArgumentExplicitlyPassed(name, context)) return;\n\n const optionsDefinition = commandDefinition.options ?? {};\n\n const missingOptions: string[] = [];\n const missingArguments: string[] = [];\n\n for (const requiredName of requires) {\n const isOption = requiredName in optionsDefinition;\n\n const provided = isOption\n ? isOptionExplicitlyPassed(requiredName, context)\n : isArgumentExplicitlyPassed(requiredName, context);\n\n if (provided) continue;\n\n if (isOption) {\n missingOptions.push(requiredName);\n continue;\n }\n\n missingArguments.push(requiredName);\n }\n\n if (missingOptions.length === 0 && missingArguments.length === 0) return; // OK\n\n throw new CliError({\n cause: ErrorCause.Validation,\n code: ValidationErrorCode.RequiredDependencyMissing,\n context: { kind, name, missingArguments, missingOptions },\n });\n}\n"],
5
+ "mappings": ";AAAA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAuBA,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA4B;AAC1B,QAAM,WAAW,iBAAiB;AAClC,MAAI,CAAC,YAAY,SAAS,WAAW,EAAG;AAGxC,MAAI,CAAC,mCAAmC,MAAM,OAAO,EAAG;AAExD,QAAM,oBAAoB,kBAAkB,WAAW,CAAC;AAExD,QAAM,iBAA2B,CAAC;AAClC,QAAM,mBAA6B,CAAC;AAEpC,aAAW,gBAAgB,UAAU;AACnC,UAAM,WAAW,gBAAgB;AAEjC,UAAM,WAAW,WACb,yBAAyB,cAAc,OAAO,IAC9C,2BAA2B,cAAc,OAAO;AAEpD,QAAI,SAAU;AAEd,QAAI,UAAU;AACZ,qBAAe,KAAK,YAAY;AAChC;AAAA,IACF;AAEA,qBAAiB,KAAK,YAAY;AAAA,EACpC;AAEA,MAAI,eAAe,WAAW,KAAK,iBAAiB,WAAW,EAAG;AAElE,QAAM,IAAI,SAAS;AAAA,IACjB,OAAO,WAAW;AAAA,IAClB,MAAM,oBAAoB;AAAA,IAC1B,SAAS,EAAE,MAAM,MAAM,kBAAkB,eAAe;AAAA,EAC1D,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -0,0 +1,61 @@
1
+ // src/utilities/parse-argv.ts
2
+ function parseArgv(input) {
3
+ const argv = [];
4
+ let currentQuote = void 0;
5
+ let currentArgument = void 0;
6
+ for (let index = 0; index < input.length; index++) {
7
+ const char = input[index];
8
+ const previousChar = input[index - 1];
9
+ const nextChar = input[index + 1];
10
+ const end = index === input.length - 1;
11
+ if ((char === '"' || char === "'") && previousChar !== "\\") {
12
+ if (currentQuote === char) {
13
+ currentQuote = void 0;
14
+ continue;
15
+ }
16
+ if (currentQuote === void 0) {
17
+ currentQuote = char;
18
+ continue;
19
+ }
20
+ if (currentQuote !== void 0 && char !== currentQuote) {
21
+ currentArgument ??= "";
22
+ currentArgument += char;
23
+ continue;
24
+ }
25
+ continue;
26
+ }
27
+ if (char === "\\" && nextChar === "\n") {
28
+ index++;
29
+ continue;
30
+ }
31
+ if (currentArgument !== void 0 && currentQuote === void 0) {
32
+ if (char === " ") {
33
+ argv.push(currentArgument);
34
+ currentArgument = void 0;
35
+ continue;
36
+ }
37
+ if (end) {
38
+ currentArgument += char;
39
+ argv.push(currentArgument);
40
+ currentArgument = void 0;
41
+ continue;
42
+ }
43
+ }
44
+ if (char === " " && currentQuote === void 0) {
45
+ continue;
46
+ }
47
+ if (char === "\\" && (nextChar === "'" || nextChar === '"')) {
48
+ continue;
49
+ }
50
+ currentArgument ??= "";
51
+ currentArgument += char;
52
+ }
53
+ if (currentArgument !== void 0) {
54
+ argv.push(currentArgument);
55
+ }
56
+ return argv;
57
+ }
58
+ export {
59
+ parseArgv
60
+ };
61
+ //# sourceMappingURL=parse-argv.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utilities/parse-argv.ts"],
4
+ "sourcesContent": ["/** Parse a string into an argv (array of arguments) */\nexport function parseArgv(input: string): string[] {\n const argv = [];\n\n let currentQuote: string | undefined = undefined;\n let currentArgument: string | undefined = undefined;\n\n for (let index = 0; index < input.length; index++) {\n const char = input[index];\n const previousChar = input[index - 1];\n const nextChar = input[index + 1];\n const end = index === input.length - 1;\n\n // entering/leaving quote\n if ((char === '\"' || char === \"'\") && previousChar !== \"\\\\\") {\n // leaving quote\n if (currentQuote === char) {\n currentQuote = undefined;\n continue;\n }\n\n // entering quote\n if (currentQuote === undefined) {\n currentQuote = char;\n continue;\n }\n\n // quote inside quote\n if (currentQuote !== undefined && char !== currentQuote) {\n currentArgument ??= \"\";\n currentArgument += char;\n continue;\n }\n continue;\n }\n\n // new line\n if (char === \"\\\\\" && nextChar === \"\\n\") {\n index++;\n continue;\n }\n\n // Add to argv\n if (currentArgument !== undefined && currentQuote === undefined) {\n if (char === \" \") {\n argv.push(currentArgument);\n currentArgument = undefined;\n continue;\n }\n\n if (end) {\n currentArgument += char;\n argv.push(currentArgument);\n currentArgument = undefined;\n continue;\n }\n }\n\n // Ignore spaces outside of quotes\n if (char === \" \" && currentQuote === undefined) {\n continue;\n }\n\n // Ignore escaped characters\n if (char === \"\\\\\" && (nextChar === \"'\" || nextChar === '\"')) {\n continue;\n }\n\n currentArgument ??= \"\";\n currentArgument += char;\n }\n\n // Add last argument\n if (currentArgument !== undefined) {\n argv.push(currentArgument);\n }\n\n return argv;\n}\n"],
5
+ "mappings": ";AACO,SAAS,UAAU,OAAyB;AACjD,QAAM,OAAO,CAAC;AAEd,MAAI,eAAmC;AACvC,MAAI,kBAAsC;AAE1C,WAAS,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;AACjD,UAAM,OAAO,MAAM,KAAK;AACxB,UAAM,eAAe,MAAM,QAAQ,CAAC;AACpC,UAAM,WAAW,MAAM,QAAQ,CAAC;AAChC,UAAM,MAAM,UAAU,MAAM,SAAS;AAGrC,SAAK,SAAS,OAAO,SAAS,QAAQ,iBAAiB,MAAM;AAE3D,UAAI,iBAAiB,MAAM;AACzB,uBAAe;AACf;AAAA,MACF;AAGA,UAAI,iBAAiB,QAAW;AAC9B,uBAAe;AACf;AAAA,MACF;AAGA,UAAI,iBAAiB,UAAa,SAAS,cAAc;AACvD,4BAAoB;AACpB,2BAAmB;AACnB;AAAA,MACF;AACA;AAAA,IACF;AAGA,QAAI,SAAS,QAAQ,aAAa,MAAM;AACtC;AACA;AAAA,IACF;AAGA,QAAI,oBAAoB,UAAa,iBAAiB,QAAW;AAC/D,UAAI,SAAS,KAAK;AAChB,aAAK,KAAK,eAAe;AACzB,0BAAkB;AAClB;AAAA,MACF;AAEA,UAAI,KAAK;AACP,2BAAmB;AACnB,aAAK,KAAK,eAAe;AACzB,0BAAkB;AAClB;AAAA,MACF;AAAA,IACF;AAGA,QAAI,SAAS,OAAO,iBAAiB,QAAW;AAC9C;AAAA,IACF;AAGA,QAAI,SAAS,SAAS,aAAa,OAAO,aAAa,MAAM;AAC3D;AAAA,IACF;AAEA,wBAAoB;AACpB,uBAAmB;AAAA,EACrB;AAGA,MAAI,oBAAoB,QAAW;AACjC,SAAK,KAAK,eAAe;AAAA,EAC3B;AAEA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,57 @@
1
+ // src/utilities/schema-utilities.ts
2
+ import { CliError } from "../cli-error/cli-error.mjs";
3
+ import { ErrorCause } from "../cli-error/error-cause.mjs";
4
+ import { ValidationErrorCode } from "../cli-error/error-code/validation-error-code.mjs";
5
+ function validateSync(schema, value) {
6
+ const results = schema["~standard"].validate(value);
7
+ if (results instanceof Promise) {
8
+ throw new CliError({
9
+ cause: ErrorCause.Validation,
10
+ code: ValidationErrorCode.AsyncSchemaNotSupported,
11
+ context: { schema, value }
12
+ });
13
+ }
14
+ return results;
15
+ }
16
+ function defaultValueAndIsOptional(schema) {
17
+ const results = validateSync(schema);
18
+ if (results.issues) {
19
+ return { defaultValue: void 0, optional: false };
20
+ }
21
+ return { defaultValue: results.value, optional: true };
22
+ }
23
+ function PrepareType(schema, coerceHandler) {
24
+ const { optional, defaultValue } = defaultValueAndIsOptional(schema);
25
+ return {
26
+ schema,
27
+ optional,
28
+ defaultValue,
29
+ coerceTo: coerceHandler.type,
30
+ validate: (value) => validateSync(schema, value && coerceHandler(value))
31
+ };
32
+ }
33
+ function prepareDefinitionTypes(definition) {
34
+ if (!definition) return;
35
+ for (const object of Object.values(definition)) {
36
+ if (!object.coerce) {
37
+ object.coerce = (value) => value;
38
+ }
39
+ if (!object._preparedType) {
40
+ object._preparedType = PrepareType(object.schema, object.coerce);
41
+ }
42
+ }
43
+ }
44
+ function prettifyError(issues) {
45
+ return issues.map((issue) => {
46
+ const path = issue.path?.map((seg) => typeof seg === "object" && "key" in seg ? seg.key : seg);
47
+ const pathString = path && path.length > 0 ? ` at "${path.join(".")}"` : "";
48
+ return `${issue.message}${pathString}`;
49
+ }).join(" : ");
50
+ }
51
+ export {
52
+ defaultValueAndIsOptional,
53
+ prepareDefinitionTypes,
54
+ prettifyError,
55
+ validateSync
56
+ };
57
+ //# sourceMappingURL=schema-utilities.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utilities/schema-utilities.ts"],
4
+ "sourcesContent": ["import { CliError } from \"../cli-error/cli-error.ts\";\nimport { ErrorCause } from \"../cli-error/error-cause.ts\";\nimport { ValidationErrorCode } from \"../cli-error/error-code/validation-error-code.ts\";\n\nimport type { Argument, Option, PreparedType } from \"../types/definitions-types.ts\";\nimport type { SchemaResult, SchemaType } from \"../types/schema-types.ts\";\nimport type { CoerceMethod } from \"../types/types.ts\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n/** @throws {CliError} When schema is async */\nexport function validateSync(schema: SchemaType, value?: unknown): SchemaResult {\n const results = schema[\"~standard\"].validate(value);\n if (results instanceof Promise) {\n throw new CliError({\n cause: ErrorCause.Validation,\n code: ValidationErrorCode.AsyncSchemaNotSupported,\n context: { schema, value },\n });\n }\n\n return results;\n}\n\n/** @throws {CliError} When schema is async */\nexport function defaultValueAndIsOptional(schema: SchemaType): { defaultValue: unknown; optional: boolean } {\n const results = validateSync(schema);\n\n if (results.issues) {\n return { defaultValue: undefined, optional: false };\n }\n\n return { defaultValue: results.value, optional: true };\n}\n\n/** @throws {CliError} When schema is async */\nfunction PrepareType(schema: SchemaType, coerceHandler: CoerceMethod<unknown>): PreparedType {\n const { optional, defaultValue } = defaultValueAndIsOptional(schema);\n\n return {\n schema,\n optional,\n defaultValue,\n coerceTo: coerceHandler.type,\n validate: (value?: string) => validateSync(schema, value && coerceHandler(value)),\n };\n}\n\n/** @throws {CliError} When schema is async */\nexport function prepareDefinitionTypes(definition: Record<string, Argument> | Record<string, Option> | undefined) {\n if (!definition) return;\n\n for (const object of Object.values<Argument | Option>(definition)) {\n if (!object.coerce) {\n (object.coerce as CoerceMethod<string> | undefined) = (value: string) => value;\n }\n\n if (!object._preparedType) {\n object._preparedType = PrepareType(object.schema, object.coerce!);\n }\n }\n}\n\n/** Prettify Standard Schema V1 issues */\nexport function prettifyError(issues: ReadonlyArray<StandardSchemaV1.Issue>): string {\n return issues\n .map(issue => {\n const path = issue.path?.map(seg => (typeof seg === \"object\" && \"key\" in seg ? seg.key : seg));\n const pathString = path && path.length > 0 ? ` at \"${path.join(\".\")}\"` : \"\";\n return `${issue.message}${pathString}`;\n })\n .join(\" : \");\n}\n"],
5
+ "mappings": ";AAAA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,2BAA2B;AAQ7B,SAAS,aAAa,QAAoB,OAA+B;AAC9E,QAAM,UAAU,OAAO,WAAW,EAAE,SAAS,KAAK;AAClD,MAAI,mBAAmB,SAAS;AAC9B,UAAM,IAAI,SAAS;AAAA,MACjB,OAAO,WAAW;AAAA,MAClB,MAAM,oBAAoB;AAAA,MAC1B,SAAS,EAAE,QAAQ,MAAM;AAAA,IAC3B,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAGO,SAAS,0BAA0B,QAAkE;AAC1G,QAAM,UAAU,aAAa,MAAM;AAEnC,MAAI,QAAQ,QAAQ;AAClB,WAAO,EAAE,cAAc,QAAW,UAAU,MAAM;AAAA,EACpD;AAEA,SAAO,EAAE,cAAc,QAAQ,OAAO,UAAU,KAAK;AACvD;AAGA,SAAS,YAAY,QAAoB,eAAoD;AAC3F,QAAM,EAAE,UAAU,aAAa,IAAI,0BAA0B,MAAM;AAEnE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,cAAc;AAAA,IACxB,UAAU,CAAC,UAAmB,aAAa,QAAQ,SAAS,cAAc,KAAK,CAAC;AAAA,EAClF;AACF;AAGO,SAAS,uBAAuB,YAA2E;AAChH,MAAI,CAAC,WAAY;AAEjB,aAAW,UAAU,OAAO,OAA0B,UAAU,GAAG;AACjE,QAAI,CAAC,OAAO,QAAQ;AAClB,MAAC,OAAO,SAA8C,CAAC,UAAkB;AAAA,IAC3E;AAEA,QAAI,CAAC,OAAO,eAAe;AACzB,aAAO,gBAAgB,YAAY,OAAO,QAAQ,OAAO,MAAO;AAAA,IAClE;AAAA,EACF;AACF;AAGO,SAAS,cAAc,QAAuD;AACnF,SAAO,OACJ,IAAI,WAAS;AACZ,UAAM,OAAO,MAAM,MAAM,IAAI,SAAQ,OAAO,QAAQ,YAAY,SAAS,MAAM,IAAI,MAAM,GAAI;AAC7F,UAAM,aAAa,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,KAAK,GAAG,CAAC,MAAM;AACzE,WAAO,GAAG,MAAM,OAAO,GAAG,UAAU;AAAA,EACtC,CAAC,EACA,KAAK,KAAK;AACf;",
6
+ "names": []
7
+ }
@@ -0,0 +1,122 @@
1
+ // src/utilities/utilities.ts
2
+ function toKebabCase(input) {
3
+ return input.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
4
+ }
5
+ function generateOrdinalSuffix(index) {
6
+ if (index < 0) return "";
7
+ const number = index + 1;
8
+ const lastDigit = number % 10;
9
+ const lastTwoDigits = number % 100;
10
+ let suffix = "th";
11
+ if (lastTwoDigits < 11 || lastTwoDigits > 13) {
12
+ switch (lastDigit) {
13
+ case 1: {
14
+ suffix = "st";
15
+ break;
16
+ }
17
+ case 2: {
18
+ suffix = "nd";
19
+ break;
20
+ }
21
+ case 3: {
22
+ suffix = "rd";
23
+ break;
24
+ }
25
+ }
26
+ }
27
+ return `${number}${suffix}`;
28
+ }
29
+ function ln(count) {
30
+ return "\n".repeat(count);
31
+ }
32
+ function indent(count) {
33
+ if (count <= 0) return "";
34
+ return " ".repeat(count);
35
+ }
36
+ function indentLines(text, spaces) {
37
+ return text.replace(/\n/g, "\n" + indent(spaces));
38
+ }
39
+ function stringifyValue(value) {
40
+ if (value instanceof Set) {
41
+ return "new Set([" + Array.from(value).map((element) => stringifyValue(element)).join(", ") + "])";
42
+ }
43
+ return JSON.stringify(value);
44
+ }
45
+ function insertAtEndOfFirstLine(string, insert) {
46
+ const lines = string.split("\n");
47
+ lines[0] += (lines[0] ? " " : "") + insert;
48
+ return lines.join("\n");
49
+ }
50
+ function subcommandPlaceholder(metadata) {
51
+ let placeholder = metadata.placeholder;
52
+ if (placeholder) {
53
+ return placeholder;
54
+ }
55
+ if (metadata.options.length > 0) {
56
+ placeholder += (placeholder ? " " : "") + "[options]";
57
+ }
58
+ if (metadata.arguments.length > 0) {
59
+ placeholder += (placeholder ? " " : "") + "<arguments>";
60
+ }
61
+ if (metadata.allowPositionals) {
62
+ placeholder += (placeholder ? " " : "") + "<positionals>";
63
+ }
64
+ if (!placeholder) {
65
+ placeholder = " ";
66
+ }
67
+ return placeholder;
68
+ }
69
+ function escapeHtmlTags(markdown) {
70
+ const escapeMap = { "&": "&amp;", "<": "&lt;", ">": "&gt;" };
71
+ const re = /(```[\s\S]*?```|`[^`]*`)|(<!--[\s\S]*?-->)|(<[^>]+>)/g;
72
+ return markdown.replace(re, (fullMatch, code, comment, tag) => {
73
+ if (code) return code;
74
+ if (comment) return comment;
75
+ if (!tag) return fullMatch;
76
+ return tag.replace(/[&<>]/g, (ch) => escapeMap[ch]);
77
+ });
78
+ }
79
+ function ansiRegex({ onlyFirst = false } = {}) {
80
+ const ST = String.raw`(?:\u0007|\u001B\u005C|\u009C)`;
81
+ const osc = String.raw`(?:\u001B\][\s\S]*?${ST})`;
82
+ const csi = String.raw`[\u001B\u009B][[\]()#;?]*(?:\d{1,4}(?:[;:]\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]`;
83
+ const pattern = `${osc}|${csi}`;
84
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
85
+ }
86
+ var regex = ansiRegex();
87
+ function stripAnsi(string) {
88
+ return string.replace(regex, "");
89
+ }
90
+ function walkObject(object_, onVisit, basePath = "") {
91
+ for (const [key, value] of Object.entries(object_)) {
92
+ const path = basePath ? `${basePath}.${key}` : key;
93
+ const newValue = onVisit(key, value, path);
94
+ if (newValue !== void 0) {
95
+ object_[key] = newValue;
96
+ }
97
+ const target = object_[key];
98
+ if (target && typeof target === "object" && !Array.isArray(target)) {
99
+ walkObject(target, onVisit, path);
100
+ }
101
+ }
102
+ }
103
+ function Enum(value) {
104
+ const casted = value;
105
+ for (const [key] of Object.entries(casted)) casted[key] = key;
106
+ return Object.freeze(casted);
107
+ }
108
+ export {
109
+ Enum,
110
+ escapeHtmlTags,
111
+ generateOrdinalSuffix,
112
+ indent,
113
+ indentLines,
114
+ insertAtEndOfFirstLine,
115
+ ln,
116
+ stringifyValue,
117
+ stripAnsi,
118
+ subcommandPlaceholder,
119
+ toKebabCase,
120
+ walkObject
121
+ };
122
+ //# sourceMappingURL=utilities.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utilities/utilities.ts"],
4
+ "sourcesContent": ["import type { SubcommandMetadata } from \"../types/metadata-types.ts\";\n\nexport function toKebabCase(input: string): string {\n return input.replace(/([a-z])([A-Z])/g, \"$1-$2\").toLowerCase();\n}\n\n/**\n * Converts a zero-based index into its human-readable ordinal form.\n *\n * Examples: 0 \u2192 \"1st\" 1 \u2192 \"2nd\" 2 \u2192 \"3rd\" 3 \u2192 \"4th\" 10 \u2192 \"11th\"\n *\n * Handles special cases for 11, 12, and 13.\n *\n * @param index - The zero-based index to convert.\n * @returns The ordinal string (e.g., \"1st\", \"2nd\", \"3rd\", \"4th\", ...).\n */\nexport function generateOrdinalSuffix(index: number): string {\n if (index < 0) return \"\";\n\n const number = index + 1;\n const lastDigit = number % 10;\n const lastTwoDigits = number % 100;\n\n let suffix = \"th\";\n\n if (lastTwoDigits < 11 || lastTwoDigits > 13) {\n switch (lastDigit) {\n case 1: {\n suffix = \"st\";\n break;\n }\n case 2: {\n suffix = \"nd\";\n break;\n }\n case 3: {\n suffix = \"rd\";\n break;\n }\n }\n }\n\n return `${number}${suffix}`;\n}\n\n/** New line */\nexport function ln(count: number) {\n return \"\\n\".repeat(count);\n}\n\n/** Space */\nexport function indent(count: number) {\n if (count <= 0) return \"\";\n return \" \".repeat(count);\n}\n\n/** Indents every line in the given text by the provided number of spaces. Empty lines are preserved. */\nexport function indentLines(text: string, spaces: number): string {\n return text.replace(/\\n/g, \"\\n\" + indent(spaces));\n}\n\nexport function stringifyValue(value: unknown): string {\n // Set\n if (value instanceof Set) {\n return (\n \"new Set([\" +\n Array.from(value)\n .map(element => stringifyValue(element))\n .join(\", \") +\n \"])\"\n );\n }\n\n // unknown\n return JSON.stringify(value);\n}\n\n/** Insert text at the end of the first line */\nexport function insertAtEndOfFirstLine(string: string, insert: string) {\n const lines = string.split(\"\\n\");\n lines[0] += (lines[0] ? \" \" : \"\") + insert;\n return lines.join(\"\\n\");\n}\n\n/** Get the placeholder for a subcommand */\nexport function subcommandPlaceholder(metadata: SubcommandMetadata): string {\n let placeholder = metadata.placeholder;\n\n if (placeholder) {\n return placeholder;\n }\n\n if (metadata.options.length > 0) {\n placeholder += (placeholder ? \" \" : \"\") + \"[options]\";\n }\n\n if (metadata.arguments.length > 0) {\n placeholder += (placeholder ? \" \" : \"\") + \"<arguments>\";\n }\n\n if (metadata.allowPositionals) {\n placeholder += (placeholder ? \" \" : \"\") + \"<positionals>\";\n }\n\n if (!placeholder) {\n placeholder = \" \";\n }\n\n return placeholder;\n}\n\n/**\n * Escape HTML characters inside HTML tags in a Markdown string, but leave code blocks, inline code, and HTML comments\n * unchanged.\n */\nexport function escapeHtmlTags(markdown: string): string {\n const escapeMap: Record<string, string> = { \"&\": \"&amp;\", \"<\": \"&lt;\", \">\": \"&gt;\" };\n\n // Captures:\n // 1) fenced code blocks or inline code\n // 2) HTML comments <!-- ... -->\n // 3) other HTML tags like <b>, <div attr=\"x\">, etc.\n const re = /(```[\\s\\S]*?```|`[^`]*`)|(<!--[\\s\\S]*?-->)|(<[^>]+>)/g;\n\n return markdown.replace(re, (fullMatch: string, code?: string, comment?: string, tag?: string) => {\n if (code) return code;\n if (comment) return comment;\n if (!tag) return fullMatch;\n\n return tag.replace(/[&<>]/g, ch => escapeMap[ch]);\n });\n}\n\n/** Credits: https://github.com/chalk/ansi-regex */\nfunction ansiRegex({ onlyFirst = false } = {}) {\n // Valid string terminator sequences are BEL, ESC\\, and 0x9c\n const ST = String.raw`(?:\\u0007|\\u001B\\u005C|\\u009C)`;\n\n // OSC sequences only: ESC ] ... ST (non-greedy until the first ST)\n const osc = String.raw`(?:\\u001B\\][\\s\\S]*?${ST})`;\n\n // CSI and related: ESC/C1, optional intermediates, optional params (supports ; and :) then final byte\n const csi = String.raw`[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`;\n\n const pattern = `${osc}|${csi}`;\n\n return new RegExp(pattern, onlyFirst ? undefined : \"g\");\n}\n\nconst regex = ansiRegex();\n\nexport function stripAnsi(string: string): string {\n return string.replace(regex, \"\");\n}\n\ntype WalkCallback = (key: string, value: unknown, path: string) => unknown;\n\n/**\n * Recursively walks through an object and calls a function for each key-value pair.\n *\n * @param object_ - The object to walk.\n * @param onVisit - Function called on every visited property (key, value, path).\n * @param basePath - (Internal) Used for recursion to build nested paths.\n */\nexport function walkObject(object_: Record<string, unknown>, onVisit: WalkCallback, basePath = \"\"): void {\n for (const [key, value] of Object.entries(object_)) {\n const path = basePath ? `${basePath}.${key}` : key;\n const newValue = onVisit(key, value, path);\n\n if (newValue !== undefined) {\n object_[key] = newValue;\n }\n\n const target = object_[key];\n if (target && typeof target === \"object\" && !Array.isArray(target)) {\n walkObject(target as Record<string, unknown>, onVisit, path);\n }\n }\n}\n\nexport function Enum<const T extends Record<string, undefined>>(value: T) {\n const casted = value as Record<string, unknown>;\n for (const [key] of Object.entries(casted)) casted[key] = key;\n return Object.freeze(casted) as { [K in keyof T]: K };\n}\n"],
5
+ "mappings": ";AAEO,SAAS,YAAY,OAAuB;AACjD,SAAO,MAAM,QAAQ,mBAAmB,OAAO,EAAE,YAAY;AAC/D;AAYO,SAAS,sBAAsB,OAAuB;AAC3D,MAAI,QAAQ,EAAG,QAAO;AAEtB,QAAM,SAAS,QAAQ;AACvB,QAAM,YAAY,SAAS;AAC3B,QAAM,gBAAgB,SAAS;AAE/B,MAAI,SAAS;AAEb,MAAI,gBAAgB,MAAM,gBAAgB,IAAI;AAC5C,YAAQ,WAAW;AAAA,MACjB,KAAK,GAAG;AACN,iBAAS;AACT;AAAA,MACF;AAAA,MACA,KAAK,GAAG;AACN,iBAAS;AACT;AAAA,MACF;AAAA,MACA,KAAK,GAAG;AACN,iBAAS;AACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,GAAG,MAAM,GAAG,MAAM;AAC3B;AAGO,SAAS,GAAG,OAAe;AAChC,SAAO,KAAK,OAAO,KAAK;AAC1B;AAGO,SAAS,OAAO,OAAe;AACpC,MAAI,SAAS,EAAG,QAAO;AACvB,SAAO,IAAI,OAAO,KAAK;AACzB;AAGO,SAAS,YAAY,MAAc,QAAwB;AAChE,SAAO,KAAK,QAAQ,OAAO,OAAO,OAAO,MAAM,CAAC;AAClD;AAEO,SAAS,eAAe,OAAwB;AAErD,MAAI,iBAAiB,KAAK;AACxB,WACE,cACA,MAAM,KAAK,KAAK,EACb,IAAI,aAAW,eAAe,OAAO,CAAC,EACtC,KAAK,IAAI,IACZ;AAAA,EAEJ;AAGA,SAAO,KAAK,UAAU,KAAK;AAC7B;AAGO,SAAS,uBAAuB,QAAgB,QAAgB;AACrE,QAAM,QAAQ,OAAO,MAAM,IAAI;AAC/B,QAAM,CAAC,MAAM,MAAM,CAAC,IAAI,MAAM,MAAM;AACpC,SAAO,MAAM,KAAK,IAAI;AACxB;AAGO,SAAS,sBAAsB,UAAsC;AAC1E,MAAI,cAAc,SAAS;AAE3B,MAAI,aAAa;AACf,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,QAAQ,SAAS,GAAG;AAC/B,oBAAgB,cAAc,MAAM,MAAM;AAAA,EAC5C;AAEA,MAAI,SAAS,UAAU,SAAS,GAAG;AACjC,oBAAgB,cAAc,MAAM,MAAM;AAAA,EAC5C;AAEA,MAAI,SAAS,kBAAkB;AAC7B,oBAAgB,cAAc,MAAM,MAAM;AAAA,EAC5C;AAEA,MAAI,CAAC,aAAa;AAChB,kBAAc;AAAA,EAChB;AAEA,SAAO;AACT;AAMO,SAAS,eAAe,UAA0B;AACvD,QAAM,YAAoC,EAAE,KAAK,SAAS,KAAK,QAAQ,KAAK,OAAO;AAMnF,QAAM,KAAK;AAEX,SAAO,SAAS,QAAQ,IAAI,CAAC,WAAmB,MAAe,SAAkB,QAAiB;AAChG,QAAI,KAAM,QAAO;AACjB,QAAI,QAAS,QAAO;AACpB,QAAI,CAAC,IAAK,QAAO;AAEjB,WAAO,IAAI,QAAQ,UAAU,QAAM,UAAU,EAAE,CAAC;AAAA,EAClD,CAAC;AACH;AAGA,SAAS,UAAU,EAAE,YAAY,MAAM,IAAI,CAAC,GAAG;AAE7C,QAAM,KAAK,OAAO;AAGlB,QAAM,MAAM,OAAO,yBAAyB,EAAE;AAG9C,QAAM,MAAM,OAAO;AAEnB,QAAM,UAAU,GAAG,GAAG,IAAI,GAAG;AAE7B,SAAO,IAAI,OAAO,SAAS,YAAY,SAAY,GAAG;AACxD;AAEA,IAAM,QAAQ,UAAU;AAEjB,SAAS,UAAU,QAAwB;AAChD,SAAO,OAAO,QAAQ,OAAO,EAAE;AACjC;AAWO,SAAS,WAAW,SAAkC,SAAuB,WAAW,IAAU;AACvG,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAG;AAClD,UAAM,OAAO,WAAW,GAAG,QAAQ,IAAI,GAAG,KAAK;AAC/C,UAAM,WAAW,QAAQ,KAAK,OAAO,IAAI;AAEzC,QAAI,aAAa,QAAW;AAC1B,cAAQ,GAAG,IAAI;AAAA,IACjB;AAEA,UAAM,SAAS,QAAQ,GAAG;AAC1B,QAAI,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,MAAM,GAAG;AAClE,iBAAW,QAAmC,SAAS,IAAI;AAAA,IAC7D;AAAA,EACF;AACF;AAEO,SAAS,KAAgD,OAAU;AACxE,QAAM,SAAS;AACf,aAAW,CAAC,GAAG,KAAK,OAAO,QAAQ,MAAM,EAAG,QAAO,GAAG,IAAI;AAC1D,SAAO,OAAO,OAAO,MAAM;AAC7B;",
6
+ "names": []
7
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"bash-autocomplete-script.d.ts","sourceRoot":"","sources":["../../../src/autocomplete-scripts/bash-autocomplete-script.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AAEzD;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,aAAa,EAAE,GAAG,GAAG,MAAM,CAwEzE"}
1
+ {"version":3,"file":"bash-autocomplete-script.d.ts","sourceRoot":"","sources":["../../../src/autocomplete-scripts/bash-autocomplete-script.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AAEzD;;;;;;;GAOG;AACH,wBAAgB,8BAA8B,CAAC,aAAa,EAAE,GAAG,GAAG,MAAM,CA0EzE"}
@@ -0,0 +1,15 @@
1
+ import type { Cli } from "../types/definitions-types.ts";
2
+ /**
3
+ * Generates a PowerShell autocomplete script for a CLI.
4
+ *
5
+ * Instructions:
6
+ *
7
+ * - Ensure your CLI is available as a `.ps1` file in your environment. e.g., `cliName.ps1`.
8
+ * - Add the generated script to your `profile.ps1` file:
9
+ *
10
+ * 1. Run: `notepad $profile`
11
+ * 2. Add: `. "<generated script path>"`
12
+ * 3. Save and reopen PowerShell
13
+ */
14
+ export declare function generatePowerShellAutocompleteScript(cliDefinition: Cli): string;
15
+ //# sourceMappingURL=powershell-autocomplete-script.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"powershell-autocomplete-script.d.ts","sourceRoot":"","sources":["../../../src/autocomplete-scripts/powershell-autocomplete-script.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,wBAAgB,oCAAoC,CAAC,aAAa,EAAE,GAAG,GAAG,MAAM,CAwE/E"}
1
+ {"version":3,"file":"powershell-autocomplete-script.d.ts","sourceRoot":"","sources":["../../../src/autocomplete-scripts/powershell-autocomplete-script.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AAEzD;;;;;;;;;;;GAWG;AACH,wBAAgB,oCAAoC,CAAC,aAAa,EAAE,GAAG,GAAG,MAAM,CAyG/E"}
@@ -0,0 +1,4 @@
1
+ import type { Cli } from "../types/definitions-types.ts";
2
+ /** Generates a Zsh autocomplete script for a CLI, including global options when no subcommand is provided. */
3
+ export declare function generateZshAutocompleteScript(cliDefinition: Cli): string;
4
+ //# sourceMappingURL=zsh-autocomplete-script.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zsh-autocomplete-script.d.ts","sourceRoot":"","sources":["../../../src/autocomplete-scripts/zsh-autocomplete-script.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAc,MAAM,+BAA+B,CAAC;AAErE;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,aAAa,EAAE,GAAG,GAAG,MAAM,CA+DxE"}
1
+ {"version":3,"file":"zsh-autocomplete-script.d.ts","sourceRoot":"","sources":["../../../src/autocomplete-scripts/zsh-autocomplete-script.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAc,MAAM,+BAA+B,CAAC;AAErE,8GAA8G;AAC9G,wBAAgB,6BAA6B,CAAC,aAAa,EAAE,GAAG,GAAG,MAAM,CA8ExE"}