@shell-shock/core 0.17.8 → 0.17.11

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 (272) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +29 -1
  2. package/dist/api.cjs +36 -1
  3. package/dist/api.cjs.map +1 -0
  4. package/dist/api.d.cts +2 -77
  5. package/dist/api.d.cts.map +1 -1
  6. package/dist/api.d.mts +2 -76
  7. package/dist/api.d.mts.map +1 -1
  8. package/dist/api.mjs +35 -1
  9. package/dist/api.mjs.map +1 -1
  10. package/dist/components/command-validation-logic.cjs +291 -1
  11. package/dist/components/command-validation-logic.cjs.map +1 -0
  12. package/dist/components/command-validation-logic.d.cts +1 -3
  13. package/dist/components/command-validation-logic.d.cts.map +1 -1
  14. package/dist/components/command-validation-logic.d.mts +1 -3
  15. package/dist/components/command-validation-logic.d.mts.map +1 -1
  16. package/dist/components/command-validation-logic.mjs +288 -1
  17. package/dist/components/command-validation-logic.mjs.map +1 -1
  18. package/dist/components/docs.cjs +265 -1
  19. package/dist/components/docs.cjs.map +1 -0
  20. package/dist/components/docs.d.cts +4 -5
  21. package/dist/components/docs.d.cts.map +1 -1
  22. package/dist/components/docs.d.mts +4 -5
  23. package/dist/components/docs.d.mts.map +1 -1
  24. package/dist/components/docs.mjs +256 -1
  25. package/dist/components/docs.mjs.map +1 -1
  26. package/dist/components/exec-builtin.cjs +429 -15
  27. package/dist/components/exec-builtin.cjs.map +1 -0
  28. package/dist/components/exec-builtin.d.cts +1 -2
  29. package/dist/components/exec-builtin.d.cts.map +1 -1
  30. package/dist/components/exec-builtin.d.mts +1 -2
  31. package/dist/components/exec-builtin.d.mts.map +1 -1
  32. package/dist/components/exec-builtin.mjs +424 -15
  33. package/dist/components/exec-builtin.mjs.map +1 -1
  34. package/dist/components/helpers.cjs +119 -1
  35. package/dist/components/helpers.cjs.map +1 -0
  36. package/dist/components/helpers.d.cts +6 -8
  37. package/dist/components/helpers.d.cts.map +1 -1
  38. package/dist/components/helpers.d.mts +6 -8
  39. package/dist/components/helpers.d.mts.map +1 -1
  40. package/dist/components/helpers.mjs +111 -1
  41. package/dist/components/helpers.mjs.map +1 -1
  42. package/dist/components/index.cjs +58 -1
  43. package/dist/components/index.mjs +10 -1
  44. package/dist/components/options-parser-logic.cjs +959 -5
  45. package/dist/components/options-parser-logic.cjs.map +1 -0
  46. package/dist/components/options-parser-logic.d.cts +8 -9
  47. package/dist/components/options-parser-logic.d.cts.map +1 -1
  48. package/dist/components/options-parser-logic.d.mts +8 -9
  49. package/dist/components/options-parser-logic.d.mts.map +1 -1
  50. package/dist/components/options-parser-logic.mjs +944 -5
  51. package/dist/components/options-parser-logic.mjs.map +1 -1
  52. package/dist/components/state-builtin.cjs +630 -8
  53. package/dist/components/state-builtin.cjs.map +1 -0
  54. package/dist/components/state-builtin.d.cts +4 -5
  55. package/dist/components/state-builtin.d.cts.map +1 -1
  56. package/dist/components/state-builtin.d.mts +4 -5
  57. package/dist/components/state-builtin.d.mts.map +1 -1
  58. package/dist/components/state-builtin.mjs +622 -8
  59. package/dist/components/state-builtin.mjs.map +1 -1
  60. package/dist/components/usage.cjs +116 -1
  61. package/dist/components/usage.cjs.map +1 -0
  62. package/dist/components/usage.d.cts +1 -2
  63. package/dist/components/usage.d.cts.map +1 -1
  64. package/dist/components/usage.d.mts +1 -2
  65. package/dist/components/usage.d.mts.map +1 -1
  66. package/dist/components/usage.mjs +113 -1
  67. package/dist/components/usage.mjs.map +1 -1
  68. package/dist/components/utils-builtin.cjs +839 -33
  69. package/dist/components/utils-builtin.cjs.map +1 -0
  70. package/dist/components/utils-builtin.d.cts +7 -8
  71. package/dist/components/utils-builtin.d.cts.map +1 -1
  72. package/dist/components/utils-builtin.d.mts +7 -8
  73. package/dist/components/utils-builtin.d.mts.map +1 -1
  74. package/dist/components/utils-builtin.mjs +828 -33
  75. package/dist/components/utils-builtin.mjs.map +1 -1
  76. package/dist/config.cjs +65 -1
  77. package/dist/config.cjs.map +1 -0
  78. package/dist/config.d.cts +29 -8
  79. package/dist/config.d.cts.map +1 -1
  80. package/dist/config.d.mts +29 -8
  81. package/dist/config.d.mts.map +1 -1
  82. package/dist/config.mjs +62 -1
  83. package/dist/config.mjs.map +1 -1
  84. package/dist/contexts/command.cjs +26 -1
  85. package/dist/contexts/command.cjs.map +1 -0
  86. package/dist/contexts/command.d.cts.map +1 -1
  87. package/dist/contexts/command.d.mts.map +1 -1
  88. package/dist/contexts/command.mjs +23 -1
  89. package/dist/contexts/command.mjs.map +1 -1
  90. package/dist/contexts/index.cjs +9 -1
  91. package/dist/contexts/index.mjs +4 -1
  92. package/dist/contexts/options.cjs +63 -1
  93. package/dist/contexts/options.cjs.map +1 -0
  94. package/dist/contexts/options.d.cts.map +1 -1
  95. package/dist/contexts/options.d.mts.map +1 -1
  96. package/dist/contexts/options.mjs +57 -1
  97. package/dist/contexts/options.mjs.map +1 -1
  98. package/dist/engine.cjs +138 -0
  99. package/dist/engine.cjs.map +1 -0
  100. package/dist/engine.d.cts +79 -0
  101. package/dist/engine.d.cts.map +1 -0
  102. package/dist/engine.d.mts +79 -0
  103. package/dist/engine.d.mts.map +1 -0
  104. package/dist/engine.mjs +136 -0
  105. package/dist/engine.mjs.map +1 -0
  106. package/dist/helpers/automd.cjs +70 -1
  107. package/dist/helpers/automd.cjs.map +1 -0
  108. package/dist/helpers/automd.mjs +69 -1
  109. package/dist/helpers/automd.mjs.map +1 -1
  110. package/dist/helpers/docs-helpers.cjs +23 -1
  111. package/dist/helpers/docs-helpers.cjs.map +1 -0
  112. package/dist/helpers/docs-helpers.mjs +22 -1
  113. package/dist/helpers/docs-helpers.mjs.map +1 -1
  114. package/dist/helpers/get-framework.cjs +24 -0
  115. package/dist/helpers/get-framework.cjs.map +1 -0
  116. package/dist/helpers/get-framework.mjs +24 -0
  117. package/dist/helpers/get-framework.mjs.map +1 -0
  118. package/dist/helpers/paths.cjs +137 -1
  119. package/dist/helpers/paths.cjs.map +1 -0
  120. package/dist/helpers/paths.mjs +133 -1
  121. package/dist/helpers/paths.mjs.map +1 -1
  122. package/dist/helpers/persistence.cjs +113 -1
  123. package/dist/helpers/persistence.cjs.map +1 -0
  124. package/dist/helpers/persistence.mjs +112 -1
  125. package/dist/helpers/persistence.mjs.map +1 -1
  126. package/dist/helpers/update-package-json.cjs +65 -1
  127. package/dist/helpers/update-package-json.cjs.map +1 -0
  128. package/dist/helpers/update-package-json.mjs +63 -1
  129. package/dist/helpers/update-package-json.mjs.map +1 -1
  130. package/dist/helpers/utilities.cjs +95 -1
  131. package/dist/helpers/utilities.cjs.map +1 -0
  132. package/dist/helpers/utilities.mjs +93 -1
  133. package/dist/helpers/utilities.mjs.map +1 -1
  134. package/dist/helpers/validations.cjs +71 -1
  135. package/dist/helpers/validations.cjs.map +1 -0
  136. package/dist/helpers/validations.mjs +69 -1
  137. package/dist/helpers/validations.mjs.map +1 -1
  138. package/dist/index.cjs +123 -1
  139. package/dist/index.cjs.map +1 -0
  140. package/dist/index.d.cts +80 -5
  141. package/dist/index.d.cts.map +1 -0
  142. package/dist/index.d.mts +80 -5
  143. package/dist/index.d.mts.map +1 -0
  144. package/dist/index.mjs +119 -1
  145. package/dist/index.mjs.map +1 -0
  146. package/dist/package.cjs +12 -0
  147. package/dist/package.cjs.map +1 -0
  148. package/dist/package.mjs +6 -0
  149. package/dist/package.mjs.map +1 -0
  150. package/dist/plugin-utils/compute-bin.cjs +48 -1
  151. package/dist/plugin-utils/compute-bin.cjs.map +1 -0
  152. package/dist/plugin-utils/compute-bin.d.cts +2 -2
  153. package/dist/plugin-utils/compute-bin.d.cts.map +1 -1
  154. package/dist/plugin-utils/compute-bin.d.mts +2 -2
  155. package/dist/plugin-utils/compute-bin.d.mts.map +1 -1
  156. package/dist/plugin-utils/compute-bin.mjs +47 -1
  157. package/dist/plugin-utils/compute-bin.mjs.map +1 -1
  158. package/dist/plugin-utils/context-helpers.cjs +224 -1
  159. package/dist/plugin-utils/context-helpers.cjs.map +1 -0
  160. package/dist/plugin-utils/context-helpers.d.cts +4 -4
  161. package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
  162. package/dist/plugin-utils/context-helpers.d.mts +4 -4
  163. package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
  164. package/dist/plugin-utils/context-helpers.mjs +214 -1
  165. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  166. package/dist/plugin-utils/deepkit.cjs +70 -1
  167. package/dist/plugin-utils/deepkit.cjs.map +1 -0
  168. package/dist/plugin-utils/deepkit.d.cts +5 -5
  169. package/dist/plugin-utils/deepkit.d.cts.map +1 -1
  170. package/dist/plugin-utils/deepkit.d.mts +5 -5
  171. package/dist/plugin-utils/deepkit.d.mts.map +1 -1
  172. package/dist/plugin-utils/deepkit.mjs +68 -1
  173. package/dist/plugin-utils/deepkit.mjs.map +1 -1
  174. package/dist/plugin-utils/description-helpers.cjs +112 -2
  175. package/dist/plugin-utils/description-helpers.cjs.map +1 -0
  176. package/dist/plugin-utils/description-helpers.d.cts.map +1 -1
  177. package/dist/plugin-utils/description-helpers.d.mts.map +1 -1
  178. package/dist/plugin-utils/description-helpers.mjs +107 -2
  179. package/dist/plugin-utils/description-helpers.mjs.map +1 -1
  180. package/dist/plugin-utils/get-command-tree.cjs +118 -1
  181. package/dist/plugin-utils/get-command-tree.cjs.map +1 -0
  182. package/dist/plugin-utils/get-command-tree.d.cts.map +1 -1
  183. package/dist/plugin-utils/get-command-tree.d.mts.map +1 -1
  184. package/dist/plugin-utils/get-command-tree.mjs +114 -1
  185. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  186. package/dist/plugin-utils/index.cjs +39 -1
  187. package/dist/plugin-utils/index.d.cts +2 -2
  188. package/dist/plugin-utils/index.d.mts +2 -2
  189. package/dist/plugin-utils/index.mjs +10 -1
  190. package/dist/plugin-utils/reflect.cjs +52 -1
  191. package/dist/plugin-utils/reflect.cjs.map +1 -0
  192. package/dist/plugin-utils/reflect.d.cts.map +1 -1
  193. package/dist/plugin-utils/reflect.d.mts.map +1 -1
  194. package/dist/plugin-utils/reflect.mjs +50 -1
  195. package/dist/plugin-utils/reflect.mjs.map +1 -1
  196. package/dist/plugin-utils/traverse-command-tree.cjs +65 -1
  197. package/dist/plugin-utils/traverse-command-tree.cjs.map +1 -0
  198. package/dist/plugin-utils/traverse-command-tree.d.cts.map +1 -1
  199. package/dist/plugin-utils/traverse-command-tree.d.mts.map +1 -1
  200. package/dist/plugin-utils/traverse-command-tree.mjs +62 -1
  201. package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
  202. package/dist/plugin-utils/type-checks.cjs +222 -1
  203. package/dist/plugin-utils/type-checks.cjs.map +1 -0
  204. package/dist/plugin-utils/type-checks.d.cts +5 -5
  205. package/dist/plugin-utils/type-checks.d.cts.map +1 -1
  206. package/dist/plugin-utils/type-checks.d.mts +5 -5
  207. package/dist/plugin-utils/type-checks.d.mts.map +1 -1
  208. package/dist/plugin-utils/type-checks.mjs +217 -1
  209. package/dist/plugin-utils/type-checks.mjs.map +1 -1
  210. package/dist/plugin.cjs +495 -4
  211. package/dist/plugin.cjs.map +1 -0
  212. package/dist/plugin.d.cts.map +1 -1
  213. package/dist/plugin.d.mts.map +1 -1
  214. package/dist/plugin.mjs +488 -4
  215. package/dist/plugin.mjs.map +1 -1
  216. package/dist/resolver/helpers.cjs +182 -1
  217. package/dist/resolver/helpers.cjs.map +1 -0
  218. package/dist/resolver/helpers.mjs +178 -1
  219. package/dist/resolver/helpers.mjs.map +1 -1
  220. package/dist/resolver/resolve.cjs +479 -1
  221. package/dist/resolver/resolve.cjs.map +1 -0
  222. package/dist/resolver/resolve.mjs +478 -1
  223. package/dist/resolver/resolve.mjs.map +1 -1
  224. package/dist/types/command.cjs +402 -1
  225. package/dist/types/command.cjs.map +1 -0
  226. package/dist/types/command.d.cts +61 -119
  227. package/dist/types/command.d.cts.map +1 -1
  228. package/dist/types/command.d.mts +61 -119
  229. package/dist/types/command.d.mts.map +1 -1
  230. package/dist/types/command.mjs +367 -1
  231. package/dist/types/command.mjs.map +1 -1
  232. package/dist/types/config.cjs +175 -1
  233. package/dist/types/config.cjs.map +1 -0
  234. package/dist/types/config.d.cts +19 -12
  235. package/dist/types/config.d.cts.map +1 -1
  236. package/dist/types/config.d.mts +19 -12
  237. package/dist/types/config.d.mts.map +1 -1
  238. package/dist/types/config.mjs +163 -1
  239. package/dist/types/config.mjs.map +1 -1
  240. package/dist/types/context.cjs +45 -1
  241. package/dist/types/context.cjs.map +1 -0
  242. package/dist/types/context.d.cts +3 -2
  243. package/dist/types/context.d.cts.map +1 -1
  244. package/dist/types/context.d.mts +3 -2
  245. package/dist/types/context.d.mts.map +1 -1
  246. package/dist/types/context.mjs +40 -1
  247. package/dist/types/context.mjs.map +1 -1
  248. package/dist/types/env.cjs +53 -1
  249. package/dist/types/env.cjs.map +1 -0
  250. package/dist/types/env.d.cts +1 -1
  251. package/dist/types/env.d.cts.map +1 -1
  252. package/dist/types/env.d.mts +1 -1
  253. package/dist/types/env.d.mts.map +1 -1
  254. package/dist/types/env.mjs +50 -1
  255. package/dist/types/env.mjs.map +1 -1
  256. package/dist/types/index.cjs +53 -1
  257. package/dist/types/index.d.cts +4 -4
  258. package/dist/types/index.d.mts +4 -4
  259. package/dist/types/index.mjs +6 -1
  260. package/dist/types/options.cjs +13 -1
  261. package/dist/types/options.cjs.map +1 -0
  262. package/dist/types/options.d.cts.map +1 -1
  263. package/dist/types/options.d.mts.map +1 -1
  264. package/dist/types/options.mjs +10 -1
  265. package/dist/types/options.mjs.map +1 -1
  266. package/package.json +43 -34
  267. package/dist/resolver/deepkit.cjs +0 -1
  268. package/dist/resolver/deepkit.mjs +0 -2
  269. package/dist/resolver/deepkit.mjs.map +0 -1
  270. package/dist/resolver/module.cjs +0 -1
  271. package/dist/resolver/module.mjs +0 -2
  272. package/dist/resolver/module.mjs.map +0 -1
