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

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 (510) hide show
  1. package/README.md +525 -588
  2. package/lib/cjs/autocomplete-scripts/bash-autocomplete-script.cjs +2 -0
  3. package/lib/cjs/autocomplete-scripts/bash-autocomplete-script.cjs.map +1 -0
  4. package/lib/cjs/autocomplete-scripts/powershell-autocomplete-script.cjs +2 -0
  5. package/lib/cjs/autocomplete-scripts/powershell-autocomplete-script.cjs.map +1 -0
  6. package/lib/cjs/autocomplete-scripts/zsh-autocomplete-script.cjs +42 -0
  7. package/lib/cjs/autocomplete-scripts/zsh-autocomplete-script.cjs.map +1 -0
  8. package/lib/cjs/coerce/coerce-methods.cjs +2 -0
  9. package/lib/cjs/coerce/coerce-methods.cjs.map +1 -0
  10. package/lib/cjs/coerce/string-to-array.cjs +2 -0
  11. package/lib/cjs/coerce/string-to-array.cjs.map +1 -0
  12. package/lib/cjs/coerce/string-to-primitive.cjs +2 -0
  13. package/lib/cjs/coerce/string-to-primitive.cjs.map +1 -0
  14. package/lib/cjs/coerce/string-to-set.cjs +2 -0
  15. package/lib/cjs/coerce/string-to-set.cjs.map +1 -0
  16. package/lib/cjs/definitions/define-arguments.cjs +2 -0
  17. package/lib/cjs/definitions/define-arguments.cjs.map +1 -0
  18. package/lib/cjs/definitions/define-cli.cjs +2 -0
  19. package/lib/cjs/definitions/define-cli.cjs.map +1 -0
  20. package/lib/cjs/definitions/define-options.cjs +2 -0
  21. package/lib/cjs/definitions/define-options.cjs.map +1 -0
  22. package/lib/cjs/definitions/define-subcommand.cjs +2 -0
  23. package/lib/cjs/definitions/define-subcommand.cjs.map +1 -0
  24. package/lib/cjs/definitions/validate-cli-definition.cjs +2 -0
  25. package/lib/cjs/definitions/validate-cli-definition.cjs.map +1 -0
  26. package/lib/cjs/help-message/format-arguments.cjs +2 -0
  27. package/lib/cjs/help-message/format-arguments.cjs.map +1 -0
  28. package/lib/cjs/help-message/format-options.cjs +2 -0
  29. package/lib/cjs/help-message/format-options.cjs.map +1 -0
  30. package/lib/cjs/help-message/format-subcommands.cjs +2 -0
  31. package/lib/cjs/help-message/format-subcommands.cjs.map +1 -0
  32. package/lib/cjs/help-message/generate-for-cli.cjs +2 -0
  33. package/lib/cjs/help-message/generate-for-cli.cjs.map +1 -0
  34. package/lib/cjs/help-message/generate-for-subcommand.cjs +2 -0
  35. package/lib/cjs/help-message/generate-for-subcommand.cjs.map +1 -0
  36. package/lib/cjs/help-message/print-help.cjs +2 -0
  37. package/lib/cjs/help-message/print-help.cjs.map +1 -0
  38. package/lib/cjs/help-message/set-defaults.cjs +2 -0
  39. package/lib/cjs/help-message/set-defaults.cjs.map +1 -0
  40. package/lib/cjs/help-message/styles.cjs +2 -0
  41. package/lib/cjs/help-message/styles.cjs.map +1 -0
  42. package/lib/cjs/help-message/terminal-markdown.cjs +2 -0
  43. package/lib/cjs/help-message/terminal-markdown.cjs.map +1 -0
  44. package/lib/cjs/index.cjs +2 -0
  45. package/lib/cjs/index.cjs.map +1 -0
  46. package/lib/cjs/markdown/generate-markdown.cjs +2 -0
  47. package/lib/cjs/markdown/generate-markdown.cjs.map +1 -0
  48. package/lib/cjs/metadata/arguments-metadata.cjs +2 -0
  49. package/lib/cjs/metadata/arguments-metadata.cjs.map +1 -0
  50. package/lib/cjs/metadata/cli-metadata.cjs +2 -0
  51. package/lib/cjs/metadata/cli-metadata.cjs.map +1 -0
  52. package/lib/cjs/metadata/options-metadata.cjs +2 -0
  53. package/lib/cjs/metadata/options-metadata.cjs.map +1 -0
  54. package/lib/cjs/metadata/subcommands-metadata.cjs +2 -0
  55. package/lib/cjs/metadata/subcommands-metadata.cjs.map +1 -0
  56. package/lib/cjs/parse/context/cli-context-builder.cjs +2 -0
  57. package/lib/cjs/parse/context/cli-context-builder.cjs.map +1 -0
  58. package/lib/cjs/parse/context/object-context-builder.cjs +2 -0
  59. package/lib/cjs/parse/context/object-context-builder.cjs.map +1 -0
  60. package/lib/cjs/parse/parser-utilities.cjs +2 -0
  61. package/lib/cjs/parse/parser-utilities.cjs.map +1 -0
  62. package/lib/cjs/parse/safe-parse.cjs +2 -0
  63. package/lib/cjs/parse/safe-parse.cjs.map +1 -0
  64. package/lib/cjs/parse/validation/validate-context.cjs +2 -0
  65. package/lib/cjs/parse/validation/validate-context.cjs.map +1 -0
  66. package/lib/cjs/parse/validation/validators/arguments.cjs +2 -0
  67. package/lib/cjs/parse/validation/validators/arguments.cjs.map +1 -0
  68. package/lib/cjs/parse/validation/validators/conflict.cjs +2 -0
  69. package/lib/cjs/parse/validation/validators/conflict.cjs.map +1 -0
  70. package/lib/cjs/parse/validation/validators/exclusive.cjs +2 -0
  71. package/lib/cjs/parse/validation/validators/exclusive.cjs.map +1 -0
  72. package/lib/cjs/parse/validation/validators/explicitly-passed.cjs +2 -0
  73. package/lib/cjs/parse/validation/validators/explicitly-passed.cjs.map +1 -0
  74. package/lib/cjs/parse/validation/validators/options.cjs +2 -0
  75. package/lib/cjs/parse/validation/validators/options.cjs.map +1 -0
  76. package/lib/cjs/parse/validation/validators/requires.cjs +2 -0
  77. package/lib/cjs/parse/validation/validators/requires.cjs.map +1 -0
  78. package/lib/cjs/utilities.cjs +2 -0
  79. package/lib/cjs/utilities.cjs.map +1 -0
  80. package/lib/esm/autocomplete-scripts/bash-autocomplete-script.js +2 -0
  81. package/lib/esm/autocomplete-scripts/bash-autocomplete-script.js.map +1 -0
  82. package/lib/esm/autocomplete-scripts/powershell-autocomplete-script.js +2 -0
  83. package/lib/esm/autocomplete-scripts/powershell-autocomplete-script.js.map +1 -0
  84. package/lib/esm/autocomplete-scripts/zsh-autocomplete-script.js +42 -0
  85. package/lib/esm/autocomplete-scripts/zsh-autocomplete-script.js.map +1 -0
  86. package/lib/esm/coerce/coerce-methods.js +2 -0
  87. package/lib/esm/coerce/coerce-methods.js.map +1 -0
  88. package/lib/esm/coerce/string-to-array.js +2 -0
  89. package/lib/esm/coerce/string-to-array.js.map +1 -0
  90. package/lib/esm/coerce/string-to-primitive.js +2 -0
  91. package/lib/esm/coerce/string-to-primitive.js.map +1 -0
  92. package/lib/esm/coerce/string-to-set.js +2 -0
  93. package/lib/esm/coerce/string-to-set.js.map +1 -0
  94. package/lib/esm/definitions/define-arguments.js +2 -0
  95. package/lib/esm/definitions/define-arguments.js.map +1 -0
  96. package/lib/esm/definitions/define-cli.js +2 -0
  97. package/lib/esm/definitions/define-cli.js.map +1 -0
  98. package/lib/esm/definitions/define-options.js +2 -0
  99. package/lib/esm/definitions/define-options.js.map +1 -0
  100. package/lib/esm/definitions/define-subcommand.js +2 -0
  101. package/lib/esm/definitions/define-subcommand.js.map +1 -0
  102. package/lib/esm/definitions/validate-cli-definition.js +2 -0
  103. package/lib/esm/definitions/validate-cli-definition.js.map +1 -0
  104. package/lib/esm/help-message/format-arguments.js +2 -0
  105. package/lib/esm/help-message/format-arguments.js.map +1 -0
  106. package/lib/esm/help-message/format-options.js +2 -0
  107. package/lib/esm/help-message/format-options.js.map +1 -0
  108. package/lib/esm/help-message/format-subcommands.js +2 -0
  109. package/lib/esm/help-message/format-subcommands.js.map +1 -0
  110. package/lib/esm/help-message/generate-for-cli.js +2 -0
  111. package/lib/esm/help-message/generate-for-cli.js.map +1 -0
  112. package/lib/esm/help-message/generate-for-subcommand.js +2 -0
  113. package/lib/esm/help-message/generate-for-subcommand.js.map +1 -0
  114. package/lib/esm/help-message/print-help.js +2 -0
  115. package/lib/esm/help-message/print-help.js.map +1 -0
  116. package/lib/esm/help-message/set-defaults.js +2 -0
  117. package/lib/esm/help-message/set-defaults.js.map +1 -0
  118. package/lib/esm/help-message/styles.js +2 -0
  119. package/lib/esm/help-message/styles.js.map +1 -0
  120. package/lib/esm/help-message/terminal-markdown.js +2 -0
  121. package/lib/esm/help-message/terminal-markdown.js.map +1 -0
  122. package/lib/esm/index.js +2 -0
  123. package/lib/esm/index.js.map +1 -0
  124. package/lib/esm/markdown/generate-markdown.js +2 -0
  125. package/lib/esm/markdown/generate-markdown.js.map +1 -0
  126. package/lib/esm/metadata/arguments-metadata.js +2 -0
  127. package/lib/esm/metadata/arguments-metadata.js.map +1 -0
  128. package/lib/esm/metadata/cli-metadata.js +2 -0
  129. package/lib/esm/metadata/cli-metadata.js.map +1 -0
  130. package/lib/esm/metadata/options-metadata.js +2 -0
  131. package/lib/esm/metadata/options-metadata.js.map +1 -0
  132. package/lib/esm/metadata/subcommands-metadata.js +2 -0
  133. package/lib/esm/metadata/subcommands-metadata.js.map +1 -0
  134. package/lib/esm/parse/context/cli-context-builder.js +2 -0
  135. package/lib/esm/parse/context/cli-context-builder.js.map +1 -0
  136. package/lib/esm/parse/context/object-context-builder.js +2 -0
  137. package/lib/esm/parse/context/object-context-builder.js.map +1 -0
  138. package/lib/esm/parse/parser-utilities.js +2 -0
  139. package/lib/esm/parse/parser-utilities.js.map +1 -0
  140. package/lib/esm/parse/safe-parse.js +2 -0
  141. package/lib/esm/parse/safe-parse.js.map +1 -0
  142. package/lib/esm/parse/validation/validate-context.js +2 -0
  143. package/lib/esm/parse/validation/validate-context.js.map +1 -0
  144. package/lib/esm/parse/validation/validators/arguments.js +2 -0
  145. package/lib/esm/parse/validation/validators/arguments.js.map +1 -0
  146. package/lib/esm/parse/validation/validators/conflict.js +2 -0
  147. package/lib/esm/parse/validation/validators/conflict.js.map +1 -0
  148. package/lib/esm/parse/validation/validators/exclusive.js +2 -0
  149. package/lib/esm/parse/validation/validators/exclusive.js.map +1 -0
  150. package/lib/esm/parse/validation/validators/explicitly-passed.js +2 -0
  151. package/lib/esm/parse/validation/validators/explicitly-passed.js.map +1 -0
  152. package/lib/esm/parse/validation/validators/options.js +2 -0
  153. package/lib/esm/parse/validation/validators/options.js.map +1 -0
  154. package/lib/esm/parse/validation/validators/requires.js +2 -0
  155. package/lib/esm/parse/validation/validators/requires.js.map +1 -0
  156. package/lib/esm/utilities.js +2 -0
  157. package/lib/esm/utilities.js.map +1 -0
  158. package/lib/iife/index.js +2 -0
  159. package/lib/iife/index.js.map +1 -0
  160. package/lib/mjs/autocomplete-scripts/bash-autocomplete-script.mjs +2 -0
  161. package/lib/mjs/autocomplete-scripts/bash-autocomplete-script.mjs.map +1 -0
  162. package/lib/mjs/autocomplete-scripts/powershell-autocomplete-script.mjs +2 -0
  163. package/lib/mjs/autocomplete-scripts/powershell-autocomplete-script.mjs.map +1 -0
  164. package/lib/mjs/autocomplete-scripts/zsh-autocomplete-script.mjs +42 -0
  165. package/lib/mjs/autocomplete-scripts/zsh-autocomplete-script.mjs.map +1 -0
  166. package/lib/mjs/coerce/coerce-methods.mjs +2 -0
  167. package/lib/mjs/coerce/coerce-methods.mjs.map +1 -0
  168. package/lib/mjs/coerce/string-to-array.mjs +2 -0
  169. package/lib/mjs/coerce/string-to-array.mjs.map +1 -0
  170. package/lib/mjs/coerce/string-to-primitive.mjs +2 -0
  171. package/lib/mjs/coerce/string-to-primitive.mjs.map +1 -0
  172. package/lib/mjs/coerce/string-to-set.mjs +2 -0
  173. package/lib/mjs/coerce/string-to-set.mjs.map +1 -0
  174. package/lib/mjs/definitions/define-arguments.mjs +2 -0
  175. package/lib/mjs/definitions/define-arguments.mjs.map +1 -0
  176. package/lib/mjs/definitions/define-cli.mjs +2 -0
  177. package/lib/mjs/definitions/define-cli.mjs.map +1 -0
  178. package/lib/mjs/definitions/define-options.mjs +2 -0
  179. package/lib/mjs/definitions/define-options.mjs.map +1 -0
  180. package/lib/mjs/definitions/define-subcommand.mjs +2 -0
  181. package/lib/mjs/definitions/define-subcommand.mjs.map +1 -0
  182. package/lib/mjs/definitions/validate-cli-definition.mjs +2 -0
  183. package/lib/mjs/definitions/validate-cli-definition.mjs.map +1 -0
  184. package/lib/mjs/help-message/format-arguments.mjs +2 -0
  185. package/lib/mjs/help-message/format-arguments.mjs.map +1 -0
  186. package/lib/mjs/help-message/format-options.mjs +2 -0
  187. package/lib/mjs/help-message/format-options.mjs.map +1 -0
  188. package/lib/mjs/help-message/format-subcommands.mjs +2 -0
  189. package/lib/mjs/help-message/format-subcommands.mjs.map +1 -0
  190. package/lib/mjs/help-message/generate-for-cli.mjs +2 -0
  191. package/lib/mjs/help-message/generate-for-cli.mjs.map +1 -0
  192. package/lib/mjs/help-message/generate-for-subcommand.mjs +2 -0
  193. package/lib/mjs/help-message/generate-for-subcommand.mjs.map +1 -0
  194. package/lib/mjs/help-message/print-help.mjs +2 -0
  195. package/lib/mjs/help-message/print-help.mjs.map +1 -0
  196. package/lib/mjs/help-message/set-defaults.mjs +2 -0
  197. package/lib/mjs/help-message/set-defaults.mjs.map +1 -0
  198. package/lib/mjs/help-message/styles.mjs +2 -0
  199. package/lib/mjs/help-message/styles.mjs.map +1 -0
  200. package/lib/mjs/help-message/terminal-markdown.mjs +2 -0
  201. package/lib/mjs/help-message/terminal-markdown.mjs.map +1 -0
  202. package/lib/mjs/index.mjs +2 -0
  203. package/lib/mjs/index.mjs.map +1 -0
  204. package/lib/mjs/markdown/generate-markdown.mjs +2 -0
  205. package/lib/mjs/markdown/generate-markdown.mjs.map +1 -0
  206. package/lib/mjs/metadata/arguments-metadata.mjs +2 -0
  207. package/lib/mjs/metadata/arguments-metadata.mjs.map +1 -0
  208. package/lib/mjs/metadata/cli-metadata.mjs +2 -0
  209. package/lib/mjs/metadata/cli-metadata.mjs.map +1 -0
  210. package/lib/mjs/metadata/options-metadata.mjs +2 -0
  211. package/lib/mjs/metadata/options-metadata.mjs.map +1 -0
  212. package/lib/mjs/metadata/subcommands-metadata.mjs +2 -0
  213. package/lib/mjs/metadata/subcommands-metadata.mjs.map +1 -0
  214. package/lib/mjs/parse/context/cli-context-builder.mjs +2 -0
  215. package/lib/mjs/parse/context/cli-context-builder.mjs.map +1 -0
  216. package/lib/mjs/parse/context/object-context-builder.mjs +2 -0
  217. package/lib/mjs/parse/context/object-context-builder.mjs.map +1 -0
  218. package/lib/mjs/parse/parser-utilities.mjs +2 -0
  219. package/lib/mjs/parse/parser-utilities.mjs.map +1 -0
  220. package/lib/mjs/parse/safe-parse.mjs +2 -0
  221. package/lib/mjs/parse/safe-parse.mjs.map +1 -0
  222. package/lib/mjs/parse/validation/validate-context.mjs +2 -0
  223. package/lib/mjs/parse/validation/validate-context.mjs.map +1 -0
  224. package/lib/mjs/parse/validation/validators/arguments.mjs +2 -0
  225. package/lib/mjs/parse/validation/validators/arguments.mjs.map +1 -0
  226. package/lib/mjs/parse/validation/validators/conflict.mjs +2 -0
  227. package/lib/mjs/parse/validation/validators/conflict.mjs.map +1 -0
  228. package/lib/mjs/parse/validation/validators/exclusive.mjs +2 -0
  229. package/lib/mjs/parse/validation/validators/exclusive.mjs.map +1 -0
  230. package/lib/mjs/parse/validation/validators/explicitly-passed.mjs +2 -0
  231. package/lib/mjs/parse/validation/validators/explicitly-passed.mjs.map +1 -0
  232. package/lib/mjs/parse/validation/validators/options.mjs +2 -0
  233. package/lib/mjs/parse/validation/validators/options.mjs.map +1 -0
  234. package/lib/mjs/parse/validation/validators/requires.mjs +2 -0
  235. package/lib/mjs/parse/validation/validators/requires.mjs.map +1 -0
  236. package/lib/mjs/utilities.mjs +2 -0
  237. package/lib/mjs/utilities.mjs.map +1 -0
  238. package/lib/typescript/autocomplete-scripts/bash-autocomplete-script.d.ts +2 -2
  239. package/lib/typescript/autocomplete-scripts/bash-autocomplete-script.d.ts.map +1 -1
  240. package/lib/typescript/autocomplete-scripts/powershell-autocomplete-script.d.ts +2 -2
  241. package/lib/typescript/autocomplete-scripts/powershell-autocomplete-script.d.ts.map +1 -1
  242. package/lib/typescript/autocomplete-scripts/zsh-autocomplete-script.d.ts +2 -2
  243. package/lib/typescript/autocomplete-scripts/zsh-autocomplete-script.d.ts.map +1 -1
  244. package/lib/typescript/coerce/coerce-methods.d.ts +20 -0
  245. package/lib/typescript/coerce/coerce-methods.d.ts.map +1 -0
  246. package/lib/typescript/coerce/string-to-array.d.ts +6 -0
  247. package/lib/typescript/coerce/string-to-array.d.ts.map +1 -0
  248. package/lib/typescript/coerce/string-to-primitive.d.ts +5 -0
  249. package/lib/typescript/coerce/string-to-primitive.d.ts.map +1 -0
  250. package/lib/typescript/coerce/string-to-set.d.ts +6 -0
  251. package/lib/typescript/coerce/string-to-set.d.ts.map +1 -0
  252. package/lib/typescript/definitions/define-arguments.d.ts +7 -0
  253. package/lib/typescript/definitions/define-arguments.d.ts.map +1 -0
  254. package/lib/typescript/definitions/define-cli.d.ts +24 -0
  255. package/lib/typescript/definitions/define-cli.d.ts.map +1 -0
  256. package/lib/typescript/definitions/define-options.d.ts +7 -0
  257. package/lib/typescript/definitions/define-options.d.ts.map +1 -0
  258. package/lib/typescript/definitions/define-subcommand.d.ts +17 -0
  259. package/lib/typescript/definitions/define-subcommand.d.ts.map +1 -0
  260. package/lib/typescript/definitions/validate-cli-definition.d.ts +4 -0
  261. package/lib/typescript/definitions/validate-cli-definition.d.ts.map +1 -0
  262. package/lib/typescript/help-message/format-arguments.d.ts +3 -3
  263. package/lib/typescript/help-message/format-arguments.d.ts.map +1 -1
  264. package/lib/typescript/help-message/format-options.d.ts +3 -3
  265. package/lib/typescript/help-message/format-options.d.ts.map +1 -1
  266. package/lib/typescript/help-message/format-subcommands.d.ts +3 -3
  267. package/lib/typescript/help-message/format-subcommands.d.ts.map +1 -1
  268. package/lib/typescript/help-message/generate-for-cli.d.ts +8 -0
  269. package/lib/typescript/help-message/generate-for-cli.d.ts.map +1 -0
  270. package/lib/typescript/help-message/generate-for-subcommand.d.ts +4 -0
  271. package/lib/typescript/help-message/generate-for-subcommand.d.ts.map +1 -0
  272. package/lib/typescript/help-message/print-help.d.ts +5 -0
  273. package/lib/typescript/help-message/print-help.d.ts.map +1 -0
  274. package/lib/typescript/help-message/set-defaults.d.ts +4 -0
  275. package/lib/typescript/help-message/set-defaults.d.ts.map +1 -0
  276. package/lib/typescript/help-message/styles.d.ts +30 -106
  277. package/lib/typescript/help-message/styles.d.ts.map +1 -1
  278. package/lib/typescript/help-message/terminal-markdown.d.ts +3 -0
  279. package/lib/typescript/help-message/terminal-markdown.d.ts.map +1 -0
  280. package/lib/typescript/index.d.ts +23 -35
  281. package/lib/typescript/index.d.ts.map +1 -1
  282. package/lib/typescript/markdown/generate-markdown.d.ts +2 -2
  283. package/lib/typescript/markdown/generate-markdown.d.ts.map +1 -1
  284. package/lib/typescript/metadata/arguments-metadata.d.ts +4 -0
  285. package/lib/typescript/metadata/arguments-metadata.d.ts.map +1 -0
  286. package/lib/typescript/metadata/cli-metadata.d.ts +4 -0
  287. package/lib/typescript/metadata/cli-metadata.d.ts.map +1 -0
  288. package/lib/typescript/metadata/options-metadata.d.ts +4 -0
  289. package/lib/typescript/metadata/options-metadata.d.ts.map +1 -0
  290. package/lib/typescript/metadata/subcommands-metadata.d.ts +4 -0
  291. package/lib/typescript/metadata/subcommands-metadata.d.ts.map +1 -0
  292. package/lib/typescript/parse/context/cli-context-builder.d.ts +9 -0
  293. package/lib/typescript/parse/context/cli-context-builder.d.ts.map +1 -0
  294. package/lib/typescript/parse/context/object-context-builder.d.ts +6 -0
  295. package/lib/typescript/parse/context/object-context-builder.d.ts.map +1 -0
  296. package/lib/typescript/{parser/parse/parser-helpers.d.ts → parse/parser-utilities.d.ts} +18 -9
  297. package/lib/typescript/parse/parser-utilities.d.ts.map +1 -0
  298. package/lib/typescript/parse/safe-parse.d.ts +5 -0
  299. package/lib/typescript/parse/safe-parse.d.ts.map +1 -0
  300. package/lib/typescript/parse/validation/validate-context.d.ts +6 -0
  301. package/lib/typescript/parse/validation/validate-context.d.ts.map +1 -0
  302. package/lib/typescript/parse/validation/validators/arguments.d.ts +12 -0
  303. package/lib/typescript/parse/validation/validators/arguments.d.ts.map +1 -0
  304. package/lib/typescript/parse/validation/validators/conflict.d.ts +16 -0
  305. package/lib/typescript/parse/validation/validators/conflict.d.ts.map +1 -0
  306. package/lib/typescript/parse/validation/validators/exclusive.d.ts +16 -0
  307. package/lib/typescript/parse/validation/validators/exclusive.d.ts.map +1 -0
  308. package/lib/typescript/parse/validation/validators/explicitly-passed.d.ts +5 -0
  309. package/lib/typescript/parse/validation/validators/explicitly-passed.d.ts.map +1 -0
  310. package/lib/typescript/parse/validation/validators/options.d.ts +12 -0
  311. package/lib/typescript/parse/validation/validators/options.d.ts.map +1 -0
  312. package/lib/typescript/parse/validation/validators/requires.d.ts +18 -0
  313. package/lib/typescript/parse/validation/validators/requires.d.ts.map +1 -0
  314. package/lib/typescript/types/context-types.d.ts +135 -0
  315. package/lib/typescript/types/context-types.d.ts.map +1 -0
  316. package/lib/typescript/types/definitions-types.d.ts +294 -0
  317. package/lib/typescript/types/definitions-types.d.ts.map +1 -0
  318. package/lib/typescript/types/help-message-types.d.ts +134 -0
  319. package/lib/typescript/types/help-message-types.d.ts.map +1 -0
  320. package/lib/typescript/types/io-types.d.ts +96 -0
  321. package/lib/typescript/types/io-types.d.ts.map +1 -0
  322. package/lib/typescript/types/metadata-types.d.ts +75 -0
  323. package/lib/typescript/types/metadata-types.d.ts.map +1 -0
  324. package/lib/typescript/types/schema-types.d.ts +6 -0
  325. package/lib/typescript/types/schema-types.d.ts.map +1 -0
  326. package/lib/typescript/types/types.d.ts +61 -0
  327. package/lib/typescript/types/types.d.ts.map +1 -0
  328. package/lib/typescript/types/utilities-types.d.ts +17 -0
  329. package/lib/typescript/types/utilities-types.d.ts.map +1 -0
  330. package/lib/typescript/utilities.d.ts +24 -10
  331. package/lib/typescript/utilities.d.ts.map +1 -1
  332. package/package.json +29 -26
  333. package/src/autocomplete-scripts/bash-autocomplete-script.ts +13 -9
  334. package/src/autocomplete-scripts/powershell-autocomplete-script.ts +21 -13
  335. package/src/autocomplete-scripts/zsh-autocomplete-script.ts +27 -23
  336. package/src/coerce/coerce-methods.ts +75 -0
  337. package/src/coerce/string-to-array.ts +18 -0
  338. package/src/coerce/string-to-primitive.ts +31 -0
  339. package/src/coerce/string-to-set.ts +15 -0
  340. package/src/definitions/define-arguments.ts +10 -0
  341. package/src/definitions/define-cli.ts +105 -0
  342. package/src/definitions/define-options.ts +12 -0
  343. package/src/definitions/define-subcommand.ts +57 -0
  344. package/src/definitions/validate-cli-definition.ts +331 -0
  345. package/src/help-message/format-arguments.ts +57 -33
  346. package/src/help-message/format-options.ts +59 -34
  347. package/src/help-message/format-subcommands.ts +43 -21
  348. package/src/help-message/generate-for-cli.ts +114 -0
  349. package/src/help-message/generate-for-subcommand.ts +32 -0
  350. package/src/help-message/print-help.ts +13 -0
  351. package/src/help-message/set-defaults.ts +34 -0
  352. package/src/help-message/styles.ts +148 -103
  353. package/src/help-message/terminal-markdown.ts +147 -0
  354. package/src/index.ts +28 -97
  355. package/src/markdown/generate-markdown.ts +47 -58
  356. package/src/metadata/arguments-metadata.ts +28 -0
  357. package/src/metadata/cli-metadata.ts +26 -0
  358. package/src/metadata/options-metadata.ts +38 -0
  359. package/src/metadata/subcommands-metadata.ts +35 -0
  360. package/src/parse/context/cli-context-builder.ts +246 -0
  361. package/src/parse/context/object-context-builder.ts +63 -0
  362. package/src/{parser/parse/parser-helpers.ts → parse/parser-utilities.ts} +46 -25
  363. package/src/parse/safe-parse.ts +76 -0
  364. package/src/parse/validation/validate-context.ts +23 -0
  365. package/src/parse/validation/validators/arguments.ts +59 -0
  366. package/src/parse/validation/validators/conflict.ts +68 -0
  367. package/src/parse/validation/validators/exclusive.ts +70 -0
  368. package/src/parse/validation/validators/explicitly-passed.ts +15 -0
  369. package/src/parse/validation/validators/options.ts +59 -0
  370. package/src/parse/validation/validators/requires.ts +82 -0
  371. package/src/types/context-types.ts +171 -0
  372. package/src/types/definitions-types.ts +340 -0
  373. package/src/types/help-message-types.ts +153 -0
  374. package/src/types/io-types.ts +131 -0
  375. package/src/types/metadata-types.ts +104 -0
  376. package/src/types/schema-types.ts +9 -0
  377. package/src/types/types.ts +72 -0
  378. package/src/types/utilities-types.ts +26 -0
  379. package/src/utilities.ts +200 -23
  380. package/lib/commonjs/autocomplete-scripts/bash-autocomplete-script.cjs +0 -42
  381. package/lib/commonjs/autocomplete-scripts/bash-autocomplete-script.cjs.map +0 -1
  382. package/lib/commonjs/autocomplete-scripts/powershell-autocomplete-script.cjs +0 -31
  383. package/lib/commonjs/autocomplete-scripts/powershell-autocomplete-script.cjs.map +0 -1
  384. package/lib/commonjs/autocomplete-scripts/zsh-autocomplete-script.cjs +0 -41
  385. package/lib/commonjs/autocomplete-scripts/zsh-autocomplete-script.cjs.map +0 -1
  386. package/lib/commonjs/help-message/format-arguments.cjs +0 -1
  387. package/lib/commonjs/help-message/format-arguments.cjs.map +0 -1
  388. package/lib/commonjs/help-message/format-cli.cjs +0 -1
  389. package/lib/commonjs/help-message/format-cli.cjs.map +0 -1
  390. package/lib/commonjs/help-message/format-options.cjs +0 -1
  391. package/lib/commonjs/help-message/format-options.cjs.map +0 -1
  392. package/lib/commonjs/help-message/format-subcommands.cjs +0 -1
  393. package/lib/commonjs/help-message/format-subcommands.cjs.map +0 -1
  394. package/lib/commonjs/help-message/styles.cjs +0 -1
  395. package/lib/commonjs/help-message/styles.cjs.map +0 -1
  396. package/lib/commonjs/index.cjs +0 -1
  397. package/lib/commonjs/index.cjs.map +0 -1
  398. package/lib/commonjs/markdown/generate-markdown.cjs +0 -1
  399. package/lib/commonjs/markdown/generate-markdown.cjs.map +0 -1
  400. package/lib/commonjs/metadata/get-arguments-metadata.cjs +0 -1
  401. package/lib/commonjs/metadata/get-arguments-metadata.cjs.map +0 -1
  402. package/lib/commonjs/metadata/get-cli-metadata.cjs +0 -1
  403. package/lib/commonjs/metadata/get-cli-metadata.cjs.map +0 -1
  404. package/lib/commonjs/metadata/get-options-metadata.cjs +0 -1
  405. package/lib/commonjs/metadata/get-options-metadata.cjs.map +0 -1
  406. package/lib/commonjs/metadata/get-subcommands-metadata.cjs +0 -1
  407. package/lib/commonjs/metadata/get-subcommands-metadata.cjs.map +0 -1
  408. package/lib/commonjs/parser/parse/parse.cjs +0 -1
  409. package/lib/commonjs/parser/parse/parse.cjs.map +0 -1
  410. package/lib/commonjs/parser/parse/parser-helpers.cjs +0 -1
  411. package/lib/commonjs/parser/parse/parser-helpers.cjs.map +0 -1
  412. package/lib/commonjs/parser/safe-parse.cjs +0 -1
  413. package/lib/commonjs/parser/safe-parse.cjs.map +0 -1
  414. package/lib/commonjs/parser/unsafe-parse.cjs +0 -1
  415. package/lib/commonjs/parser/unsafe-parse.cjs.map +0 -1
  416. package/lib/commonjs/parser/validate/validate-type.cjs +0 -1
  417. package/lib/commonjs/parser/validate/validate-type.cjs.map +0 -1
  418. package/lib/commonjs/parser/validate/validate.cjs +0 -1
  419. package/lib/commonjs/parser/validate/validate.cjs.map +0 -1
  420. package/lib/commonjs/utilities.cjs +0 -1
  421. package/lib/commonjs/utilities.cjs.map +0 -1
  422. package/lib/commonjs/zod-utilities.cjs +0 -1
  423. package/lib/commonjs/zod-utilities.cjs.map +0 -1
  424. package/lib/module/autocomplete-scripts/bash-autocomplete-script.mjs +0 -42
  425. package/lib/module/autocomplete-scripts/bash-autocomplete-script.mjs.map +0 -1
  426. package/lib/module/autocomplete-scripts/powershell-autocomplete-script.mjs +0 -31
  427. package/lib/module/autocomplete-scripts/powershell-autocomplete-script.mjs.map +0 -1
  428. package/lib/module/autocomplete-scripts/zsh-autocomplete-script.mjs +0 -41
  429. package/lib/module/autocomplete-scripts/zsh-autocomplete-script.mjs.map +0 -1
  430. package/lib/module/help-message/format-arguments.mjs +0 -1
  431. package/lib/module/help-message/format-arguments.mjs.map +0 -1
  432. package/lib/module/help-message/format-cli.mjs +0 -1
  433. package/lib/module/help-message/format-cli.mjs.map +0 -1
  434. package/lib/module/help-message/format-options.mjs +0 -1
  435. package/lib/module/help-message/format-options.mjs.map +0 -1
  436. package/lib/module/help-message/format-subcommands.mjs +0 -1
  437. package/lib/module/help-message/format-subcommands.mjs.map +0 -1
  438. package/lib/module/help-message/styles.mjs +0 -1
  439. package/lib/module/help-message/styles.mjs.map +0 -1
  440. package/lib/module/index.mjs +0 -1
  441. package/lib/module/index.mjs.map +0 -1
  442. package/lib/module/markdown/generate-markdown.mjs +0 -1
  443. package/lib/module/markdown/generate-markdown.mjs.map +0 -1
  444. package/lib/module/metadata/get-arguments-metadata.mjs +0 -1
  445. package/lib/module/metadata/get-arguments-metadata.mjs.map +0 -1
  446. package/lib/module/metadata/get-cli-metadata.mjs +0 -1
  447. package/lib/module/metadata/get-cli-metadata.mjs.map +0 -1
  448. package/lib/module/metadata/get-options-metadata.mjs +0 -1
  449. package/lib/module/metadata/get-options-metadata.mjs.map +0 -1
  450. package/lib/module/metadata/get-subcommands-metadata.mjs +0 -1
  451. package/lib/module/metadata/get-subcommands-metadata.mjs.map +0 -1
  452. package/lib/module/parser/parse/parse.mjs +0 -1
  453. package/lib/module/parser/parse/parse.mjs.map +0 -1
  454. package/lib/module/parser/parse/parser-helpers.mjs +0 -1
  455. package/lib/module/parser/parse/parser-helpers.mjs.map +0 -1
  456. package/lib/module/parser/safe-parse.mjs +0 -1
  457. package/lib/module/parser/safe-parse.mjs.map +0 -1
  458. package/lib/module/parser/unsafe-parse.mjs +0 -1
  459. package/lib/module/parser/unsafe-parse.mjs.map +0 -1
  460. package/lib/module/parser/validate/validate-type.mjs +0 -1
  461. package/lib/module/parser/validate/validate-type.mjs.map +0 -1
  462. package/lib/module/parser/validate/validate.mjs +0 -1
  463. package/lib/module/parser/validate/validate.mjs.map +0 -1
  464. package/lib/module/utilities.mjs +0 -1
  465. package/lib/module/utilities.mjs.map +0 -1
  466. package/lib/module/zod-utilities.mjs +0 -1
  467. package/lib/module/zod-utilities.mjs.map +0 -1
  468. package/lib/typescript/help-message/format-cli.d.ts +0 -6
  469. package/lib/typescript/help-message/format-cli.d.ts.map +0 -1
  470. package/lib/typescript/metadata/get-arguments-metadata.d.ts +0 -4
  471. package/lib/typescript/metadata/get-arguments-metadata.d.ts.map +0 -1
  472. package/lib/typescript/metadata/get-cli-metadata.d.ts +0 -4
  473. package/lib/typescript/metadata/get-cli-metadata.d.ts.map +0 -1
  474. package/lib/typescript/metadata/get-options-metadata.d.ts +0 -4
  475. package/lib/typescript/metadata/get-options-metadata.d.ts.map +0 -1
  476. package/lib/typescript/metadata/get-subcommands-metadata.d.ts +0 -4
  477. package/lib/typescript/metadata/get-subcommands-metadata.d.ts.map +0 -1
  478. package/lib/typescript/metadata/metadata-types.d.ts +0 -80
  479. package/lib/typescript/metadata/metadata-types.d.ts.map +0 -1
  480. package/lib/typescript/parser/parse/parse-types.d.ts +0 -85
  481. package/lib/typescript/parser/parse/parse-types.d.ts.map +0 -1
  482. package/lib/typescript/parser/parse/parse.d.ts +0 -4
  483. package/lib/typescript/parser/parse/parse.d.ts.map +0 -1
  484. package/lib/typescript/parser/parse/parser-helpers.d.ts.map +0 -1
  485. package/lib/typescript/parser/safe-parse.d.ts +0 -4
  486. package/lib/typescript/parser/safe-parse.d.ts.map +0 -1
  487. package/lib/typescript/parser/unsafe-parse.d.ts +0 -4
  488. package/lib/typescript/parser/unsafe-parse.d.ts.map +0 -1
  489. package/lib/typescript/parser/validate/validate-type.d.ts +0 -22
  490. package/lib/typescript/parser/validate/validate-type.d.ts.map +0 -1
  491. package/lib/typescript/parser/validate/validate.d.ts +0 -11
  492. package/lib/typescript/parser/validate/validate.d.ts.map +0 -1
  493. package/lib/typescript/types.d.ts +0 -294
  494. package/lib/typescript/types.d.ts.map +0 -1
  495. package/lib/typescript/zod-utilities.d.ts +0 -28
  496. package/lib/typescript/zod-utilities.d.ts.map +0 -1
  497. package/src/help-message/format-cli.ts +0 -141
  498. package/src/metadata/get-arguments-metadata.ts +0 -25
  499. package/src/metadata/get-cli-metadata.ts +0 -23
  500. package/src/metadata/get-options-metadata.ts +0 -35
  501. package/src/metadata/get-subcommands-metadata.ts +0 -32
  502. package/src/metadata/metadata-types.ts +0 -114
  503. package/src/parser/parse/parse-types.ts +0 -89
  504. package/src/parser/parse/parse.ts +0 -230
  505. package/src/parser/safe-parse.ts +0 -103
  506. package/src/parser/unsafe-parse.ts +0 -98
  507. package/src/parser/validate/validate-type.ts +0 -21
  508. package/src/parser/validate/validate.ts +0 -66
  509. package/src/types.ts +0 -365
  510. package/src/zod-utilities.ts +0 -214
