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