@@ -1,8 +1,947 @@
1
- import{getDynamicPathSegmentName as e,isDynamicPathSegment as t}from"../plugin-utils/context-helpers.mjs";import{CommandParameterKinds as n}from"../types/command.mjs";import{computedOptions as r}from"../contexts/options.mjs";import{BooleanInputParserLogic as i,CommandParameterType as a}from"./helpers.mjs";import{createComponent as o,createIntrinsic as s,memo as c}from"@alloy-js/core/jsx-runtime";import{camelCase as l}from"@stryke/string-format/camel-case";import{constantCase as u}from"@stryke/string-format/constant-case";import{isSetString as d}from"@stryke/type-checks/is-set-string";import{For as f,Show as p,code as m,computed as h}from"@alloy-js/core";import{Spacing as g}from"@powerlines/plugin-alloy/core/components/spacing";import{ElseClause as _,ElseIfClause as v,IfStatement as y,InterfaceDeclaration as b,InterfaceMember as x,VarDeclaration as S}from"@alloy-js/typescript";import{pascalCase as C}from"@stryke/string-format/pascal-case";function w(e,t){return e.__type=t,e}const T=[`CommandTree`,`command`,`The command to generate the dynamic path segments parser logic for. This is used to access the command options and parameters when generating the parser logic for dynamic path segments.`,`isCaseSensitive`,`Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.`,`DynamicSegmentsParserLogicProps`,`P"w!4"?#)4$?%Mw&y`];function E(n){let{command:r}=n;return o(f,{get each(){return r.segments??[]},get children(){return w((n,r)=>o(p,{get when(){return t(n)},get children(){return[o(S,{let:!0,get name(){return l(e(n))},type:`string | undefined`}),s(`hbr`,{}),o(y,{condition:m`args.length > ${2+r} && args[${2+r}]`,get children(){return m`${l(e(n))} = args[${2+r}];`}}),s(`hbr`,{}),s(`hbr`,{})]}}),[`segment`,`index`,``,`P"2!"2""/#`])}})}E.__type=[()=>T,`props`,`DynamicSegmentsParserLogic`,`Pn!2""/#`];const D=[`CommandTree`,`command`,`The command to generate the positional parameters parser logic for.`,`appSpecificEnvPrefix`,"The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).",`isCaseSensitive`,`Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.`,`ArgumentsParserLogicProps`,`P"w!4"?#&4$?%)4&?'Mw(y`];function O(e){let{command:t,appSpecificEnvPrefix:r,isCaseSensitive:s}=e;return o(p,{get when(){return t.args&&t.args.length>0},get children(){return[o(S,{let:!0,name:`optionsIndex`,type:`number`,get initializer(){return m`Math.max(0, args.slice(${t.segments.length+1}).findIndex(arg => arg.startsWith("-") && /^(${Object.values(t.options??{}).map(w(e=>`${s||e.name.length===1?e.name:e.name.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``)}${e.alias&&e.alias.length>0?`|`:``}${e.alias?.map(w(t=>(s||e.name.length===1?t:t.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``))===`?`?`\\?`:s||e.name.length===1?t:t.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``),[`a`,``,`P"2!"/"`])).join(`|`)}`,[`option`,``,`P"2!"/"`])).join(`|`)})=?.*$/.test(arg${s?``:`.toLowerCase().replaceAll("-", "").replaceAll("_", "")`}))) + ${t.segments.length+1};`}}),o(g,{}),o(S,{let:!0,name:`argsIndex`,type:`number`,get initializer(){return m`optionsIndex > ${t.segments.length+1} ? ${t.segments.length+1} : (Math.max(0, args.slice(optionsIndex).findLastIndex(arg => arg.startsWith("-") && /^(${Object.values(t.options??{}).map(w(e=>`${s||e.name.length===1?e.name:e.name.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``)}${e.alias&&e.alias.length>0?`|`:``}${e.alias?.map(w(t=>(s||e.name.length===1?t:t.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``))===`?`?`\\?`:s||e.name.length===1?t:t.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``),[`a`,``,`P"2!"/"`])).join(`|`)}`,[`option`,``,`P"2!"/"`])).join(`|`)})=?.*$/.test(arg${s?``:`.toLowerCase().replaceAll("-", "").replaceAll("_", "")`}))) + ${t.segments.length+1});`}}),o(g,{}),o(f,{get each(){return t.args??[]},hardline:!0,get children(){return w((e,s)=>[o(p,{get when(){return d(e.env)||e.default!==void 0||e.variadic},get fallback(){return[c(()=>m`let ${l(e.name)}!: `),o(a,{parameter:e}),m`; `]},get children(){return o(S,{let:!0,get name(){return l(e.name)},get type(){return o(a,{parameter:e})},get initializer(){return[m` ( `,o(p,{get when(){return d(e.env)},get children(){return m`env.${r}_${u(String(e.env))} ?? `}}),o(p,{get when(){return e.default!==void 0&&(!e.variadic||e.default.length>0)},get fallback(){return o(p,{get when(){return e.variadic},fallback:m`undefined`,children:m`[]`})},get children(){return o(p,{get when(){return e.variadic},get fallback(){return e.kind===n.string?m`"${e.default}"`:m`${e.default}`},get children(){return m`[${e.default?.map(w(t=>e.kind===n.string?`"${t}"`:t,[`value`,``,`P"2!"/"`])).join(`, `)}]`}})}}),m`) as `,o(a,{parameter:e}),m`; `]}})}}),o(g,{}),o(y,{condition:m`argsIndex + ${s} < args.length && argsIndex + ${s} !== optionsIndex`,get children(){return[c(()=>m`${l(e.name)} = `),o(p,{get when(){return e.kind===n.string||e.kind===n.number},get fallback(){return o(i,{name:`args[argsIndex + ${s}] `})},get children(){return o(p,{get when(){return e.variadic},get fallback(){return o(p,{get when(){return e.kind===n.number},fallback:m`args[argsIndex + ${s}] `,children:m`Number(args[argsIndex + ${s}]) `})},get children(){return m`args.slice(argsIndex + ${s}, (optionsIndex > argsIndex ? optionsIndex : args.length) - ${t.args.length-s}).join(" ").split(",").map(item => item.trim().replace(/^("|')/, "").replace(/("|')$/, "")).filter(Boolean)`}})}}),m` as `,o(a,{parameter:e}),m`; `]}}),o(g,{})],[`arg`,`index`,``,`P"2!"2""/#`])}})]}})}O.__type=[()=>D,`props`,`ArgumentsParserLogic`,`Pn!2""/#`];function k({option:e}){let t=e.description||`The ${e.title} command option.`;return[o(p,{get when(){return!!e.name},get children(){return[o(p,{get when(){return e.kind===n.string},get children(){return o(x,{get name(){return e.name},doc:t,get type(){return o(a,{parameter:e})},get optional(){return e.optional}})}}),o(p,{get when(){return e.kind===n.number},get children(){return o(x,{get name(){return e.name},doc:t,get type(){return o(a,{parameter:e})},get optional(){return e.optional}})}}),o(p,{get when(){return e.kind===n.boolean},get children(){return o(x,{get name(){return e.name},doc:t,get type(){return o(a,{parameter:e})},get optional(){return e.optional}})}})]}})]}k.__type=[`CommandOption`,`option`,`param0`,`OptionsMember`,`The command option interface property.`,`PP"w!4"M2#"/$?%`];const A=[`name`,`The option name to generate the parser logic for.`,`CommandOption`,`option`,`The command option to generate the parser logic for.`,`isCaseSensitive`,!0,`Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.`,`OptionsMemberParserLogicProps`,`P&4!?""w#4$?%)4&>'?(Mw)y`];function j(e){let{name:t,option:r,isCaseSensitive:a}=e,c=`/^--?(${a||t.length===1?t:t.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``)}${r.alias&&r.alias.length>0?`|`:``}${r.alias?.map(w(e=>(a||t.length===1?e:e.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``))===`?`?`\\?`:a||t.length===1?e:e.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``),[`a`,``,`P"2!"/"`])).join(`|`)})=/`;return[o(p,{get when(){return r.kind===n.string||r.kind===n.number},get children(){return[o(p,{get when(){return r.variadic},get children(){return[o(p,{get when(){return t.includes(`?`)||t.includes(`-`)},fallback:m`options.${t} ??= []; `,children:m`options["${t}"] ??= []; `}),s(`hbr`,{}),o(y,{condition:`${c}.test(${a?`arg`:`"-" + arg.toLowerCase().replaceAll("-", "").replaceAll("_", "")`})`,get children(){return[o(p,{get when(){return t.includes(`?`)||t.includes(`-`)},fallback:m`options.${t}.push(`,children:m`options["${t}"].push(`}),o(p,{get when(){return r.kind===n.string},children:m`...arg.replace(${c}, "").split(",").map(item => item.trim().replace(/^("|')/, "").replace(/("|')$/, "")).filter(Boolean) `}),o(p,{get when(){return r.kind===n.number},children:m`...arg.replace(${c}, "").split(",").map(item => item.trim().replace(/^("|')/, "").replace(/("|')$/, "")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `}),o(p,{get when(){return(r.kind===n.string||r.kind===n.number)&&r.choices&&r.choices.length>0},get children(){return m` as ${r.choices?.map(w(e=>d(e)?`"${e}"`:e,[`choice`,``,`P"2!"/"`])).join(` | `)} `}}),m`); `]}}),o(v,{condition:`args.length > i + 1`,get children(){return[o(p,{get when(){return t.includes(`?`)||t.includes(`-`)},fallback:m`options.${t}.push(`,children:m`options["${t}"].push(`}),o(p,{get when(){return r.kind===n.string},children:m`...args[++i].split(",").map(item => item.trim().replace(/^("|')/, "").replace(/("|')$/, "")).filter(Boolean) `}),o(p,{get when(){return r.kind===n.number},children:m`...args[++i].split(",").map(item => item.trim().replace(/^("|')/, "").replace(/("|')$/, "")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `}),o(p,{get when(){return(r.kind===n.string||r.kind===n.number)&&r.choices&&r.choices.length>0},get children(){return m` as ${r.choices?.map(w(e=>d(e)?`"${e}"`:e,[`choice`,``,`P"2!"/"`])).join(` | `)} `}}),m`); `]}})]}}),o(p,{get when(){return!r.variadic},get children(){return[o(y,{condition:`${c}.test(${a?`arg`:`"-" + arg.toLowerCase().replaceAll("-", "").replaceAll("_", "")`})`,get children(){return[o(p,{get when(){return r.kind===n.string},get children(){return[o(p,{get when(){return t.includes(`?`)||t.includes(`-`)},fallback:m`options.${t}`,children:m`options["${t}"]`}),m` = arg.replace(${c}, "").trim().replace(/^("|')/, "").replace(/("|')$/, "")`,o(p,{get when(){return r.choices&&r.choices.length>0},get children(){return m` as ${r.choices?.map(w(e=>`"${e}"`,[`choice`,``,`P"2!"/"`])).join(` | `)}`}}),m`; `]}}),o(p,{get when(){return r.kind===n.number},get children(){return[o(S,{const:!0,name:`value`,initializer:m` Number(arg.replace(${c}, "").trim().replace(/^("|')/, "").replace(/("|')$/, "")); `}),s(`hbr`,{}),o(y,{condition:`!Number.isNaN(value)`,get children(){return[o(p,{get when(){return t.includes(`?`)||t.includes(`-`)},fallback:m`options.${t}`,children:m`options["${t}"]`}),m` = value`,o(p,{get when(){return r.choices&&r.choices.length>0},get children(){return m` as ${r.choices?.join(` | `)}`}}),m`; `]}})]}})]}}),o(v,{condition:`args.length > i + 1`,get children(){return[o(p,{get when(){return r.kind===n.string},get children(){return[o(p,{get when(){return t.includes(`?`)||t.includes(`-`)},fallback:m`options.${t}`,children:m`options["${t}"]`}),m` = args[++i].trim().replace(/^("|')/, "").replace(/("|')$/, "")`,o(p,{get when(){return r.choices&&r.choices.length>0},get children(){return m` as ${r.choices?.map(w(e=>`"${e}"`,[`choice`,``,`P"2!"/"`])).join(` | `)}`}}),m`; `]}}),o(p,{get when(){return r.kind===n.number},get children(){return[o(S,{const:!0,name:`value`,initializer:m` Number(args[++i].trim().replace(/^("|')/, "").replace(/("|')$/, "")); `}),s(`hbr`,{}),o(y,{condition:`!Number.isNaN(value)`,get children(){return[o(p,{get when(){return t.includes(`?`)||t.includes(`-`)},fallback:m`options.${t}`,children:m`options["${t}"]`}),m` = value`,o(p,{get when(){return r.choices&&r.choices.length>0},get children(){return m` as ${r.choices?.join(` | `)}`}}),m`; `]}})]}})]}}),s(`hbr`,{})]}})]}}),o(p,{get when(){return r.kind===n.boolean},get children(){return[o(y,{condition:`${c}.test(${a?`arg`:`"-" + arg.toLowerCase().replaceAll("-", "").replaceAll("_", "")`})`,get children(){return[o(S,{const:!0,name:`value`,initializer:m` arg.replace(${c}, "").trim().replace(/^("|')/, "").replace(/("|')$/, "").toLowerCase(); `}),s(`hbr`,{}),o(p,{get when(){return t.includes(`?`)||t.includes(`-`)},fallback:m`options.${t} = `,children:m`options["${t}"] = `}),o(i,{name:`value`})]}}),o(_,{get children(){return o(p,{get when(){return t.includes(`?`)||t.includes(`-`)},fallback:m`options.${t} = true; `,children:m`options["${t}"] = true; `})}}),o(p,{get when(){return!!r.isNegativeOf},get children(){return[s(`hbr`,{}),o(p,{get when(){return r.isNegativeOf.includes(`?`)||r.isNegativeOf.includes(`-`)},get fallback(){return m`options.${r.isNegativeOf} = false; `},get children(){return m`options["${r.isNegativeOf}"] = false; `}})]}})]}})]}j.__type=[()=>A,`props`,`OptionsMemberParserLogic`,`The command option property parser logic.`,`Pn!2""/#?$`];const M=[`name`,`The option name to generate the parser logic for.`,`alias`,`Aliases for the option, which will also be parsed in the generated code. This will affect how the generated code compares command-line arguments to option names and aliases.`,`isCaseSensitive`,!0,`Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.`,`OptionsMemberParserConditionProps`,`P&4!?"&F4#8?$)4%>&?'Mw(y`];function N(e){let{name:t,alias:n,isCaseSensitive:r}=e;return[c(()=>m`${r?`arg.startsWith("--`:`arg.toLowerCase().replaceAll("-", "").replaceAll("_", "").startsWith("`}${r?t:t.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``)}=") || ${r?`arg`:`arg.toLowerCase().replaceAll("-", "").replaceAll("_", "")`} === "${r?t:t.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``)}" || ${r?`arg.startsWith("-`:`arg.toLowerCase().replaceAll("-", "").replaceAll("_", "").startsWith("`}${r?t:t.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``)}=") || ${r?`arg`:`arg.toLowerCase().replaceAll("-", "").replaceAll("_", "")`} === "${r?t:t.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``)}"`),o(p,{get when(){return n&&n.length>0},get children(){return o(f,{each:n??[],get children(){return w(e=>m` || ${r||e.length===1?`arg.startsWith("--`:`arg.toLowerCase().replaceAll("-", "").replaceAll("_", "").startsWith("`}${r||e.length===1?e:e.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``)}=") || ${r||e.length===1?`arg`:`arg.toLowerCase().replaceAll("-", "").replaceAll("_", "")`} === "${r||e.length===1?e:e.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``)}" || ${r||e.length===1?`arg.startsWith("-`:`arg.toLowerCase().replaceAll("-", "").replaceAll("_", "").startsWith("`}${r||e.length===1?e:e.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``)}=") || ${r||e.length===1?`arg`:`arg.toLowerCase().replaceAll("-", "").replaceAll("_", "")`} === "${r||e.length===1?e:e.toLowerCase().replaceAll(`-`,``).replaceAll(`_`,``)}"`,[`alias`,``,`P"2!"/"`])}})}})]}N.__type=[()=>M,`props`,`OptionsMemberParserCondition`,`Pn!2""/#`];function P(e){let{command:t}=e,n=h(()=>r(Object.entries(t.options).map(w(([e,t])=>({...t,name:e}),[`param0`,``,`P"2!"/"`]))));return o(b,{export:!0,get name(){return`${C(t.name)}Options`},extends:`GlobalOptions`,get children(){return o(f,{get each(){return Object.values(n.value)},hardline:!0,get children(){return w(e=>o(k,{option:e}),[`option`,``,`P"2!"/"`])}})}})}P.__type=[`CommandTree`,`command`,`props`,`OptionsInterfaceDeclaration`,`PP"w!4"M2#"/$`];const F=[`appSpecificEnvPrefix`,"The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).",`isCaseSensitive`,!0,`Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.`,`OptionsParserLogicProps`,`P!&4!?")4#8>$?%Mw&y`];function I(e){let{segments:i=[],options:a,name:l,appSpecificEnvPrefix:u,isCaseSensitive:d=!1}=e,_=h(()=>r(Object.entries(a).map(w(([e,t])=>({...t,name:e}),[`param0`,``,`P"2!"/"`]))));return[o(S,{const:!0,name:`options`,get initializer(){return m` {
2
- ${i.length>0?`...useGlobalOptions(), `:``}${Object.entries(_.value).filter(w(([,e])=>e.env||e.default!==void 0||(e.kind===n.string||e.kind===n.number)&&e.variadic,[`param0`,``,`P"2!"/"`])).map(w(([e,t])=>t.kind===n.string?` ${e.includes(`?`)||e.includes(`-`)?`"${e}"`:`${e}`}: ${t.env?`env.${u}_${t.env}`:``}${t.variadic?t.default===void 0?t.env?` ?? []`:`[]`:`${t.env?` ?? `:``}${JSON.stringify(t.default)}`:t.default===void 0?``:`${t.env?` ?? `:``}"${t.default}"`}, `:t.kind===n.number?` ${e.includes(`?`)||e.includes(`-`)?`"${e}"`:`${e}`}: ${t.env?`env.${u}_${t.env}`:``}${t.variadic?t.default&&Array.isArray(t.default)?`${t.env?` ?? `:``}${JSON.stringify(t.default)}`:t.env?` ?? []`:`[]`:t.default===void 0?``:`${t.env?` ?? `:``}${t.default}`}, `:t.kind===n.boolean?` ${e.includes(`?`)||e.includes(`-`)?`"${e}"`:`${e}`}: ${t.env?`env.${u}_${t.env} ?? `:``}${t.default?`true`:`false`},`:``,[`param0`,``,`P"2!"/"`])).join(``)}
3
- } as unknown as ${i.length>0?C(l):`Global`}Options;`}}),o(g,{}),c(()=>m`for (let i = 0; i < args.slice(${i.filter(w(e=>t(e),[`segment`,``,`P"2!"/"`])).length}).length; i++) { `),s(`hbr`,{}),o(S,{const:!0,name:`arg`,type:`string`,initializer:m` args[i].length > 3 && args[i].startsWith("--")
4
- ? \`--\${args[i].slice(2).replaceAll("-", "")${d?``:`.toLowerCase().replaceAll("-", "").replaceAll("_", "")`}}\`
1
+ import { getDynamicPathSegmentName, isDynamicPathSegment } from "../plugin-utils/context-helpers.mjs";
2
+ import { computedOptions } from "../contexts/options.mjs";
3
+ import { BooleanInputParserLogic, CommandParameterType } from "./helpers.mjs";
4
+ import { createComponent, createIntrinsic, memo } from "@alloy-js/core/jsx-runtime";
5
+ import { For, Show, code, computed } from "@alloy-js/core";
6
+ import { camelCase } from "@stryke/string-format/camel-case";
7
+ import { constantCase } from "@stryke/string-format/constant-case";
8
+ import { isSetString } from "@stryke/type-checks/is-set-string";
9
+ import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
10
+ import { ElseClause, ElseIfClause, IfStatement, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
11
+ import { pascalCase } from "@stryke/string-format/pascal-case";
12
+
13
+ //#region src/components/options-parser-logic.tsx
14
+ function __assignType(fn, args) {
15
+ fn.__type = args;
16
+ return fn;
17
+ }
18
+ const __ΩDynamicSegmentsParserLogicProps = [
19
+ "CommandTree",
20
+ "command",
21
+ "The command to generate the dynamic path segments parser logic for. This is used to access the command options and parameters when generating the parser logic for dynamic path segments.",
22
+ "isCaseSensitive",
23
+ "Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.",
24
+ "DynamicSegmentsParserLogicProps",
25
+ "P\"w!4\"?#)4$?%Mw&y"
26
+ ];
27
+ function DynamicSegmentsParserLogic(props) {
28
+ const { command } = props;
29
+ return createComponent(For, {
30
+ get each() {
31
+ return command.segments ?? [];
32
+ },
33
+ get children() {
34
+ return __assignType((segment, index) => createComponent(Show, {
35
+ get when() {
36
+ return isDynamicPathSegment(segment);
37
+ },
38
+ get children() {
39
+ return [
40
+ createComponent(VarDeclaration, {
41
+ "let": true,
42
+ get name() {
43
+ return camelCase(getDynamicPathSegmentName(segment));
44
+ },
45
+ type: "string | undefined"
46
+ }),
47
+ createIntrinsic("hbr", {}),
48
+ createComponent(IfStatement, {
49
+ condition: code`args.length > ${2 + index} && args[${2 + index}]`,
50
+ get children() {
51
+ return code`${camelCase(getDynamicPathSegmentName(segment))} = args[${2 + index}];`;
52
+ }
53
+ }),
54
+ createIntrinsic("hbr", {}),
55
+ createIntrinsic("hbr", {})
56
+ ];
57
+ }
58
+ }), [
59
+ "segment",
60
+ "index",
61
+ "",
62
+ "P\"2!\"2\"\"/#"
63
+ ]);
64
+ }
65
+ });
66
+ }
67
+ DynamicSegmentsParserLogic.__type = [
68
+ () => __ΩDynamicSegmentsParserLogicProps,
69
+ "props",
70
+ "DynamicSegmentsParserLogic",
71
+ "Pn!2\"\"/#"
72
+ ];
73
+ const __ΩArgumentsParserLogicProps = [
74
+ "CommandTree",
75
+ "command",
76
+ "The command to generate the positional parameters parser logic for.",
77
+ "appSpecificEnvPrefix",
78
+ "The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).",
79
+ "isCaseSensitive",
80
+ "Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.",
81
+ "ArgumentsParserLogicProps",
82
+ "P\"w!4\"?#&4$?%)4&?'Mw(y"
83
+ ];
84
+ function ArgumentsParserLogic(props) {
85
+ const { command, appSpecificEnvPrefix, isCaseSensitive } = props;
86
+ return createComponent(Show, {
87
+ get when() {
88
+ return command.args && command.args.length > 0;
89
+ },
90
+ get children() {
91
+ return [
92
+ createComponent(VarDeclaration, {
93
+ "let": true,
94
+ name: "optionsIndex",
95
+ type: "number",
96
+ get initializer() {
97
+ return code`Math.max(0, args.slice(${command.segments.length + 1}).findIndex(arg => arg.startsWith("-") && /^(${Object.values(command.options ?? {}).map(__assignType((option) => `${isCaseSensitive || option.name.length === 1 ? option.name : option.name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}${option.alias && option.alias.length > 0 ? "|" : ""}${option.alias?.map(__assignType((a) => (isCaseSensitive || option.name.length === 1 ? a : a.toLowerCase().replaceAll("-", "").replaceAll("_", "")) === "?" ? "\\?" : isCaseSensitive || option.name.length === 1 ? a : a.toLowerCase().replaceAll("-", "").replaceAll("_", ""), [
98
+ "a",
99
+ "",
100
+ "P\"2!\"/\""
101
+ ])).join("|")}`, [
102
+ "option",
103
+ "",
104
+ "P\"2!\"/\""
105
+ ])).join("|")})=?.*$/.test(arg${isCaseSensitive ? "" : ".toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"}))) + ${command.segments.length + 1};`;
106
+ }
107
+ }),
108
+ createComponent(Spacing, {}),
109
+ createComponent(VarDeclaration, {
110
+ "let": true,
111
+ name: "argsIndex",
112
+ type: "number",
113
+ get initializer() {
114
+ return code`optionsIndex > ${command.segments.length + 1} ? ${command.segments.length + 1} : (Math.max(0, args.slice(optionsIndex).findLastIndex(arg => arg.startsWith("-") && /^(${Object.values(command.options ?? {}).map(__assignType((option) => `${isCaseSensitive || option.name.length === 1 ? option.name : option.name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}${option.alias && option.alias.length > 0 ? "|" : ""}${option.alias?.map(__assignType((a) => (isCaseSensitive || option.name.length === 1 ? a : a.toLowerCase().replaceAll("-", "").replaceAll("_", "")) === "?" ? "\\?" : isCaseSensitive || option.name.length === 1 ? a : a.toLowerCase().replaceAll("-", "").replaceAll("_", ""), [
115
+ "a",
116
+ "",
117
+ "P\"2!\"/\""
118
+ ])).join("|")}`, [
119
+ "option",
120
+ "",
121
+ "P\"2!\"/\""
122
+ ])).join("|")})=?.*$/.test(arg${isCaseSensitive ? "" : ".toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"}))) + ${command.segments.length + 1});`;
123
+ }
124
+ }),
125
+ createComponent(Spacing, {}),
126
+ createComponent(For, {
127
+ get each() {
128
+ return command.args ?? [];
129
+ },
130
+ hardline: true,
131
+ get children() {
132
+ return __assignType((arg, index) => [
133
+ createComponent(Show, {
134
+ get when() {
135
+ return isSetString(arg.env) || arg.default !== void 0 || arg.variadic;
136
+ },
137
+ get fallback() {
138
+ return [
139
+ memo(() => code`let ${camelCase(arg.name)}!: `),
140
+ createComponent(CommandParameterType, { parameter: arg }),
141
+ code`; `
142
+ ];
143
+ },
144
+ get children() {
145
+ return createComponent(VarDeclaration, {
146
+ "let": true,
147
+ get name() {
148
+ return camelCase(arg.name);
149
+ },
150
+ get type() {
151
+ return createComponent(CommandParameterType, { parameter: arg });
152
+ },
153
+ get initializer() {
154
+ return [
155
+ code` ( `,
156
+ createComponent(Show, {
157
+ get when() {
158
+ return isSetString(arg.env);
159
+ },
160
+ get children() {
161
+ return code`env.${appSpecificEnvPrefix}_${constantCase(String(arg.env))} ?? `;
162
+ }
163
+ }),
164
+ createComponent(Show, {
165
+ get when() {
166
+ return arg.default !== void 0 && (!arg.variadic || arg.default.length > 0);
167
+ },
168
+ get fallback() {
169
+ return createComponent(Show, {
170
+ get when() {
171
+ return arg.variadic;
172
+ },
173
+ fallback: code`undefined`,
174
+ children: code`[]`
175
+ });
176
+ },
177
+ get children() {
178
+ return createComponent(Show, {
179
+ get when() {
180
+ return arg.variadic;
181
+ },
182
+ get fallback() {
183
+ return arg.type === "string" ? code`"${arg.default}"` : code`${arg.default}`;
184
+ },
185
+ get children() {
186
+ return code`[${arg.default?.map(__assignType((value) => arg.type === "string" ? `"${value}"` : value, [
187
+ "value",
188
+ "",
189
+ "P\"2!\"/\""
190
+ ])).join(", ")}]`;
191
+ }
192
+ });
193
+ }
194
+ }),
195
+ code`) as `,
196
+ createComponent(CommandParameterType, { parameter: arg }),
197
+ code`; `
198
+ ];
199
+ }
200
+ });
201
+ }
202
+ }),
203
+ createComponent(Spacing, {}),
204
+ createComponent(IfStatement, {
205
+ condition: code`argsIndex + ${index} < args.length && argsIndex + ${index} !== optionsIndex`,
206
+ get children() {
207
+ return [
208
+ memo(() => code`${camelCase(arg.name)} = `),
209
+ createComponent(Show, {
210
+ get when() {
211
+ return arg.type === "string" || arg.type === "number";
212
+ },
213
+ get fallback() {
214
+ return createComponent(BooleanInputParserLogic, { name: `args[argsIndex + ${index}] ` });
215
+ },
216
+ get children() {
217
+ return createComponent(Show, {
218
+ get when() {
219
+ return arg.variadic;
220
+ },
221
+ get fallback() {
222
+ return createComponent(Show, {
223
+ get when() {
224
+ return arg.type === "number";
225
+ },
226
+ fallback: code`args[argsIndex + ${index}] `,
227
+ children: code`Number(args[argsIndex + ${index}]) `
228
+ });
229
+ },
230
+ get children() {
231
+ return code`args.slice(argsIndex + ${index}, (optionsIndex > argsIndex ? optionsIndex : args.length) - ${command.args.length - index}).join(" ").split(",").map(item => item.trim().replace(/^("|')/, "").replace(/("|')$/, "")).filter(Boolean)`;
232
+ }
233
+ });
234
+ }
235
+ }),
236
+ code` as `,
237
+ createComponent(CommandParameterType, { parameter: arg }),
238
+ code`; `
239
+ ];
240
+ }
241
+ }),
242
+ createComponent(Spacing, {})
243
+ ], [
244
+ "arg",
245
+ "index",
246
+ "",
247
+ "P\"2!\"2\"\"/#"
248
+ ]);
249
+ }
250
+ })
251
+ ];
252
+ }
253
+ });
254
+ }
255
+ ArgumentsParserLogic.__type = [
256
+ () => __ΩArgumentsParserLogicProps,
257
+ "props",
258
+ "ArgumentsParserLogic",
259
+ "Pn!2\"\"/#"
260
+ ];
261
+ /**
262
+ * The command option interface property.
263
+ */
264
+ function OptionsMember({ option }) {
265
+ const doc = option.description || `The ${option.title} command option.`;
266
+ return [createComponent(Show, {
267
+ get when() {
268
+ return Boolean(option.name);
269
+ },
270
+ get children() {
271
+ return [
272
+ createComponent(Show, {
273
+ get when() {
274
+ return option.type === "string";
275
+ },
276
+ get children() {
277
+ return createComponent(InterfaceMember, {
278
+ get name() {
279
+ return option.name;
280
+ },
281
+ doc,
282
+ get type() {
283
+ return createComponent(CommandParameterType, { parameter: option });
284
+ },
285
+ get optional() {
286
+ return !option.required;
287
+ }
288
+ });
289
+ }
290
+ }),
291
+ createComponent(Show, {
292
+ get when() {
293
+ return option.type === "number";
294
+ },
295
+ get children() {
296
+ return createComponent(InterfaceMember, {
297
+ get name() {
298
+ return option.name;
299
+ },
300
+ doc,
301
+ get type() {
302
+ return createComponent(CommandParameterType, { parameter: option });
303
+ },
304
+ get optional() {
305
+ return !option.required;
306
+ }
307
+ });
308
+ }
309
+ }),
310
+ createComponent(Show, {
311
+ get when() {
312
+ return option.type === "boolean";
313
+ },
314
+ get children() {
315
+ return createComponent(InterfaceMember, {
316
+ get name() {
317
+ return option.name;
318
+ },
319
+ doc,
320
+ get type() {
321
+ return createComponent(CommandParameterType, { parameter: option });
322
+ },
323
+ get optional() {
324
+ return !option.required;
325
+ }
326
+ });
327
+ }
328
+ })
329
+ ];
330
+ }
331
+ })];
332
+ }
333
+ OptionsMember.__type = [
334
+ "CommandOption",
335
+ "option",
336
+ "param0",
337
+ "OptionsMember",
338
+ "The command option interface property.",
339
+ "PP\"w!4\"M2#\"/$?%"
340
+ ];
341
+ const __ΩOptionsMemberParserLogicProps = [
342
+ "name",
343
+ "The option name to generate the parser logic for.",
344
+ "CommandOption",
345
+ "option",
346
+ "The command option to generate the parser logic for.",
347
+ "isCaseSensitive",
348
+ true,
349
+ "Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.",
350
+ "OptionsMemberParserLogicProps",
351
+ "P&4!?\"\"w#4$?%)4&>'?(Mw)y"
352
+ ];
353
+ /**
354
+ * The command option property parser logic.
355
+ */
356
+ function OptionsMemberParserLogic(props) {
357
+ const { name, option, isCaseSensitive } = props;
358
+ const equalsRegex = `/^--?(${isCaseSensitive || name.length === 1 ? name : name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}${option.alias && option.alias.length > 0 ? "|" : ""}${option.alias?.map(__assignType((a) => (isCaseSensitive || name.length === 1 ? a : a.toLowerCase().replaceAll("-", "").replaceAll("_", "")) === "?" ? "\\?" : isCaseSensitive || name.length === 1 ? a : a.toLowerCase().replaceAll("-", "").replaceAll("_", ""), [
359
+ "a",
360
+ "",
361
+ "P\"2!\"/\""
362
+ ])).join("|")})=/`;
363
+ return [createComponent(Show, {
364
+ get when() {
365
+ return option.type === "string" || option.type === "number";
366
+ },
367
+ get children() {
368
+ return [createComponent(Show, {
369
+ get when() {
370
+ return option.variadic;
371
+ },
372
+ get children() {
373
+ return [
374
+ createComponent(Show, {
375
+ get when() {
376
+ return name.includes("?") || name.includes("-");
377
+ },
378
+ fallback: code`options.${name} ??= []; `,
379
+ children: code`options["${name}"] ??= []; `
380
+ }),
381
+ createIntrinsic("hbr", {}),
382
+ createComponent(IfStatement, {
383
+ condition: `${equalsRegex}.test(${isCaseSensitive ? "arg" : "\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"})`,
384
+ get children() {
385
+ return [
386
+ createComponent(Show, {
387
+ get when() {
388
+ return name.includes("?") || name.includes("-");
389
+ },
390
+ fallback: code`options.${name}.push(`,
391
+ children: code`options["${name}"].push(`
392
+ }),
393
+ createComponent(Show, {
394
+ get when() {
395
+ return option.type === "string";
396
+ },
397
+ children: code`...arg.replace(${equalsRegex}, "").split(",").map(item => item.trim().replace(/^("|')/, "").replace(/("|')$/, "")).filter(Boolean) `
398
+ }),
399
+ createComponent(Show, {
400
+ get when() {
401
+ return option.type === "number";
402
+ },
403
+ children: code`...arg.replace(${equalsRegex}, "").split(",").map(item => item.trim().replace(/^("|')/, "").replace(/("|')$/, "")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `
404
+ }),
405
+ createComponent(Show, {
406
+ get when() {
407
+ return (option.type === "string" || option.type === "number") && option.choices && option.choices.length > 0;
408
+ },
409
+ get children() {
410
+ return code` as ${option.choices?.map(__assignType((choice) => isSetString(choice) ? `"${choice}"` : choice, [
411
+ "choice",
412
+ "",
413
+ "P\"2!\"/\""
414
+ ])).join(" | ")} `;
415
+ }
416
+ }),
417
+ code`); `
418
+ ];
419
+ }
420
+ }),
421
+ createComponent(ElseIfClause, {
422
+ condition: `args.length > i + 1`,
423
+ get children() {
424
+ return [
425
+ createComponent(Show, {
426
+ get when() {
427
+ return name.includes("?") || name.includes("-");
428
+ },
429
+ fallback: code`options.${name}.push(`,
430
+ children: code`options["${name}"].push(`
431
+ }),
432
+ createComponent(Show, {
433
+ get when() {
434
+ return option.type === "string";
435
+ },
436
+ children: code`...args[++i].split(",").map(item => item.trim().replace(/^("|')/, "").replace(/("|')$/, "")).filter(Boolean) `
437
+ }),
438
+ createComponent(Show, {
439
+ get when() {
440
+ return option.type === "number";
441
+ },
442
+ children: code`...args[++i].split(",").map(item => item.trim().replace(/^("|')/, "").replace(/("|')$/, "")).filter(Boolean).map(Number).filter(value => !Number.isNaN(value)) `
443
+ }),
444
+ createComponent(Show, {
445
+ get when() {
446
+ return (option.type === "string" || option.type === "number") && option.choices && option.choices.length > 0;
447
+ },
448
+ get children() {
449
+ return code` as ${option.choices?.map(__assignType((choice) => isSetString(choice) ? `"${choice}"` : choice, [
450
+ "choice",
451
+ "",
452
+ "P\"2!\"/\""
453
+ ])).join(" | ")} `;
454
+ }
455
+ }),
456
+ code`); `
457
+ ];
458
+ }
459
+ })
460
+ ];
461
+ }
462
+ }), createComponent(Show, {
463
+ get when() {
464
+ return !option.variadic;
465
+ },
466
+ get children() {
467
+ return [
468
+ createComponent(IfStatement, {
469
+ condition: `${equalsRegex}.test(${isCaseSensitive ? "arg" : "\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"})`,
470
+ get children() {
471
+ return [createComponent(Show, {
472
+ get when() {
473
+ return option.type === "string";
474
+ },
475
+ get children() {
476
+ return [
477
+ createComponent(Show, {
478
+ get when() {
479
+ return name.includes("?") || name.includes("-");
480
+ },
481
+ fallback: code`options.${name}`,
482
+ children: code`options["${name}"]`
483
+ }),
484
+ code` = arg.replace(${equalsRegex}, "").trim().replace(/^("|')/, "").replace(/("|')$/, "")`,
485
+ createComponent(Show, {
486
+ get when() {
487
+ return option.choices && option.choices.length > 0;
488
+ },
489
+ get children() {
490
+ return code` as ${option.choices?.map(__assignType((choice) => `"${choice}"`, [
491
+ "choice",
492
+ "",
493
+ "P\"2!\"/\""
494
+ ])).join(" | ")}`;
495
+ }
496
+ }),
497
+ code`; `
498
+ ];
499
+ }
500
+ }), createComponent(Show, {
501
+ get when() {
502
+ return option.type === "number";
503
+ },
504
+ get children() {
505
+ return [
506
+ createComponent(VarDeclaration, {
507
+ "const": true,
508
+ name: "value",
509
+ initializer: code` Number(arg.replace(${equalsRegex}, "").trim().replace(/^("|')/, "").replace(/("|')$/, "")); `
510
+ }),
511
+ createIntrinsic("hbr", {}),
512
+ createComponent(IfStatement, {
513
+ condition: `!Number.isNaN(value)`,
514
+ get children() {
515
+ return [
516
+ createComponent(Show, {
517
+ get when() {
518
+ return name.includes("?") || name.includes("-");
519
+ },
520
+ fallback: code`options.${name}`,
521
+ children: code`options["${name}"]`
522
+ }),
523
+ code` = value`,
524
+ createComponent(Show, {
525
+ get when() {
526
+ return option.choices && option.choices.length > 0;
527
+ },
528
+ get children() {
529
+ return code` as ${option.choices?.join(" | ")}`;
530
+ }
531
+ }),
532
+ code`; `
533
+ ];
534
+ }
535
+ })
536
+ ];
537
+ }
538
+ })];
539
+ }
540
+ }),
541
+ createComponent(ElseIfClause, {
542
+ condition: `args.length > i + 1`,
543
+ get children() {
544
+ return [createComponent(Show, {
545
+ get when() {
546
+ return option.type === "string";
547
+ },
548
+ get children() {
549
+ return [
550
+ createComponent(Show, {
551
+ get when() {
552
+ return name.includes("?") || name.includes("-");
553
+ },
554
+ fallback: code`options.${name}`,
555
+ children: code`options["${name}"]`
556
+ }),
557
+ code` = args[++i].trim().replace(/^("|')/, "").replace(/("|')$/, "")`,
558
+ createComponent(Show, {
559
+ get when() {
560
+ return option.choices && option.choices.length > 0;
561
+ },
562
+ get children() {
563
+ return code` as ${option.choices?.map(__assignType((choice) => `"${choice}"`, [
564
+ "choice",
565
+ "",
566
+ "P\"2!\"/\""
567
+ ])).join(" | ")}`;
568
+ }
569
+ }),
570
+ code`; `
571
+ ];
572
+ }
573
+ }), createComponent(Show, {
574
+ get when() {
575
+ return option.type === "number";
576
+ },
577
+ get children() {
578
+ return [
579
+ createComponent(VarDeclaration, {
580
+ "const": true,
581
+ name: "value",
582
+ initializer: code` Number(args[++i].trim().replace(/^("|')/, "").replace(/("|')$/, "")); `
583
+ }),
584
+ createIntrinsic("hbr", {}),
585
+ createComponent(IfStatement, {
586
+ condition: `!Number.isNaN(value)`,
587
+ get children() {
588
+ return [
589
+ createComponent(Show, {
590
+ get when() {
591
+ return name.includes("?") || name.includes("-");
592
+ },
593
+ fallback: code`options.${name}`,
594
+ children: code`options["${name}"]`
595
+ }),
596
+ code` = value`,
597
+ createComponent(Show, {
598
+ get when() {
599
+ return option.choices && option.choices.length > 0;
600
+ },
601
+ get children() {
602
+ return code` as ${option.choices?.join(" | ")}`;
603
+ }
604
+ }),
605
+ code`; `
606
+ ];
607
+ }
608
+ })
609
+ ];
610
+ }
611
+ })];
612
+ }
613
+ }),
614
+ createIntrinsic("hbr", {})
615
+ ];
616
+ }
617
+ })];
618
+ }
619
+ }), createComponent(Show, {
620
+ get when() {
621
+ return option.type === "boolean";
622
+ },
623
+ get children() {
624
+ return [
625
+ createComponent(IfStatement, {
626
+ condition: `${equalsRegex}.test(${isCaseSensitive ? "arg" : "\"-\" + arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"})`,
627
+ get children() {
628
+ return [
629
+ createComponent(VarDeclaration, {
630
+ "const": true,
631
+ name: "value",
632
+ initializer: code` arg.replace(${equalsRegex}, "").trim().replace(/^("|')/, "").replace(/("|')$/, "").toLowerCase(); `
633
+ }),
634
+ createIntrinsic("hbr", {}),
635
+ createComponent(Show, {
636
+ get when() {
637
+ return name.includes("?") || name.includes("-");
638
+ },
639
+ fallback: code`options.${name} = `,
640
+ children: code`options["${name}"] = `
641
+ }),
642
+ createComponent(BooleanInputParserLogic, { name: "value" })
643
+ ];
644
+ }
645
+ }),
646
+ createComponent(ElseClause, { get children() {
647
+ return createComponent(Show, {
648
+ get when() {
649
+ return name.includes("?") || name.includes("-");
650
+ },
651
+ fallback: code`options.${name} = true; `,
652
+ children: code`options["${name}"] = true; `
653
+ });
654
+ } }),
655
+ createComponent(Show, {
656
+ get when() {
657
+ return Boolean(option.isNegativeOf);
658
+ },
659
+ get children() {
660
+ return [createIntrinsic("hbr", {}), createComponent(Show, {
661
+ get when() {
662
+ return option.isNegativeOf.includes("?") || option.isNegativeOf.includes("-");
663
+ },
664
+ get fallback() {
665
+ return code`options.${option.isNegativeOf} = false; `;
666
+ },
667
+ get children() {
668
+ return code`options["${option.isNegativeOf}"] = false; `;
669
+ }
670
+ })];
671
+ }
672
+ })
673
+ ];
674
+ }
675
+ })];
676
+ }
677
+ OptionsMemberParserLogic.__type = [
678
+ () => __ΩOptionsMemberParserLogicProps,
679
+ "props",
680
+ "OptionsMemberParserLogic",
681
+ "The command option property parser logic.",
682
+ "Pn!2\"\"/#?$"
683
+ ];
684
+ const __ΩOptionsMemberParserConditionProps = [
685
+ "name",
686
+ "The option name to generate the parser logic for.",
687
+ "alias",
688
+ "Aliases for the option, which will also be parsed in the generated code. This will affect how the generated code compares command-line arguments to option names and aliases.",
689
+ "isCaseSensitive",
690
+ true,
691
+ "Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.",
692
+ "OptionsMemberParserConditionProps",
693
+ "P&4!?\"&F4#8?$)4%>&?'Mw(y"
694
+ ];
695
+ function OptionsMemberParserCondition(props) {
696
+ const { name, alias: aliasProp, isCaseSensitive } = props;
697
+ return [memo(() => code`${isCaseSensitive ? "arg.startsWith(\"--" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\""}${isCaseSensitive ? name : name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}=") || ${isCaseSensitive ? "arg" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"} === "${isCaseSensitive ? name : name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}" || ${isCaseSensitive ? "arg.startsWith(\"-" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\""}${isCaseSensitive ? name : name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}=") || ${isCaseSensitive ? "arg" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"} === "${isCaseSensitive ? name : name.toLowerCase().replaceAll("-", "").replaceAll("_", "")}"`), createComponent(Show, {
698
+ get when() {
699
+ return aliasProp && aliasProp.length > 0;
700
+ },
701
+ get children() {
702
+ return createComponent(For, {
703
+ each: aliasProp ?? [],
704
+ get children() {
705
+ return __assignType((alias) => code` || ${isCaseSensitive || alias.length === 1 ? "arg.startsWith(\"--" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\""}${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll("-", "").replaceAll("_", "")}=") || ${isCaseSensitive || alias.length === 1 ? "arg" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"} === "${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll("-", "").replaceAll("_", "")}" || ${isCaseSensitive || alias.length === 1 ? "arg.startsWith(\"-" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\").startsWith(\""}${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll("-", "").replaceAll("_", "")}=") || ${isCaseSensitive || alias.length === 1 ? "arg" : "arg.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"} === "${isCaseSensitive || alias.length === 1 ? alias : alias.toLowerCase().replaceAll("-", "").replaceAll("_", "")}"`, [
706
+ "alias",
707
+ "",
708
+ "P\"2!\"/\""
709
+ ]);
710
+ }
711
+ });
712
+ }
713
+ })];
714
+ }
715
+ OptionsMemberParserCondition.__type = [
716
+ () => __ΩOptionsMemberParserConditionProps,
717
+ "props",
718
+ "OptionsMemberParserCondition",
719
+ "Pn!2\"\"/#"
720
+ ];
721
+ function OptionsInterfaceDeclaration(props) {
722
+ const { command } = props;
723
+ const options = computed(() => computedOptions(Object.entries(command.options).map(__assignType(([name, option]) => ({
724
+ ...option,
725
+ name
726
+ }), [
727
+ "param0",
728
+ "",
729
+ "P\"2!\"/\""
730
+ ]))));
731
+ return createComponent(InterfaceDeclaration, {
732
+ "export": true,
733
+ get name() {
734
+ return `${pascalCase(command.name)}Options`;
735
+ },
736
+ "extends": "GlobalOptions",
737
+ get children() {
738
+ return createComponent(For, {
739
+ get each() {
740
+ return Object.values(options.value);
741
+ },
742
+ hardline: true,
743
+ get children() {
744
+ return __assignType((option) => createComponent(OptionsMember, { option }), [
745
+ "option",
746
+ "",
747
+ "P\"2!\"/\""
748
+ ]);
749
+ }
750
+ });
751
+ }
752
+ });
753
+ }
754
+ OptionsInterfaceDeclaration.__type = [
755
+ "CommandTree",
756
+ "command",
757
+ "props",
758
+ "OptionsInterfaceDeclaration",
759
+ "PP\"w!4\"M2#\"/$"
760
+ ];
761
+ const __ΩOptionsParserLogicProps = [
762
+ "appSpecificEnvPrefix",
763
+ "The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).",
764
+ "isCaseSensitive",
765
+ true,
766
+ "Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.",
767
+ "OptionsParserLogicProps",
768
+ "P!&4!?\")4#8>$?%Mw&y"
769
+ ];
770
+ /**
771
+ * The command options parser logic.
772
+ */
773
+ function OptionsParserLogic(props) {
774
+ const { segments = [], options: _options, name: _name, appSpecificEnvPrefix, isCaseSensitive = false } = props;
775
+ const options = computed(() => computedOptions(Object.entries(_options).map(__assignType(([name, option]) => ({
776
+ ...option,
777
+ name
778
+ }), [
779
+ "param0",
780
+ "",
781
+ "P\"2!\"/\""
782
+ ]))));
783
+ return [
784
+ createComponent(VarDeclaration, {
785
+ "const": true,
786
+ name: "options",
787
+ get initializer() {
788
+ return code` {
789
+ ${segments.length > 0 ? "...useGlobalOptions(), " : ""}${Object.entries(options.value).filter(__assignType(([, option]) => option.env || option.default !== void 0 || (option.type === "string" || option.type === "number") && option.variadic, [
790
+ "param0",
791
+ "",
792
+ "P\"2!\"/\""
793
+ ])).map(__assignType(([name, option]) => {
794
+ if (option.type === "string") return ` ${name.includes("?") || name.includes("-") ? `"${name}"` : `${name}`}: ${option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : ""}${option.variadic ? option.default !== void 0 ? `${option.env ? " ?? " : ""}${JSON.stringify(option.default)}` : option.env ? " ?? []" : "[]" : option.default !== void 0 ? `${option.env ? " ?? " : ""}"${option.default}"` : ""}, `;
795
+ else if (option.type === "number") return ` ${name.includes("?") || name.includes("-") ? `"${name}"` : `${name}`}: ${option.env ? `env.${appSpecificEnvPrefix}_${option.env}` : ""}${option.variadic ? option.default && Array.isArray(option.default) ? `${option.env ? " ?? " : ""}${JSON.stringify(option.default)}` : option.env ? " ?? []" : "[]" : option.default !== void 0 ? `${option.env ? " ?? " : ""}${option.default}` : ""}, `;
796
+ else if (option.type === "boolean") return ` ${name.includes("?") || name.includes("-") ? `"${name}"` : `${name}`}: ${option.env ? `env.${appSpecificEnvPrefix}_${option.env} ?? ` : ""}${option.default ? "true" : "false"},`;
797
+ return "";
798
+ }, [
799
+ "param0",
800
+ "",
801
+ "P\"2!\"/\""
802
+ ])).join("")}
803
+ } as unknown as ${segments.length > 0 ? pascalCase(_name) : "Global"}Options;`;
804
+ }
805
+ }),
806
+ createComponent(Spacing, {}),
807
+ memo(() => code`for (let i = 0; i < args.slice(${segments.filter(__assignType((segment) => isDynamicPathSegment(segment), [
808
+ "segment",
809
+ "",
810
+ "P\"2!\"/\""
811
+ ])).length}).length; i++) { `),
812
+ createIntrinsic("hbr", {}),
813
+ createComponent(VarDeclaration, {
814
+ "const": true,
815
+ name: "arg",
816
+ type: "string",
817
+ initializer: code` args[i].length > 3 && args[i].startsWith("--")
818
+ ? \`--\${args[i].slice(2).replaceAll("-", "")${isCaseSensitive ? "" : ".toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")"}}\`
5
819
  : args[i].length > 2 && args[i].startsWith("-")
6
820
  ? \`-\${args[i].slice(1).replaceAll("-", "")}\`
7
- : args[i]; `}),s(`hbr`,{}),o(f,{get each(){return Object.entries(_.value)},hardline:!0,get children(){return w(([e,t],n)=>o(p,{when:n===0,get fallback(){return o(v,{get condition(){return[o(N,{name:e,get alias(){return t.alias},isCaseSensitive:d})]},get children(){return o(j,{name:e,option:t,isCaseSensitive:d})}})},get children(){return o(y,{get condition(){return o(N,{name:e,get alias(){return t.alias},isCaseSensitive:d})},get children(){return o(j,{name:e,option:t,isCaseSensitive:d})}})}}),[`param0`,`i`,``,`P"2!"2""/#`])}}),s(`hbr`,{}),m` } `,s(`hbr`,{})]}I.__type=[()=>F,`props`,`OptionsParserLogic`,`The command options parser logic.`,`Pn!2""/#?$`];const L=[`CommandTree`,`command`,`The command to generate the parser logic for.`,`appSpecificEnvPrefix`,"The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).",`isCaseSensitive`,!0,`Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.`,`CommandParserLogicProps`,`P"w!4"?#&4$?%)4&8>'?(Mw)y`];function R(e){let{command:t,appSpecificEnvPrefix:n,isCaseSensitive:r=!1}=e;return[o(E,{command:t,isCaseSensitive:r}),o(g,{}),o(I,{get name(){return t.name},get options(){return t.options},get segments(){return t.segments},appSpecificEnvPrefix:n,isCaseSensitive:r}),o(g,{}),o(O,{command:t,appSpecificEnvPrefix:n,isCaseSensitive:r}),o(g,{})]}R.__type=[()=>L,`props`,`CommandParserLogic`,`The command parser logic, which includes parsing dynamic path segments, positional parameters, and options.`,`Pn!2""/#?$`];export{O as ArgumentsParserLogic,R as CommandParserLogic,E as DynamicSegmentsParserLogic,P as OptionsInterfaceDeclaration,k as OptionsMember,N as OptionsMemberParserCondition,j as OptionsMemberParserLogic,I as OptionsParserLogic,D as __ΩArgumentsParserLogicProps,L as __ΩCommandParserLogicProps,T as __ΩDynamicSegmentsParserLogicProps,M as __ΩOptionsMemberParserConditionProps,A as __ΩOptionsMemberParserLogicProps,F as __ΩOptionsParserLogicProps};
821
+ : args[i]; `
822
+ }),
823
+ createIntrinsic("hbr", {}),
824
+ createComponent(For, {
825
+ get each() {
826
+ return Object.entries(options.value);
827
+ },
828
+ hardline: true,
829
+ get children() {
830
+ return __assignType(([name, option], i) => createComponent(Show, {
831
+ when: i === 0,
832
+ get fallback() {
833
+ return createComponent(ElseIfClause, {
834
+ get condition() {
835
+ return [createComponent(OptionsMemberParserCondition, {
836
+ name,
837
+ get alias() {
838
+ return option.alias;
839
+ },
840
+ isCaseSensitive
841
+ })];
842
+ },
843
+ get children() {
844
+ return createComponent(OptionsMemberParserLogic, {
845
+ name,
846
+ option,
847
+ isCaseSensitive
848
+ });
849
+ }
850
+ });
851
+ },
852
+ get children() {
853
+ return createComponent(IfStatement, {
854
+ get condition() {
855
+ return createComponent(OptionsMemberParserCondition, {
856
+ name,
857
+ get alias() {
858
+ return option.alias;
859
+ },
860
+ isCaseSensitive
861
+ });
862
+ },
863
+ get children() {
864
+ return createComponent(OptionsMemberParserLogic, {
865
+ name,
866
+ option,
867
+ isCaseSensitive
868
+ });
869
+ }
870
+ });
871
+ }
872
+ }), [
873
+ "param0",
874
+ "i",
875
+ "",
876
+ "P\"2!\"2\"\"/#"
877
+ ]);
878
+ }
879
+ }),
880
+ createIntrinsic("hbr", {}),
881
+ code` } `,
882
+ createIntrinsic("hbr", {})
883
+ ];
884
+ }
885
+ OptionsParserLogic.__type = [
886
+ () => __ΩOptionsParserLogicProps,
887
+ "props",
888
+ "OptionsParserLogic",
889
+ "The command options parser logic.",
890
+ "Pn!2\"\"/#?$"
891
+ ];
892
+ const __ΩCommandParserLogicProps = [
893
+ "CommandTree",
894
+ "command",
895
+ "The command to generate the parser logic for.",
896
+ "appSpecificEnvPrefix",
897
+ "The environment variable prefix to use for options that have an associated environment variable. This prefix will be used in the generated code to access the environment variables (e.g., `env.${appSpecificEnvPrefix}_OPTION_NAME`).",
898
+ "isCaseSensitive",
899
+ true,
900
+ "Whether the command options should be parsed in a case-sensitive manner. This will affect how the generated code compares command-line arguments to option names and aliases.",
901
+ "CommandParserLogicProps",
902
+ "P\"w!4\"?#&4$?%)4&8>'?(Mw)y"
903
+ ];
904
+ /**
905
+ * The command parser logic, which includes parsing dynamic path segments, positional parameters, and options.
906
+ */
907
+ function CommandParserLogic(props) {
908
+ const { command, appSpecificEnvPrefix, isCaseSensitive = false } = props;
909
+ return [
910
+ createComponent(DynamicSegmentsParserLogic, {
911
+ command,
912
+ isCaseSensitive
913
+ }),
914
+ createComponent(Spacing, {}),
915
+ createComponent(OptionsParserLogic, {
916
+ get name() {
917
+ return command.name;
918
+ },
919
+ get options() {
920
+ return command.options;
921
+ },
922
+ get segments() {
923
+ return command.segments;
924
+ },
925
+ appSpecificEnvPrefix,
926
+ isCaseSensitive
927
+ }),
928
+ createComponent(Spacing, {}),
929
+ createComponent(ArgumentsParserLogic, {
930
+ command,
931
+ appSpecificEnvPrefix,
932
+ isCaseSensitive
933
+ }),
934
+ createComponent(Spacing, {})
935
+ ];
936
+ }
937
+ CommandParserLogic.__type = [
938
+ () => __ΩCommandParserLogicProps,
939
+ "props",
940
+ "CommandParserLogic",
941
+ "The command parser logic, which includes parsing dynamic path segments, positional parameters, and options.",
942
+ "Pn!2\"\"/#?$"
943
+ ];
944
+
945
+ //#endregion
946
+ export { ArgumentsParserLogic, CommandParserLogic, DynamicSegmentsParserLogic, OptionsInterfaceDeclaration, OptionsMember, OptionsMemberParserCondition, OptionsMemberParserLogic, OptionsParserLogic, __ΩArgumentsParserLogicProps, __ΩCommandParserLogicProps, __ΩDynamicSegmentsParserLogicProps, __ΩOptionsMemberParserConditionProps, __ΩOptionsMemberParserLogicProps, __ΩOptionsParserLogicProps };
8
947
  //# sourceMappingURL=options-parser-logic.mjs.map