@@ -0,0 +1,135 @@
1
+ import type { Subcommand } from "./definitions-types.ts";
2
+ import type { Argument, Option } from "./definitions-types.ts";
3
+ import type { InferSchemaInputType, InferSchemaOutputType, SchemaType } from "./schema-types.ts";
4
+ interface ContextBase<S extends SchemaType> {
5
+ /** The schema that validates this option. */
6
+ schema: S;
7
+ /** Whether the schema is optional. */
8
+ optional: boolean;
9
+ /** The default value of the schema, if any. */
10
+ defaultValue: InferSchemaOutputType<S> | undefined;
11
+ }
12
+ interface OptionContextCli<S extends SchemaType> extends ContextBase<S> {
13
+ /**
14
+ * The CLI flag as provided by the user (e.g. `--foo` or `-f`).
15
+ *
16
+ * **Note:** This is only defined when the source is `terminal`.
17
+ */
18
+ flag: string;
19
+ /**
20
+ * The raw string value provided directly from the CLI.
21
+ *
22
+ * **Note:** This is only defined when the source is `terminal`.
23
+ */
24
+ stringValue: string;
25
+ passedValue?: never;
26
+ /**
27
+ * The source of the option:
28
+ *
29
+ * - `terminal` — explicitly provided by the command-line interface.
30
+ * - `default` — not provided by the user; a default value from the schema was used.
31
+ * - `programmatic` — supplied directly from code (e.g., passed to a function or API).
32
+ */
33
+ source: "terminal";
34
+ }
35
+ interface OptionContextDefault<S extends SchemaType> extends ContextBase<S> {
36
+ flag?: never;
37
+ stringValue?: never;
38
+ passedValue?: never;
39
+ /**
40
+ * The source of the option:
41
+ *
42
+ * - `terminal` — explicitly provided by the command-line interface.
43
+ * - `default` — not provided by the user; a default value from the schema was used.
44
+ * - `programmatic` — supplied directly from code (e.g., passed to a function or API).
45
+ */
46
+ source: "default";
47
+ }
48
+ interface OptionContextProgrammatic<S extends SchemaType> extends ContextBase<S> {
49
+ flag?: never;
50
+ stringValue?: never;
51
+ /**
52
+ * The value passed programmatically.
53
+ *
54
+ * **NOTE:** This is only defined when the source is `programmatic`.
55
+ */
56
+ passedValue: InferSchemaInputType<S>;
57
+ /**
58
+ * The source of the option:
59
+ *
60
+ * - `terminal` — explicitly provided by the command-line interface.
61
+ * - `default` — not provided by the user; a default value from the schema was used.
62
+ * - `programmatic` — supplied directly from code (e.g., passed to a function or API).
63
+ */
64
+ source: "programmatic";
65
+ }
66
+ export type OptionContext<S extends SchemaType> = OptionContextCli<S> | OptionContextDefault<S> | OptionContextProgrammatic<S>;
67
+ interface ArgumentContextCli<S extends SchemaType> extends ContextBase<S> {
68
+ /**
69
+ * The raw string value provided directly from the CLI.
70
+ *
71
+ * **Note:** This is only defined when the source is `terminal`.
72
+ */
73
+ stringValue: string;
74
+ passedValue?: never;
75
+ /**
76
+ * The source of the option:
77
+ *
78
+ * - `terminal` — explicitly provided by the command-line interface.
79
+ * - `default` — not provided by the user; a default value from the schema was used.
80
+ * - `programmatic` — supplied directly from code (e.g., passed to a function or API).
81
+ */
82
+ source: "terminal";
83
+ }
84
+ interface ArgumentContextDefault<S extends SchemaType> extends ContextBase<S> {
85
+ stringValue?: never;
86
+ passedValue?: never;
87
+ /**
88
+ * The source of the option:
89
+ *
90
+ * - `terminal` — explicitly provided by the command-line interface.
91
+ * - `default` — not provided by the user; a default value from the schema was used.
92
+ * - `programmatic` — supplied directly from code (e.g., passed to a function or API).
93
+ */
94
+ source: "default";
95
+ }
96
+ interface ArgumentContextProgrammatic<S extends SchemaType> extends ContextBase<S> {
97
+ stringValue?: never;
98
+ /**
99
+ * The value passed programmatically.
100
+ *
101
+ * **NOTE:** This is only defined when the source is `programmatic`.
102
+ */
103
+ passedValue: InferSchemaInputType<S>;
104
+ /**
105
+ * The source of the option:
106
+ *
107
+ * - `terminal` — explicitly provided by the command-line interface.
108
+ * - `default` — not provided by the user; a default value from the schema was used.
109
+ * - `programmatic` — supplied directly from code (e.g., passed to a function or API).
110
+ */
111
+ source: "programmatic";
112
+ }
113
+ export type ArgumentContext<S extends SchemaType> = ArgumentContextCli<S> | ArgumentContextDefault<S> | ArgumentContextProgrammatic<S>;
114
+ type OptionsRecordToOptionContext<T extends Record<string, Option>> = {
115
+ [K in keyof T]: OptionContext<T[K]["schema"]>;
116
+ };
117
+ type ArgumentsRecordToArgumentContext<T extends Record<string, Argument>> = {
118
+ [K in keyof T]: ArgumentContext<T[K]["schema"]>;
119
+ };
120
+ export type Context<S extends readonly Partial<Subcommand>[]> = {
121
+ [K in keyof S]: {
122
+ subcommand: S[K]["name"] extends string ? S[K]["name"] : undefined;
123
+ options: S[K]["options"] extends Record<string, Option> ? OptionsRecordToOptionContext<S[K]["options"]> : never;
124
+ arguments: S[K]["arguments"] extends Record<string, Argument> ? ArgumentsRecordToArgumentContext<S[K]["arguments"]> : never;
125
+ positionals: S[K]["allowPositionals"] extends true ? string[] : never;
126
+ };
127
+ }[number];
128
+ export interface ContextWide {
129
+ subcommand: string | undefined;
130
+ options?: Record<string, OptionContext<SchemaType>>;
131
+ arguments?: Record<string, ArgumentContext<SchemaType>>;
132
+ positionals?: string[];
133
+ }
134
+ export {};
135
+ //# sourceMappingURL=context-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-types.d.ts","sourceRoot":"","sources":["../../../src/types/context-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEjG,UAAU,WAAW,CAAC,CAAC,SAAS,UAAU;IACxC,6CAA6C;IAC7C,MAAM,EAAE,CAAC,CAAC;IAEV,sCAAsC;IACtC,QAAQ,EAAE,OAAO,CAAC;IAElB,+CAA+C;IAC/C,YAAY,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CACpD;AAED,UAAU,gBAAgB,CAAC,CAAC,SAAS,UAAU,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IACrE;;;;OAIG;IACH,IAAI,EAAE,MAAM,CA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AS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GACzD,gCAAgC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,GACnD,KAAK,CAAC;QACV,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,SAAS,IAAI,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC;KACvE;CACF,CAAC,MAAM,CAAC,CAAC;AAEV,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC,CAAC;IACxD,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB"}
@@ -0,0 +1,294 @@
1
+ import type { OutputTypeWide } from "./io-types.ts";
2
+ import type { InferSchemaOutputType, SchemaResult, SchemaType } from "./schema-types.ts";
3
+ import type { CoerceMethod, CoerceTypes } from "./types.ts";
4
+ import type { Widen } from "./utilities-types.ts";
5
+ export interface PreparedType {
6
+ schema: SchemaType;
7
+ coerceTo: CoerceTypes | undefined;
8
+ optional: boolean;
9
+ defaultValue: unknown;
10
+ validate: (value: string | undefined) => SchemaResult;
11
+ }
12
+ /** `schema` (generic) with required `coerce` */
13
+ interface RequiredCoerce<Schema extends SchemaType> {
14
+ schema: Schema;
15
+ coerce: CoerceMethod<Widen<InferSchemaOutputType<Schema>>>;
16
+ }
17
+ /** `schema` (string) with optional `coerce` */
18
+ interface OptionalCoerce {
19
+ schema: SchemaType<string | undefined>;
20
+ coerce?: CoerceMethod<string | undefined>;
21
+ }
22
+ export interface Cli extends Omit<Subcommand, "name" | "aliases" | "meta"> {
23
+ /** The name of the CLI program (main command). */
24
+ cliName: string;
25
+ /** Array of subcommands. Do not pass them directly instead use `defineSubcommand` */
26
+ subcommands?: [Subcommand, ...Subcommand[]];
27
+ /** The metadata for the CLI. */
28
+ meta?: Omit<SubcommandMeta, "placeholder" | "hidden">;
29
+ }
30
+ interface MetaBase {
31
+ /**
32
+ * Short explanation.
33
+ *
34
+ * Supports multi-line text and ansi color styles (like `chalk`).
35
+ *
36
+ * **NOTE:** For terminal markdown, use `descriptionMarkdown` instead.
37
+ */
38
+ description?: string;
39
+ /**
40
+ * Enables Markdown formatting for terminal output and generated documentation.
41
+ *
42
+ * Most common Markdown features (headings, lists, code, links, etc.) are supported when displayed in a terminal.
43
+ *
44
+ * **Terminal help output**
45
+ *
46
+ * - If both `description` and `descriptionMarkdown` are provided, only `description` is shown.
47
+ *
48
+ * **Markdown file generation**
49
+ *
50
+ * - If both fields are provided, only `descriptionMarkdown` is used.
51
+ */
52
+ descriptionMarkdown?: string;
53
+ /**
54
+ * Example to shown to the user.
55
+ *
56
+ * - In markdown, this will be displayed inside a code block.
57
+ */
58
+ example?: string;
59
+ /** Hide this argument from being documented (help message / markdown). This is useful for internal use. */
60
+ hidden?: boolean;
61
+ }
62
+ interface SubcommandMeta extends MetaBase {
63
+ /** Text to display as a placeholder for the expected arguments (e.g. `[options] <arg1> <arg2>`). */
64
+ placeholder?: string;
65
+ /** E.g. `cliName subcommand [options] <arg1> <arg2>` */
66
+ usage?: string;
67
+ }
68
+ export interface Subcommand {
69
+ /**
70
+ * The subcommand name
71
+ *
72
+ * - Make sure there are no duplicates across names and aliases in the same CLI.
73
+ *
74
+ * @example
75
+ * name: "test-app";
76
+ * name: "run-app";
77
+ */
78
+ name: string;
79
+ /**
80
+ * A list of aliases that can be used to invoke this subcommand.
81
+ *
82
+ * **NOTE:** Make sure there are no duplicates across names and aliases in the same CLI.
83
+ *
84
+ * @example
85
+ * name: "test-app";
86
+ * aliases: ["test"];
87
+ *
88
+ * name: "run-app";
89
+ * aliases: ["run"];
90
+ */
91
+ aliases?: string[];
92
+ /**
93
+ * - Allows positionals arguments for this subcommand.
94
+ * - Unlike `arguments`, which are strictly typed tuples, positionals arguments are untyped and represented as a string
95
+ * array of variable length.
96
+ * - When enabled and typed `arguments` are provided, `arguments` will be parsed first. Any remaining arguments will be
97
+ * considered positionals arguments and added to the `positionals` property in the result.
98
+ */
99
+ allowPositionals?: boolean;
100
+ /**
101
+ * For the option name (the key), use a valid **JavaScript** variable name.\
102
+ * **Supports:** `camelCase`, `PascalCase`, `snake_case`, and `SCREAMING_SNAKE_CASE`.\
103
+ * **Examples:**
104
+ *
105
+ * - `I` or `i` => `-i`
106
+ * - `InputDir`, `inputDir`, or `INPUT_DIR` => `--input-dir`
107
+ * - `Help`, `help`, or `HELP` => `--help`
108
+ */
109
+ options?: Record<string, Option>;
110
+ /**
111
+ * - Specifies a list of strictly typed arguments.
112
+ * - The order is important; for example, the first argument will be validated against the first specified type.
113
+ * - When **`allowPositional`** is **disabled**, the last argument can be optional.
114
+ * - When **`allowPositional`** is **enabled**, no optional arguments are allowed.
115
+ *
116
+ * **IMPORTANT:** The order of arguments matters!
117
+ */
118
+ arguments?: Record<string, Argument>;
119
+ /** Metadata used for help messages and documentation generation */
120
+ meta?: SubcommandMeta;
121
+ /**
122
+ * - A list of functions to execute when the subcommand/CLI is executed.
123
+ * - Do not use this directly instead use `onExecute` after creating the subcommand/cli.
124
+ *
125
+ * @deprecated For internal use only
126
+ * @example
127
+ * const helpCommand = defineSubcommand({ name: "help", options: [...] });
128
+ * helpCommand.onExecute((result) => console.log(result));
129
+ *
130
+ * const myCli = defineCLI({ name: "my-cli", subcommands: [helpCommand] });
131
+ * myCli.onExecute((result) => console.log(result));
132
+ */
133
+ _onExecute?: ((result: OutputTypeWide) => void)[];
134
+ }
135
+ interface OptionMeta extends MetaBase {
136
+ /** Text to display as a placeholder for the expected value (e.g. `<path>`, `<value>`). */
137
+ placeholder?: string;
138
+ /**
139
+ * Custom default value.
140
+ *
141
+ * - Use an empty string to intentionally show no default.
142
+ */
143
+ default?: string;
144
+ /** Override whether this option is considered optional. */
145
+ optional?: boolean;
146
+ }
147
+ interface OptionBase {
148
+ /**
149
+ * For the option alias, use a valid **JavaScript** variable name.\
150
+ * **Supports:** `camelCase`, `PascalCase`, `snake_case`, and `SCREAMING_SNAKE_CASE`.\
151
+ * **Examples:**
152
+ *
153
+ * - `I` or `i` => `-i`
154
+ * - `InputDir`, `inputDir`, or `INPUT_DIR` => `--input-dir`
155
+ * - `Help`, `help`, or `HELP` => `--help`
156
+ */
157
+ aliases?: string[];
158
+ /**
159
+ * When `true`, this option must appear on its own. It cannot be used together with any other option or argument,
160
+ * except those explicitly listed in `requires`.
161
+ *
162
+ * Only explicitly provided inputs are checked — options or arguments that are present only through default values are
163
+ * ignored.
164
+ *
165
+ * @example
166
+ * defineOptions({
167
+ * // nothing else can be used with this option (no other options or arguments)
168
+ * output: {
169
+ * exclusive: true,
170
+ * },
171
+ * });
172
+ *
173
+ * defineOptions({
174
+ * // only `input` (could be an option or argument name) can be used with this option
175
+ * output: {
176
+ * exclusive: true,
177
+ * requires: ["input"],
178
+ * },
179
+ * });
180
+ */
181
+ exclusive?: boolean;
182
+ /**
183
+ * Declares other options ir arguments that must be provided when this option is used.
184
+ *
185
+ * If this option appears in the parsed input, each entry listed in `requires` must also be present. Default values do
186
+ * not satisfy this requirement — the user must explicitly provide the required option(s).
187
+ *
188
+ * Example:
189
+ *
190
+ * @example
191
+ * defineOptions({
192
+ * // using the option `output` also requires `input` (could be an option or argument name)
193
+ * output: {
194
+ * requires: ["input"],
195
+ * },
196
+ * });
197
+ */
198
+ requires?: string[];
199
+ /**
200
+ * Declares options or arguments that conflict with this option.
201
+ *
202
+ * If any entry in `conflictWith` is provided alongside this option, the parser will report an error. Conflicts are
203
+ * only checked against explicitly supplied values — defaults do not trigger conflicts.
204
+ *
205
+ * @example
206
+ * defineOptions({
207
+ * // the option `help` cannot be used together with `version` (could be an option or argument name)
208
+ * help: {
209
+ * conflictWith: ["version"],
210
+ * },
211
+ * });
212
+ */
213
+ conflictWith?: string[];
214
+ /** Used for help message and documentation generation. */
215
+ meta?: OptionMeta;
216
+ /** @deprecated For internal use only */
217
+ _preparedType?: PreparedType;
218
+ }
219
+ export type Option<Schema extends SchemaType = SchemaType> = (OptionBase & RequiredCoerce<Schema>) | (OptionBase & OptionalCoerce);
220
+ interface ArgumentMeta extends MetaBase {
221
+ /** Override the argument name in the help message and documentation. */
222
+ name?: string;
223
+ /**
224
+ * Custom default value.
225
+ *
226
+ * Use an empty string to intentionally show no default.
227
+ */
228
+ default?: string;
229
+ /** Override whether this option is considered optional. */
230
+ optional?: boolean;
231
+ }
232
+ interface ArgumentBase {
233
+ /**
234
+ * When `true`, this argument must appear on its own. It cannot be used together with any other option or argument,
235
+ * except those explicitly listed in `requires`.
236
+ *
237
+ * Only explicitly provided inputs are checked — options or arguments that are present only through default values are
238
+ * ignored.
239
+ *
240
+ * @example
241
+ * defineArguments({
242
+ * // nothing else can be used with this argument (no other options or arguments)
243
+ * output: {
244
+ * exclusive: true,
245
+ * },
246
+ * });
247
+ *
248
+ * defineArguments({
249
+ * // only `input` (could be an option or argument name) can be used with this argument
250
+ * output: {
251
+ * exclusive: true,
252
+ * requires: ["input"],
253
+ * },
254
+ * });
255
+ */
256
+ exclusive?: boolean;
257
+ /**
258
+ * Declares other options/arguments that must be provided when this argument is used.
259
+ *
260
+ * If this argument appears in the parsed input, each entry listed in `requires` must also be present. Default values
261
+ * do not satisfy this requirement — the user must explicitly provide the required option(s).
262
+ *
263
+ * @example
264
+ * defineArguments({
265
+ * // using the argument `output` also requires `input` (could be an option or argument name)
266
+ * output: {
267
+ * requires: ["input"],
268
+ * },
269
+ * });
270
+ */
271
+ requires?: string[];
272
+ /**
273
+ * Declares options or arguments that conflict with this argument.
274
+ *
275
+ * If any entry in `conflictWith` is provided alongside this argument, the parser will report an error. Conflicts are
276
+ * only checked against explicitly supplied values — defaults do not trigger conflicts.
277
+ *
278
+ * @example
279
+ * defineArguments({
280
+ * // the argument `help` cannot be used together with `version` (could be an option or argument name)
281
+ * help: {
282
+ * conflictWith: ["version"],
283
+ * },
284
+ * });
285
+ */
286
+ conflictWith?: string[];
287
+ /** Used for help message and documentation generation. */
288
+ meta?: ArgumentMeta;
289
+ /** @deprecated For internal use only */
290
+ _preparedType?: PreparedType;
291
+ }
292
+ export type Argument<Schema extends SchemaType = SchemaType> = (ArgumentBase & RequiredCoerce<Schema>) | (ArgumentBase & OptionalCoerce);
293
+ export {};
294
+ //# sourceMappingURL=definitions-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions-types.d.ts","sourceRoot":"","sources":["../../../src/types/definitions-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,WAAW,GAAG,SAAS,CAAC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,YAAY,CAAC;CACvD;AAMD,gDAAgD;AAChD,UAAU,cAAc,CAAC,MAAM,SAAS,UAAU;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;CAC5D;AAED,+CAA+C;AAC/C,UAAU,cAAc;IACtB,MAAM,EAAE,UAAU,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACvC,MAAM,CAAC,EAA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;IAExB,0DAA0D;IAC1D,IAAI,CAAC,EAAE,YAAY,CAAC;IAEpB,wCAAwC;IACxC,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B;AAED,MAAM,MAAM,QAAQ,CAAC,MAAM,SAAS,UAAU,GAAG,UAAU,IACvD,CAAC,YAAY,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,GACvC,CAAC,YAAY,GAAG,cAAc,CAAC,CAAC"}
@@ -0,0 +1,134 @@
1
+ export interface PrintHelpOptions {
2
+ /** The style to use for the help message. */
3
+ style?: Partial<HelpMessageStyleImpl>;
4
+ /**
5
+ * Whether to transform the argument (not option) name to kebab case.
6
+ *
7
+ * @default true
8
+ */
9
+ kebabCaseArgumentName?: boolean;
10
+ /**
11
+ * The renderer to use for the markdown.
12
+ *
13
+ * @default terminal
14
+ */
15
+ markdownRenderer?: "terminal" | "html";
16
+ /**
17
+ * The number of spaces to put before the name of (option/argument/subcommand).
18
+ *
19
+ * @default 2
20
+ */
21
+ indentBeforeName?: number;
22
+ /**
23
+ * The number of spaces to put after the name of (option/argument/subcommand), between the name and the description
24
+ * (space between columns).
25
+ *
26
+ * @default 4
27
+ */
28
+ indentAfterName?: number;
29
+ /**
30
+ * The number of spaces to put before the placeholder.
31
+ *
32
+ * @default 1
33
+ */
34
+ indentBeforePlaceholder?: number;
35
+ /**
36
+ * The number of spaces to put before a new line:
37
+ *
38
+ * - Description new lines.
39
+ * - Example under description.
40
+ *
41
+ * @default 0
42
+ */
43
+ newLineIndent?: number;
44
+ /**
45
+ * The number of empty lines to put between lines.
46
+ *
47
+ * @default 0
48
+ */
49
+ emptyLines?: number;
50
+ /**
51
+ * The number of empty lines to put before the title.
52
+ *
53
+ * @default 1
54
+ */
55
+ emptyLinesBeforeTitle?: number;
56
+ /**
57
+ * The number of empty lines to put after the title.
58
+ *
59
+ * @default 0
60
+ */
61
+ emptyLinesAfterTitle?: number;
62
+ /**
63
+ * The keyword to use for the example.
64
+ *
65
+ * @default "Example:"
66
+ */
67
+ exampleKeyword?: string;
68
+ /**
69
+ * The keyword to use for the optional.
70
+ *
71
+ * @default "(optional)"
72
+ */
73
+ optionalKeyword?: string;
74
+ /**
75
+ * The keyword to use for the default. where `{{ value }}` will be replaced with the default value.
76
+ *
77
+ * @default "(default: {{ value }})"
78
+ */
79
+ defaultKeyword?: string;
80
+ /**
81
+ * The title to use for the usage.
82
+ *
83
+ * @default "USAGE"
84
+ */
85
+ usageTitle?: string;
86
+ /**
87
+ * The title to use for the description.
88
+ *
89
+ * @default "DESCRIPTION"
90
+ */
91
+ descriptionTitle?: string;
92
+ /**
93
+ * The title to use for the commands.
94
+ *
95
+ * @default "COMMANDS"
96
+ */
97
+ commandsTitle?: string;
98
+ /**
99
+ * The title to use for the options.
100
+ *
101
+ * @default "OPTIONS"
102
+ */
103
+ optionsTitle?: string;
104
+ /**
105
+ * The title to use for the arguments.
106
+ *
107
+ * @default "ARGUMENTS"
108
+ */
109
+ argumentsTitle?: string;
110
+ /**
111
+ * The title to use for the examples.
112
+ *
113
+ * @default "EXAMPLE"
114
+ */
115
+ exampleTitle?: string;
116
+ }
117
+ export interface ColorFunctionType {
118
+ (...text: unknown[]): string;
119
+ }
120
+ /** - The colors to use for the help message. */
121
+ export interface HelpMessageStyleImpl {
122
+ title: ColorFunctionType;
123
+ description: ColorFunctionType;
124
+ default: ColorFunctionType;
125
+ optional: ColorFunctionType;
126
+ exampleTitle: ColorFunctionType;
127
+ example: ColorFunctionType;
128
+ command: ColorFunctionType;
129
+ option: ColorFunctionType;
130
+ argument: ColorFunctionType;
131
+ placeholder: ColorFunctionType;
132
+ punctuation: ColorFunctionType;
133
+ }
134
+ //# sourceMappingURL=help-message-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help-message-types.d.ts","sourceRoot":"","sources":["../../../src/types/help-message-types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,6CAA6C;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC,oB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AAE,iBAAiB,CAAC;IAC5B,YAAY,EAAE,iBAAiB,CAAC;IAChC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,WAAW,EAAE,iBAAiB,CAAC;IAC/B,WAAW,EAAE,iBAAiB,CAAC;CAChC"}
@@ -0,0 +1,96 @@
1
+ import type { Context, ContextWide } from "./context-types.ts";
2
+ import type { Argument, Cli, Option, Subcommand } from "./definitions-types.ts";
3
+ import type { InferSchemaInputType, InferSchemaOutputType } from "./schema-types.ts";
4
+ import type { Prettify, ToOptional, AllowUndefinedIfOptional as AddUndefinedIfAllOptional } from "./utilities-types.ts";
5
+ /** Output options type */
6
+ type OptionsOutputType<T extends Record<string, Option>> = Prettify<ToOptional<{
7
+ [K in keyof T]: InferSchemaOutputType<T[K]["schema"]>;
8
+ }>>;
9
+ /** Input options type */
10
+ type OptionsInputType<T extends Record<string, Option>> = Prettify<ToOptional<{
11
+ [K in keyof T]: InferSchemaInputType<T[K]["schema"]>;
12
+ }>>;
13
+ /** Output arguments type */
14
+ type ArgumentsOutputType<T extends Record<string, Argument>> = Prettify<ToOptional<{
15
+ [K in keyof T]: InferSchemaOutputType<T[K]["schema"]>;
16
+ }>>;
17
+ /** Input arguments type */
18
+ type ArgumentsInputType<T extends Record<string, Argument>> = Prettify<ToOptional<{
19
+ [K in keyof T]: InferSchemaInputType<T[K]["schema"]>;
20
+ }>>;
21
+ /**
22
+ * - Infer options output type.
23
+ *
24
+ * @example
25
+ * const myCommand = defineSubcommand({ name: "my-command", options: [...] });
26
+ * type MyCommandOptionsOutput = InferOptionsOutputType<typeof myCommand>;
27
+ */
28
+ export type InferOptionsOutputType<T extends Cli | Subcommand> = T["options"] extends Record<string, Option> ? OptionsOutputType<T["options"]> : undefined;
29
+ /**
30
+ * - Infer arguments output type.
31
+ *
32
+ * @example
33
+ * const myCommand = defineSubcommand({ name: "my-command", arguments: [...] });
34
+ * type MyCommandArgumentsOutput = InferArgumentsOutputType<typeof myCommand>;
35
+ */
36
+ export type InferArgumentsOutputType<T extends Cli | Subcommand> = T["arguments"] extends Record<string, Argument> ? ArgumentsOutputType<T["arguments"]> : undefined;
37
+ /**
38
+ * - Infer arguments input type.
39
+ *
40
+ * @example
41
+ * const myCommand = defineSubcommand({ name: "my-command", arguments: [...] });
42
+ * type MyCommandArgumentsInput = InferArgumentsInputType<typeof myCommand>;
43
+ */
44
+ export type InferArgumentsInputType<T extends Cli | Subcommand> = T["arguments"] extends Record<string, Argument> ? ArgumentsInputType<T["arguments"]> : undefined;
45
+ /**
46
+ * - Infer options input type.
47
+ *
48
+ * @example
49
+ * const myCommand = defineSubcommand({ name: "my-command", options: [...] });
50
+ * type MyCommandOptionsInput = inferOptionsInputType<typeof myCommand>;
51
+ */
52
+ export type inferOptionsInputType<T extends Cli | Subcommand> = T["options"] extends Record<string, Option> ? OptionsInputType<T["options"]> : undefined;
53
+ /**
54
+ * - Infer options, arguments, and positionals input types from the CLI/subcommand definition.
55
+ *
56
+ * @example
57
+ * const myCommand = defineSubcommand({ name: "my-command", ... });
58
+ * type MyCommandInput = InferInputType<typeof myCommand>;
59
+ */
60
+ export type InferInputType<T extends Cli | Subcommand> = Prettify<AddUndefinedIfAllOptional<ToOptional<{
61
+ positionals: T["allowPositionals"] extends true ? string[] : undefined;
62
+ options: T["options"] extends Record<string, Option> ? AddUndefinedIfAllOptional<OptionsInputType<T["options"]>> : undefined;
63
+ arguments: T["arguments"] extends Record<string, Argument> ? AddUndefinedIfAllOptional<ArgumentsInputType<T["arguments"]>> : undefined;
64
+ }>>>;
65
+ export interface InputTypeWide {
66
+ arguments?: Record<string, unknown>;
67
+ options?: Record<string, unknown>;
68
+ positionals?: string[];
69
+ }
70
+ /**
71
+ * - Infer schema output type.
72
+ *
73
+ * @example
74
+ * const myCommand = defineSubcommand({ name: "my-command", ... });
75
+ * type MyCommandOutput = InferOutputType<typeof myCommand>;
76
+ */
77
+ export type InferOutputType<T extends Cli | Subcommand> = Prettify<{
78
+ subcommand: "name" extends keyof T ? T["name"] : undefined;
79
+ options: T["options"] extends Record<string, Option> ? OptionsOutputType<T["options"]> : never;
80
+ arguments: T["arguments"] extends Record<string, Argument> ? ArgumentsOutputType<T["arguments"]> : never;
81
+ positionals: T["allowPositionals"] extends true ? string[] : never;
82
+ context: Context<[T]>;
83
+ }>;
84
+ /** Same as `InferOutputType` but for multiple subcommands/cli */
85
+ export type OutputType<S extends readonly (Cli | Subcommand)[]> = {
86
+ [K in keyof S]: InferOutputType<S[K]>;
87
+ }[number];
88
+ export interface OutputTypeWide {
89
+ subcommand: string | undefined;
90
+ positionals?: string[];
91
+ arguments?: Record<string, unknown>;
92
+ options?: Record<string, unknown>;
93
+ context: ContextWide;
94
+ }
95
+ export {};
96
+ //# sourceMappingURL=io-types.d.ts.map