@politty/zod 0.7.0 → 0.7.1

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 (43) hide show
  1. package/dist/{arg-registry-SvIkYiSr.d.ts → arg-registry-biPCZomY.d.ts} +20 -0
  2. package/dist/{argv-parser-BEwhz0XV.js → argv-parser-DVXJQeSu.js} +1 -1
  3. package/dist/augment.d.ts +1 -1
  4. package/dist/cli-main-BSBIN1DS.js +1 -0
  5. package/dist/{cli-main-qfjIxAaA.js → cli-main-I1ZrqkyB.js} +2 -2
  6. package/dist/cli-run-6gcq15BA.js +1 -0
  7. package/dist/cli.js +1 -1
  8. package/dist/completion-BbIgv0cR.js +1 -0
  9. package/dist/{completion-07BWyhmL.js → completion-DXVkj0Uc.js} +1 -1
  10. package/dist/completion.d.ts +2 -2
  11. package/dist/completion.js +1 -1
  12. package/dist/docs.d.ts +1 -1
  13. package/dist/docs.js +32 -32
  14. package/dist/{dynamic-D3fYVKon.js → dynamic-CvUL5rZa.js} +2 -2
  15. package/dist/dynamic-CznEuQ3H.js +1 -0
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.js +1 -1
  18. package/dist/{prompt-QPFzhQ3p.js → prompt-CNSDU99O.js} +1 -1
  19. package/dist/prompt-clack.d.ts +1 -1
  20. package/dist/prompt-clack.js +1 -1
  21. package/dist/prompt-inquirer.d.ts +1 -1
  22. package/dist/prompt-inquirer.js +1 -1
  23. package/dist/prompt.d.ts +1 -1
  24. package/dist/prompt.js +1 -1
  25. package/dist/{register-BIQ84gFS.js → register-BWzt6u5k.js} +1 -1
  26. package/dist/runner-BpOAXgAg.js +33 -0
  27. package/dist/runner-yzfeOFoF.js +1 -0
  28. package/dist/{schema-C2QqQGOQ.js → schema-BF9YOHU0.js} +1 -1
  29. package/dist/schema-extractor-Cwg_WAC-.js +1 -0
  30. package/dist/skill.d.ts +1 -1
  31. package/dist/skill.js +1 -1
  32. package/dist/unflatten-DVeO9OZ_.js +1 -0
  33. package/dist/{with-completion-command-M2RHrGAp.d.ts → with-completion-command-BY-z7NOc.d.ts} +1 -1
  34. package/dist/{with-completion-command-DSqob4X0.js → with-completion-command-DkZmjiSe.js} +2 -2
  35. package/package.json +1 -1
  36. package/dist/cli-main-Dccv0RoX.js +0 -1
  37. package/dist/cli-run-DtYY4hyA.js +0 -1
  38. package/dist/completion-B9wrL5rH.js +0 -1
  39. package/dist/dynamic-CxhC0uOL.js +0 -1
  40. package/dist/runner-Bfxogqk4.js +0 -1
  41. package/dist/runner-BxFyJbWK.js +0 -33
  42. package/dist/schema-extractor-DL8vjWso.js +0 -1
  43. package/dist/unflatten-D6YJ7e-J.js +0 -1
@@ -116,6 +116,8 @@ interface ResolvedFieldMeta {
116
116
  * If an array, earlier entries take priority.
117
117
  */
118
118
  env?: string | string[] | undefined;
119
+ /** Load the value(s) as env file path(s); `"if-exists"` skips a missing file */
120
+ envFile?: boolean | "if-exists" | undefined;
119
121
  /** Whether this argument is required */
120
122
  required: boolean;
121
123
  /** Default value if any */
@@ -980,6 +982,24 @@ interface BaseArgMeta<TValue = unknown> {
980
982
  * ```
981
983
  */
982
984
  env?: string | string[];
985
+ /**
986
+ * Treat this global option's value(s) as env file path(s) and load them into
987
+ * `process.env` before any `env` fallback is applied, like Node.js
988
+ * `--env-file`. `true` fails when a file does not exist; `"if-exists"`
989
+ * skips a missing file, like `--env-file-if-exists`.
990
+ *
991
+ * Only meaningful on a `globalArgs` option whose value is a string or an array of
992
+ * strings. Files load in option declaration order, then in the order given on
993
+ * the command line (outer command first); a later file overrides an earlier
994
+ * one, and variables already set in the environment are never overridden.
995
+ *
996
+ * @example
997
+ * ```ts
998
+ * "env-file": arg(z.string().array().optional(), { alias: "e", envFile: true }),
999
+ * "env-file-if-exists": arg(z.string().array().optional(), { envFile: "if-exists" }),
1000
+ * ```
1001
+ */
1002
+ envFile?: boolean | "if-exists";
983
1003
  /** Completion configuration for shell tab-completion */
984
1004
  completion?: CompletionMeta;
985
1005
  /**
@@ -1 +1 @@
1
- import{f as e,u as t}from"./unflatten-D6YJ7e-J.js";const n=/* @__PURE__ */ new Set([`1`,`t`,`T`,`TRUE`,`true`,`True`]),r=/* @__PURE__ */ new Set([`0`,`f`,`F`,`FALSE`,`false`,`False`]);function i(e){return n.has(e)?!0:!r.has(e)&&e}function a(e,t){return t===`boolean`?i(e):e}function o(e){let t=e.indexOf(`=`);return t>=0?e.slice(2,t):e.slice(2)}function s(e,t){let n=o(e);if(!e.includes(`=`)){let e=t.negationMap.get(n);if(e&&t.booleanFlags.has(e))return{resolvedName:e,withoutDashes:n,isNegated:!0,isCustomNegation:!0,isSuppressedNegation:!1}}let r=e.includes(`=`);if(!r&&n.startsWith(`no-`)){let e=n.slice(3);if(e===e.toLowerCase()){let r=t.aliasMap.get(e)??e;if(t.booleanFlags.has(r)){let e=t.aliasMap.get(n)??n;if(!t.definedNames.has(e))return t.defaultNegationDisabledFields.has(r)?{resolvedName:r,withoutDashes:n,isNegated:!1,isCustomNegation:!1,isSuppressedNegation:!0}:{resolvedName:r,withoutDashes:n,isNegated:!0,isCustomNegation:!1,isSuppressedNegation:!1}}}}if(!r&&n.length>2&&n.startsWith(`no`)&&/[A-Z]/.test(n[2])){let e=n[2].toLowerCase()+n.slice(3),r=t.aliasMap.get(e)??e;if(t.booleanFlags.has(r)){let e=t.aliasMap.get(n)??n;if(!t.definedNames.has(e))return t.defaultNegationDisabledFields.has(r)?{resolvedName:r,withoutDashes:n,isNegated:!1,isCustomNegation:!1,isSuppressedNegation:!0}:{resolvedName:r,withoutDashes:n,isNegated:!0,isCustomNegation:!1,isSuppressedNegation:!1}}}return{resolvedName:t.aliasMap.get(n)??n,withoutDashes:n,isNegated:!1,isCustomNegation:!1,isSuppressedNegation:!1}}const c=/^-\.?\d/;function l(e){return!e.startsWith(`-`)||c.test(e)}function u(e){return e.startsWith(`-`)&&!e.startsWith(`--`)&&e.length>2&&!e.includes(`=`)}function d(e,t){let n=Array.from(e),r=n.findIndex(t);if(r===-1)return{flags:n,valueOption:void 0};let i=n.slice(r+1).join(``);return{flags:n.slice(0,r),valueOption:{name:n[r],value:i===``?void 0:i}}}function f(e,t={}){let{aliasMap:n=/* @__PURE__ */ new Map,booleanFlags:r=/* @__PURE__ */ new Set,arrayFlags:a=/* @__PURE__ */ new Set,valueFlags:o=/* @__PURE__ */ new Set,definedNames:c=/* @__PURE__ */ new Set,negationMap:u=/* @__PURE__ */ new Map,defaultNegationDisabledFields:f,unknownFlagsTakeNoValue:p=!1}=t,m=f??new Set(r),h=e=>r.has(e)||p&&!c.has(e),g={aliasMap:n,booleanFlags:r,definedNames:c,negationMap:u,defaultNegationDisabledFields:m},_={options:{},positionals:[],rest:[]},v=0,y=!1,b=(e,t)=>{let r=n.get(e)??e;if(a.has(r)){let e=_.options[r];Array.isArray(e)?e.push(t):e===void 0?_.options[r]=[t]:_.options[r]=[e,t]}else _.options[r]=t},x=t=>{let n=e[v+1];n!==void 0&&l(n)?(b(t,n),v+=2):(b(t,!0),v++)};for(;v<e.length;){let t=e[v];if(y)_.rest.push(t),v++;else if(t===`--`)y=!0,v++;else if(t.startsWith(`--`)){let e=t.slice(2),a=s(t,g);if(a.isSuppressedNegation){b(a.withoutDashes,!0),v++;continue}if(a.isNegated){b(a.resolvedName,!1),v++;continue}let o=e.indexOf(`=`);if(o!==-1){let t=e.slice(0,o),a=e.slice(o+1),s=n.get(t)??t;b(t,r.has(s)?i(a):a),v++}else{let t=e;h(n.get(t)??t)?(b(t,!0),v++):x(t)}}else if(t.startsWith(`-`)&&t.length>1&&!t.startsWith(`--`)){let e=t.slice(1),a=e.indexOf(`=`);if(a!==-1){let t=e.slice(0,a),o=e.slice(a+1),s=n.get(t)??t;b(t,r.has(s)?i(o):o),v++}else if(e.length===1){let t=e;h(n.get(t)??t)?(b(t,!0),v++):x(t)}else{let{flags:t,valueOption:r}=d(e,e=>o.has(n.get(e)??e));for(let e of t)b(e,!0);r?r.value===void 0?x(r.name):(b(r.name,r.value),v++):v++}}else _.positionals.push(t),v++}return _}function p(n){let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Set,c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Set;for(let e of n.fields)s.add(e.name);for(let u of n.fields){if(!u.named)continue;u.cliName!==u.name&&r.set(u.cliName,u.name);for(let n of t(u))if(r.set(n,u.name),n.length>1&&n.includes(`-`)){let t=e(n);t!==n&&!s.has(t)&&!r.has(t)&&r.set(t,u.name)}let n=e(u.name);if(n!==u.name&&!s.has(n)&&!r.has(n)&&r.set(n,u.name),u.type===`boolean`?i.add(u.name):o.add(u.name),u.type===`array`&&a.add(u.name),u.type===`boolean`&&u.negation!==!0&&(l.add(u.name),typeof u.negation==`string`&&(c.set(u.negation,u.name),u.negation.includes(`-`)))){let t=e(u.negation);t!==u.negation&&c.set(t,u.name)}}return{aliasMap:r,booleanFlags:i,arrayFlags:a,valueFlags:o,definedNames:s,negationMap:c,defaultNegationDisabledFields:l}}function m(e,t){return e.fields.filter(e=>e.positional&&!(e.named&&Object.hasOwn(t,e.name)))}function h(e,t){let n={...e.options},r=t.fields.filter(e=>e.positional),i=e.rest.length>0?[...e.positionals,...e.rest]:e.positionals;for(let e of r)e.named||delete n[e.name];let a=0;for(let r of m(t,e.options)){if(a>=i.length)break;if(r.type===`array`){n[r.name]=i.slice(a);break}n[r.name]=i[a],a++}return n}export{f as a,o as c,a as d,h as i,s as l,l as n,m as o,u as r,d as s,p as t,i as u};
1
+ import{d as e,p as t}from"./unflatten-DVeO9OZ_.js";const n=/* @__PURE__ */ new Set([`1`,`t`,`T`,`TRUE`,`true`,`True`]),r=/* @__PURE__ */ new Set([`0`,`f`,`F`,`FALSE`,`false`,`False`]);function i(e){return n.has(e)?!0:!r.has(e)&&e}function a(e,t){return t===`boolean`?i(e):e}function o(e){let t=e.indexOf(`=`);return t>=0?e.slice(2,t):e.slice(2)}function s(e,t){let n=o(e);if(!e.includes(`=`)){let e=t.negationMap.get(n);if(e&&t.booleanFlags.has(e))return{resolvedName:e,withoutDashes:n,isNegated:!0,isCustomNegation:!0,isSuppressedNegation:!1}}let r=e.includes(`=`);if(!r&&n.startsWith(`no-`)){let e=n.slice(3);if(e===e.toLowerCase()){let r=t.aliasMap.get(e)??e;if(t.booleanFlags.has(r)){let e=t.aliasMap.get(n)??n;if(!t.definedNames.has(e))return t.defaultNegationDisabledFields.has(r)?{resolvedName:r,withoutDashes:n,isNegated:!1,isCustomNegation:!1,isSuppressedNegation:!0}:{resolvedName:r,withoutDashes:n,isNegated:!0,isCustomNegation:!1,isSuppressedNegation:!1}}}}if(!r&&n.length>2&&n.startsWith(`no`)&&/[A-Z]/.test(n[2])){let e=n[2].toLowerCase()+n.slice(3),r=t.aliasMap.get(e)??e;if(t.booleanFlags.has(r)){let e=t.aliasMap.get(n)??n;if(!t.definedNames.has(e))return t.defaultNegationDisabledFields.has(r)?{resolvedName:r,withoutDashes:n,isNegated:!1,isCustomNegation:!1,isSuppressedNegation:!0}:{resolvedName:r,withoutDashes:n,isNegated:!0,isCustomNegation:!1,isSuppressedNegation:!1}}}return{resolvedName:t.aliasMap.get(n)??n,withoutDashes:n,isNegated:!1,isCustomNegation:!1,isSuppressedNegation:!1}}const c=/^-\.?\d/;function l(e){return!e.startsWith(`-`)||c.test(e)}function u(e){return e.startsWith(`-`)&&!e.startsWith(`--`)&&e.length>2&&!e.includes(`=`)}function d(e,t){let n=Array.from(e),r=n.findIndex(t);if(r===-1)return{flags:n,valueOption:void 0};let i=n.slice(r+1).join(``);return{flags:n.slice(0,r),valueOption:{name:n[r],value:i===``?void 0:i}}}function f(e,t={}){let{aliasMap:n=/* @__PURE__ */ new Map,booleanFlags:r=/* @__PURE__ */ new Set,arrayFlags:a=/* @__PURE__ */ new Set,valueFlags:o=/* @__PURE__ */ new Set,definedNames:c=/* @__PURE__ */ new Set,negationMap:u=/* @__PURE__ */ new Map,defaultNegationDisabledFields:f,unknownFlagsTakeNoValue:p=!1}=t,m=f??new Set(r),h=e=>r.has(e)||p&&!c.has(e),g={aliasMap:n,booleanFlags:r,definedNames:c,negationMap:u,defaultNegationDisabledFields:m},_={options:{},positionals:[],rest:[]},v=0,y=!1,b=(e,t)=>{let r=n.get(e)??e;if(a.has(r)){let e=_.options[r];Array.isArray(e)?e.push(t):e===void 0?_.options[r]=[t]:_.options[r]=[e,t]}else _.options[r]=t},x=t=>{let n=e[v+1];n!==void 0&&l(n)?(b(t,n),v+=2):(b(t,!0),v++)};for(;v<e.length;){let t=e[v];if(y)_.rest.push(t),v++;else if(t===`--`)y=!0,v++;else if(t.startsWith(`--`)){let e=t.slice(2),a=s(t,g);if(a.isSuppressedNegation){b(a.withoutDashes,!0),v++;continue}if(a.isNegated){b(a.resolvedName,!1),v++;continue}let o=e.indexOf(`=`);if(o!==-1){let t=e.slice(0,o),a=e.slice(o+1),s=n.get(t)??t;b(t,r.has(s)?i(a):a),v++}else{let t=e;h(n.get(t)??t)?(b(t,!0),v++):x(t)}}else if(t.startsWith(`-`)&&t.length>1&&!t.startsWith(`--`)){let e=t.slice(1),a=e.indexOf(`=`);if(a!==-1){let t=e.slice(0,a),o=e.slice(a+1),s=n.get(t)??t;b(t,r.has(s)?i(o):o),v++}else if(e.length===1){let t=e;h(n.get(t)??t)?(b(t,!0),v++):x(t)}else{let{flags:t,valueOption:r}=d(e,e=>o.has(n.get(e)??e));for(let e of t)b(e,!0);r?r.value===void 0?x(r.name):(b(r.name,r.value),v++):v++}}else _.positionals.push(t),v++}return _}function p(n){let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Set,a=/* @__PURE__ */ new Set,o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Set,c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Set;for(let e of n.fields)s.add(e.name);for(let u of n.fields){if(!u.named)continue;u.cliName!==u.name&&r.set(u.cliName,u.name);for(let n of e(u))if(r.set(n,u.name),n.length>1&&n.includes(`-`)){let e=t(n);e!==n&&!s.has(e)&&!r.has(e)&&r.set(e,u.name)}let n=t(u.name);if(n!==u.name&&!s.has(n)&&!r.has(n)&&r.set(n,u.name),u.type===`boolean`?i.add(u.name):o.add(u.name),u.type===`array`&&a.add(u.name),u.type===`boolean`&&u.negation!==!0&&(l.add(u.name),typeof u.negation==`string`&&(c.set(u.negation,u.name),u.negation.includes(`-`)))){let e=t(u.negation);e!==u.negation&&c.set(e,u.name)}}return{aliasMap:r,booleanFlags:i,arrayFlags:a,valueFlags:o,definedNames:s,negationMap:c,defaultNegationDisabledFields:l}}function m(e,t){return e.fields.filter(e=>e.positional&&!(e.named&&Object.hasOwn(t,e.name)))}function h(e,t){let n={...e.options},r=t.fields.filter(e=>e.positional),i=e.rest.length>0?[...e.positionals,...e.rest]:e.positionals;for(let e of r)e.named||delete n[e.name];let a=0;for(let r of m(t,e.options)){if(a>=i.length)break;if(r.type===`array`){n[r.name]=i.slice(a);break}n[r.name]=i[a],a++}return n}export{f as a,o as c,a as d,h as i,s as l,l as n,m as o,u as r,d as s,p as t,i as u};
package/dist/augment.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ArgMeta } from "./arg-registry-SvIkYiSr.js";
1
+ import { n as ArgMeta } from "./arg-registry-biPCZomY.js";
2
2
  declare module "zod" {
3
3
  interface ZodTypeDef {
4
4
  argMeta?: ArgMeta;
@@ -0,0 +1 @@
1
+ export{t as runPolittyCli}from"./cli-main-I1ZrqkyB.js";
@@ -1,2 +1,2 @@
1
- import{d as e,f as t}from"./schema-extractor-DL8vjWso.js";import{n}from"./command-BXsTrIgI.js";import{n as r}from"./runner-BxFyJbWK.js";import{chmodSync as i,existsSync as a,mkdirSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{basename as l,dirname as u,extname as d,isAbsolute as f,join as p,relative as m,resolve as h}from"node:path";import{fileURLToPath as g}from"node:url";const _=`Generated by politty: compile-cache bin shim`,v=[`./cli.js`,`./cli.mjs`,`./index.js`,`./index.mjs`];function y(e){let t=h(e);for(;;){let e=p(t,`package.json`);if(a(e))return{pkg:JSON.parse(s(e,`utf8`)),dir:t};let n=u(t);if(n===t)return;t=n}}function b(e){if(!e)return[];if(typeof e.bin==`string`&&e.bin){let t=x(e);return t?[[t,e.bin]]:[]}return typeof e.bin==`object`&&e.bin!==null?Object.entries(e.bin).filter(e=>typeof e[1]==`string`&&e[1]!==``):[]}function x(e){if(e){if(typeof e.bin==`object`&&e.bin!==null){let[t]=Object.keys(e.bin);if(t)return t}if(typeof e.name==`string`&&e.name){let t=e.name;return t.startsWith(`@`)?t.split(`/`)[1]??t:t}}}function S(e){let t=u(e),n=l(e);for(let e of v)if(l(e)!==n&&a(p(t,e)))return e}function C(e,t,n){return[`#!/usr/bin/env node`,``,`// ${_}.`,`// Enables the Node.js on-disk compile cache (V8 code cache) before the`,`// CLI module graph is compiled, so warm starts skip recompilation`,`// (Node >= 22.8.0; silent no-op otherwise).`,`try {`,` const { enableCompileCache } = await import(${JSON.stringify(n)});`,` enableCompileCache(${JSON.stringify(e)});`,`} catch {`,` // ${n} is not resolvable from here (e.g. a fully`,` // bundled CLI) — start without the compile cache rather than failing`,` // the CLI.`,`}`,`await import(${JSON.stringify(t)});`,``].join(`
2
- `)}function w(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function T(e){return(t={})=>E(`${e}/compile-cache`,t)}function E(e,t){let n=t.cwd??process.cwd(),r=y(n),l=r?.pkg,p=w(t.entry),m=w(t.out),T=b(l),E;if(m.length>0){if(p.length>0&&p.length!==m.length)throw Error(`--entry count (${p.length}) does not match --out count (${m.length}); pass one --out per --entry or omit --out entirely.`);E=m.map(e=>f(e)?e:h(n,e))}else{if(T.length===0||r===void 0)throw Error(`Cannot derive the output path: no bin entry in package.json. Pass --out explicitly.`);if(p.length>0&&p.length!==T.length)throw Error(`--entry count (${p.length}) does not match the package's bin entries (${T.length}); pass one --entry per bin (in declaration order) or matching --out paths.`);E=T.map(([,e])=>h(r.dir,e))}if(new Set(E).size!==E.length)throw Error(`Duplicate output paths; each shim needs a distinct output file. Check the --out values (or the bin paths in package.json when --out is omitted).`);let O=/* @__PURE__ */ new Map;if(r)for(let[e,t]of T)O.set(h(r.dir,t),e);let k=[],A=t.compileCacheSpecifier??e;if(/[\r\n\u2028\u2029]/.test(A))throw Error(`Invalid compile-cache specifier ${JSON.stringify(A)}: a module specifier cannot contain a line terminator.`);let j=E.map((e,r)=>{let i=O.get(e),o=t.program??i??x(l);if(!o)throw Error(`Cannot derive a program name: no bin or name in package.json. Pass --program explicitly.`);if(t.program===void 0&&i===void 0&&m.length>0&&k.push(`Warning: ${D(e,n)} does not match any bin path in package.json, so its cache directory uses the program name ${JSON.stringify(o)}. Pass --program to override.`),e.endsWith(`.cjs`))throw Error(`The generated shim is an ES module and cannot be written to a .cjs file. Use a .mjs (or .js in a "type": "module" package) output path.`);if(d(e)===``)throw Error(`The generated shim is an ES module and cannot be written to an extensionless file (it would not load on every supported Node.js version). Use a .mjs (or .js in a "type": "module" package) output path.`);if(e.endsWith(`.js`)&&l?.type!==`module`)throw Error(l===void 0?`The generated shim is an ES module, and no package.json was found to confirm .js files are treated as ESM. Write it to a .mjs file instead (e.g. --out dist/bin.mjs).`:`The generated shim is an ES module, but the package is not "type": "module". Write it to a .mjs file instead (e.g. --out dist/bin.mjs).`);let c=p[r]??S(e);if(c===void 0)throw Error(`Cannot derive an entry: none of ${v.join(`, `)} exist next to ${e}. Pass --entry explicitly.`);if(!c.startsWith(`./`)&&!c.startsWith(`../`)&&!c.startsWith(`file:`))throw Error(`Invalid entry ${c}: pass a specifier relative to the shim file ("./..." or "../...") or a file: URL.`);let f;if(c.startsWith(`file:`))try{f=g(c)}catch{f=void 0}else f=h(u(e),c);if(f===e)throw Error(`The shim at ${e} would import itself (entry ${c}). Point bin at a separate shim path (e.g. dist/bin.js) or pass a different --entry.`);if(a(e)&&!s(e,`utf8`).includes(_))throw Error(`Refusing to overwrite ${e}: it exists and was not generated by politty. If bin currently points at your real CLI entry, point it at a separate shim path (e.g. dist/bin.js) or pass --out explicitly.`);return{outputPath:e,program:o,entry:c,compileCacheSpecifier:A}});for(let e of k)console.warn(e);for(let{outputPath:e,program:t,entry:n}of j)o(u(e),{recursive:!0}),c(e,C(t,n,A)),i(e,493);return j}function D(e,t){let n=m(t,e);return n&&!n.startsWith(`..`)?n:e}const O=e({bin:t.string({description:`CLI binary or built JS entry file to invoke`,placeholder:`PATH`}),program:t.string({description:`Program name embedded in worker metadata`,placeholder:`NAME`}),shell:t.enum([`bash`,`zsh`,`fish`],{description:`Shell worker to generate`,placeholder:`SHELL`}),out:t.optionalString({description:`Output worker path (defaults to dist/completion/<shell>-worker.<ext>)`,placeholder:`PATH`}),verify:t.boolean({description:`Verify __completion-worker-path resolves to the generated worker`})}),k=n({name:`generate-worker`,description:`Generate and verify a bundled shell completion worker`,args:O,async run(e){let{generateBundledCompletionWorker:t}=await import(`./completion-B9wrL5rH.js`);await t({bin:e.bin,programName:e.program,shell:e.shell,...e.out!==void 0&&{outputPath:e.out},verify:e.verify})}}),A=e({entry:t.optionalStringArray({description:`Module specifier the shim imports, relative to the shim file; repeatable, one per bin/--out (defaults to ./cli.js, ./cli.mjs, ./index.js, or ./index.mjs next to each shim)`,placeholder:`SPECIFIER`}),out:t.optionalStringArray({description:`Output path for the generated shim; repeatable, one per --entry (defaults to the bin paths in package.json)`,placeholder:`PATH`}),program:t.optionalString({description:`Program name for the cache directory, applied to all shims (defaults per shim to its bin name)`,placeholder:`NAME`}),compileCacheSpecifier:t.optionalString({description:`Module specifier the shim imports enableCompileCache from (defaults to the compile-cache subpath of the politty package running this command)`,placeholder:`SPECIFIER`})});function j(e){let t=T(e),i=n({name:`generate-shim`,description:`Generate a compile-cache bin shim that loads the real CLI via dynamic import`,args:A,run(e){let n=process.cwd(),r=t({...e.entry!==void 0&&{entry:e.entry},...e.out!==void 0&&{out:e.out},...e.program!==void 0&&{program:e.program},...e.compileCacheSpecifier!==void 0&&{compileCacheSpecifier:e.compileCacheSpecifier},cwd:n});for(let e of r)console.log(`Generated compile-cache shim: ${D(e.outputPath,n)} (program: ${e.program}, entry: ${e.entry}, compile-cache: ${e.compileCacheSpecifier})`)}}),a=n({name:`politty`,description:`politty development utilities`,subCommands:{"generate-shim":i,"generate-worker":k}});return r(a).catch(e=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)})}export{T as n,j as t};
1
+ import{d as e,f as t}from"./schema-extractor-Cwg_WAC-.js";import{n}from"./command-BXsTrIgI.js";import{n as r}from"./runner-BpOAXgAg.js";import{chmodSync as i,existsSync as a,mkdirSync as o,readFileSync as s,writeFileSync as c}from"node:fs";import{basename as l,dirname as u,extname as d,isAbsolute as f,join as p,relative as m,resolve as h}from"node:path";import{fileURLToPath as g}from"node:url";const _=`Generated by politty: compile-cache bin shim`,v=[`./cli.js`,`./cli.mjs`,`./index.js`,`./index.mjs`];function y(e){let t=h(e);for(;;){let e=p(t,`package.json`);if(a(e))return{pkg:JSON.parse(s(e,`utf8`)),dir:t};let n=u(t);if(n===t)return;t=n}}function b(e){if(!e)return[];if(typeof e.bin==`string`&&e.bin){let t=x(e);return t?[[t,e.bin]]:[]}return typeof e.bin==`object`&&e.bin!==null?Object.entries(e.bin).filter(e=>typeof e[1]==`string`&&e[1]!==``):[]}function x(e){if(e){if(typeof e.bin==`object`&&e.bin!==null){let[t]=Object.keys(e.bin);if(t)return t}if(typeof e.name==`string`&&e.name){let t=e.name;return t.startsWith(`@`)?t.split(`/`)[1]??t:t}}}function S(e){let t=u(e),n=l(e);for(let e of v)if(l(e)!==n&&a(p(t,e)))return e}function C(e,t,n){return[`#!/usr/bin/env node`,``,`// ${_}.`,`// Enables the Node.js on-disk compile cache (V8 code cache) before the`,`// CLI module graph is compiled, so warm starts skip recompilation`,`// (Node >= 22.8.0; silent no-op otherwise).`,`try {`,` const { enableCompileCache } = await import(${JSON.stringify(n)});`,` enableCompileCache(${JSON.stringify(e)});`,`} catch {`,` // ${n} is not resolvable from here (e.g. a fully`,` // bundled CLI) — start without the compile cache rather than failing`,` // the CLI.`,`}`,`await import(${JSON.stringify(t)});`,``].join(`
2
+ `)}function w(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function T(e){return(t={})=>E(`${e}/compile-cache`,t)}function E(e,t){let n=t.cwd??process.cwd(),r=y(n),l=r?.pkg,p=w(t.entry),m=w(t.out),T=b(l),E;if(m.length>0){if(p.length>0&&p.length!==m.length)throw Error(`--entry count (${p.length}) does not match --out count (${m.length}); pass one --out per --entry or omit --out entirely.`);E=m.map(e=>f(e)?e:h(n,e))}else{if(T.length===0||r===void 0)throw Error(`Cannot derive the output path: no bin entry in package.json. Pass --out explicitly.`);if(p.length>0&&p.length!==T.length)throw Error(`--entry count (${p.length}) does not match the package's bin entries (${T.length}); pass one --entry per bin (in declaration order) or matching --out paths.`);E=T.map(([,e])=>h(r.dir,e))}if(new Set(E).size!==E.length)throw Error(`Duplicate output paths; each shim needs a distinct output file. Check the --out values (or the bin paths in package.json when --out is omitted).`);let O=/* @__PURE__ */ new Map;if(r)for(let[e,t]of T)O.set(h(r.dir,t),e);let k=[],A=t.compileCacheSpecifier??e;if(/[\r\n\u2028\u2029]/.test(A))throw Error(`Invalid compile-cache specifier ${JSON.stringify(A)}: a module specifier cannot contain a line terminator.`);let j=E.map((e,r)=>{let i=O.get(e),o=t.program??i??x(l);if(!o)throw Error(`Cannot derive a program name: no bin or name in package.json. Pass --program explicitly.`);if(t.program===void 0&&i===void 0&&m.length>0&&k.push(`Warning: ${D(e,n)} does not match any bin path in package.json, so its cache directory uses the program name ${JSON.stringify(o)}. Pass --program to override.`),e.endsWith(`.cjs`))throw Error(`The generated shim is an ES module and cannot be written to a .cjs file. Use a .mjs (or .js in a "type": "module" package) output path.`);if(d(e)===``)throw Error(`The generated shim is an ES module and cannot be written to an extensionless file (it would not load on every supported Node.js version). Use a .mjs (or .js in a "type": "module" package) output path.`);if(e.endsWith(`.js`)&&l?.type!==`module`)throw Error(l===void 0?`The generated shim is an ES module, and no package.json was found to confirm .js files are treated as ESM. Write it to a .mjs file instead (e.g. --out dist/bin.mjs).`:`The generated shim is an ES module, but the package is not "type": "module". Write it to a .mjs file instead (e.g. --out dist/bin.mjs).`);let c=p[r]??S(e);if(c===void 0)throw Error(`Cannot derive an entry: none of ${v.join(`, `)} exist next to ${e}. Pass --entry explicitly.`);if(!c.startsWith(`./`)&&!c.startsWith(`../`)&&!c.startsWith(`file:`))throw Error(`Invalid entry ${c}: pass a specifier relative to the shim file ("./..." or "../...") or a file: URL.`);let f;if(c.startsWith(`file:`))try{f=g(c)}catch{f=void 0}else f=h(u(e),c);if(f===e)throw Error(`The shim at ${e} would import itself (entry ${c}). Point bin at a separate shim path (e.g. dist/bin.js) or pass a different --entry.`);if(a(e)&&!s(e,`utf8`).includes(_))throw Error(`Refusing to overwrite ${e}: it exists and was not generated by politty. If bin currently points at your real CLI entry, point it at a separate shim path (e.g. dist/bin.js) or pass --out explicitly.`);return{outputPath:e,program:o,entry:c,compileCacheSpecifier:A}});for(let e of k)console.warn(e);for(let{outputPath:e,program:t,entry:n}of j)o(u(e),{recursive:!0}),c(e,C(t,n,A)),i(e,493);return j}function D(e,t){let n=m(t,e);return n&&!n.startsWith(`..`)?n:e}const O=e({bin:t.string({description:`CLI binary or built JS entry file to invoke`,placeholder:`PATH`}),program:t.string({description:`Program name embedded in worker metadata`,placeholder:`NAME`}),shell:t.enum([`bash`,`zsh`,`fish`],{description:`Shell worker to generate`,placeholder:`SHELL`}),out:t.optionalString({description:`Output worker path (defaults to dist/completion/<shell>-worker.<ext>)`,placeholder:`PATH`}),verify:t.boolean({description:`Verify __completion-worker-path resolves to the generated worker`})}),k=n({name:`generate-worker`,description:`Generate and verify a bundled shell completion worker`,args:O,async run(e){let{generateBundledCompletionWorker:t}=await import(`./completion-BbIgv0cR.js`);await t({bin:e.bin,programName:e.program,shell:e.shell,...e.out!==void 0&&{outputPath:e.out},verify:e.verify})}}),A=e({entry:t.optionalStringArray({description:`Module specifier the shim imports, relative to the shim file; repeatable, one per bin/--out (defaults to ./cli.js, ./cli.mjs, ./index.js, or ./index.mjs next to each shim)`,placeholder:`SPECIFIER`}),out:t.optionalStringArray({description:`Output path for the generated shim; repeatable, one per --entry (defaults to the bin paths in package.json)`,placeholder:`PATH`}),program:t.optionalString({description:`Program name for the cache directory, applied to all shims (defaults per shim to its bin name)`,placeholder:`NAME`}),compileCacheSpecifier:t.optionalString({description:`Module specifier the shim imports enableCompileCache from (defaults to the compile-cache subpath of the politty package running this command)`,placeholder:`SPECIFIER`})});function j(e){let t=T(e),i=n({name:`generate-shim`,description:`Generate a compile-cache bin shim that loads the real CLI via dynamic import`,args:A,run(e){let n=process.cwd(),r=t({...e.entry!==void 0&&{entry:e.entry},...e.out!==void 0&&{out:e.out},...e.program!==void 0&&{program:e.program},...e.compileCacheSpecifier!==void 0&&{compileCacheSpecifier:e.compileCacheSpecifier},cwd:n});for(let e of r)console.log(`Generated compile-cache shim: ${D(e.outputPath,n)} (program: ${e.program}, entry: ${e.entry}, compile-cache: ${e.compileCacheSpecifier})`)}}),a=n({name:`politty`,description:`politty development utilities`,subCommands:{"generate-shim":i,"generate-worker":k}});return r(a).catch(e=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)})}export{T as n,j as t};
@@ -0,0 +1 @@
1
+ import"./register-BWzt6u5k.js";const{runPolittyCli:e}=await import(`./cli-main-BSBIN1DS.js`);await e(`@politty/zod`);export{};
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{n as e}from"./compile-cache-6u9hgeWu.js";e(`politty`),await import(`./cli-run-DtYY4hyA.js`);export{};
2
+ import{n as e}from"./compile-cache-6u9hgeWu.js";e(`politty`),await import(`./cli-run-6gcq15BA.js`);export{};
@@ -0,0 +1 @@
1
+ import"./with-completion-command-DkZmjiSe.js";import"./dynamic-CvUL5rZa.js";export{t as createCompletionCommand,n as createCompletionWorkerPathCommand,r as createRefreshCompletionCommand,c as generateBundledCompletionWorker}from"./completion-DXVkj0Uc.js";
@@ -1,4 +1,4 @@
1
- import{a as e,c as t,n}from"./schema-extractor-DL8vjWso.js";import{n as r}from"./command-BXsTrIgI.js";import{c as i}from"./subcommand-router-40vA6Mka.js";import{a,i as o,n as s,o as c,r as l,s as u}from"./with-completion-command-DSqob4X0.js";import{_ as d,c as f,d as p,f as m,g as h,h as g,i as _,l as v,m as y,p as b,s as ee,t as te,u as ne,v as x,y as S}from"./dynamic-D3fYVKon.js";import{existsSync as C,mkdirSync as re,readFileSync as w,realpathSync as T,renameSync as ie,rmSync as ae,statSync as E,writeFileSync as oe}from"node:fs";import{dirname as D,extname as se,isAbsolute as O,join as k,relative as ce,resolve as le}from"node:path";import{promisify as ue}from"node:util";import{execFile as de}from"node:child_process";function fe(e,t,n=[],r=!1){if(t.length===0)return;let i=pe(e,n);for(let e of t)e.set(me(e,i,r))}function pe(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set;for(let t of[...e.options,...e.positionals])r.add(t.name);let i=(e,t)=>{for(let i of e){if(n.has(i.name)||t&&r.has(i.name))continue;let e=i.valueCompletion;e?.type===`choices`&&e.choices&&e.choices.length>0&&n.set(i.name,e.choices)}};return i([...e.options,...e.positionals],!1),i(t,!0),n}function me(e,t,n=!1){let{spec:r}=e,i=r.dependsOn;if(i.length===0)throw Error(`Field "${e.describe}": completion.custom.expand.dependsOn must list at least one sibling arg.`);let a=[];for(let n of i){if(n===e.name)throw Error(`Field "${e.describe}": completion.custom.expand.dependsOn cannot reference the field itself ("${n}").`);let r=t.get(n);if(!r)throw Error(`Field "${e.describe}": completion.custom.expand.dependsOn references "${n}", which is not a sibling arg with a static \`choices\`/enum schema on the same command. Chaining expand specs is not supported.`);a.push([...r])}if(n)return{type:`expand`,dependsOn:i,table:[]};let o=[];for(let t of ge(a)){let n={};i.forEach((e,r)=>{n[e]=t[r]});let a;try{a=r.enumerate(n)}catch(t){let r=t instanceof Error?t.message:String(t);throw Error(`Field "${e.describe}": completion.custom.expand.enumerate threw for deps=${JSON.stringify(n)}: ${r}`)}let s=he(a);s.length!==0&&o.push({key:t,candidates:s})}return{type:`expand`,dependsOn:i,table:o}}function he(e){let t=[],n=/* @__PURE__ */ new Set;for(let r of e){let e=typeof r==`string`?r:r.value;if(n.has(e))continue;n.add(e);let i={value:e};typeof r!=`string`&&r.description!==void 0&&(i.description=r.description),t.push(i)}return t}function*ge(e){if(e.length===0){yield[];return}let t=Array.from({length:e.length}).fill(0);for(;;){yield t.map((t,n)=>e[n][t]);let n=e.length-1;for(;n>=0&&(t[n]++,!(t[n]<e[n].length));)t[n]=0,n--;if(n<0)return}}function _e(e,t,n,r){let i=ee(e);i?.type===`pending-expand`?t.push({name:e.name,describe:n,set:r,spec:i.spec}):i!==void 0&&r(i)}function A(e){return e.replace(/[^a-zA-Z0-9_]/g,`_`)}function j(e){let t=e.toUpperCase();return/^[A-Z_]/.test(t)?`${t}_BIN`:`_${t}_BIN`}function M(e,t,n){return`__${e}_expand_${t}__${A(n)}`}function ve(e,t){return[`__${e}_invoke_complete() {`,` local _shell="$1"; shift`,` "\${${j(e)}:-${t}}" __complete --shell "$_shell" -- "$@" 2>/dev/null`,`}`]}function N(e){return e.filter(e=>!e.name.startsWith(`__`))}function P(e){let t=[];for(let n of N(e))if(t.push({name:n.name,description:n.description}),n.aliases)for(let e of n.aliases)t.push({name:e,description:n.description});return t}function ye(e,t){let n=e.type===`boolean`&&e.negation===!0,r={name:e.name,cliName:e.cliName,alias:e.alias,negation:e.negationDisplay,negationDescription:e.negationDescription,description:e.description,takesValue:e.type!==`boolean`,valueType:e.type,required:e.required,defaultNegationAccepted:n};return _e(e,t,`--${e.cliName}`,e=>{r.valueCompletion=e}),r}function be(e){return e.args?t(n(e.args)):[]}function xe(e,t){return e.filter(e=>e.named).map(e=>ye(e,t))}function Se(e,t){return e.filter(e=>e.positional).map((e,n)=>{let r={name:e.name,cliName:e.cliName,position:n,description:e.description,required:e.required,variadic:e.type===`array`};return _e(e,t,`<${e.cliName}>`,e=>{r.valueCompletion=e}),r})}function Ce(r,a,o=[],s=!1){let c=[];if(a.subCommands)for(let[e,t]of Object.entries(a.subCommands)){let n=i(t);n?c.push(Ce(e,n,o,s)):c.push({name:e,description:`(lazy loaded)`,subcommands:[],options:[],positionals:[]})}let l=[],u=a.args?n(a.args):void 0,d={name:r,description:a.description,aliases:a.aliases,subcommands:c,options:xe(u?e(u):[],l),positionals:Se(u?t(u):[],l)};return fe(d,l,o,s),d}function F(e,t,n){return e?`${e}${n}${t}`:t}function we(e,t){let n=[t.name,...t.aliases??[]];return e.flatMap(e=>n.map(t=>F(e,t,`:`)))}function Te(e){let t=[],n=(e,r)=>{let i=new Set(e.options.filter(e=>e.isGlobal!==!0).map(e=>e.name));e.positionals.some(e=>i.has(e.name))&&t.push({pathStrs:r,positionals:e.positionals,options:e.options});for(let t of N(e.subcommands))n(t,we(r,t))};return n(e,[``]),t}function I(e,t){let n=[],r=N(e.subcommands).length>0;for(let i of e.options){if(!i.takesValue)continue;let a=r&&i.isGlobal===!0?v(i.cliName,i.alias):R(i,e.options);a.length!==0&&n.push({parentPath:t,tokens:a})}for(let r of N(e.subcommands))for(let e of[r.name,...r.aliases??[]])n.push(...I(r,F(t,e,`:`)));return n}function Ee(e,t){return I(e,t).map(e=>` ${e.tokens.map(t=>`${e.parentPath}:${t}`).join(`|`)}) return 0 ;;`)}function L(e,t=``,n=``){let r=[];for(let i of N(e.subcommands)){let e=F(n,A(i.name),`_`);for(let n of[i.name,...i.aliases??[]]){let a=F(t,n,`:`);r.push(...L(i,a,e)),r.push({pathStr:a,funcSuffix:e,lookupPattern:`${t}:${n}`})}}return r}function De(e){return e.map(e=>` ${e.lookupPattern}) return 0 ;;`)}function Oe(e,t){return e.map(e=>` ${e.pathStr}) __${t}_complete_${e.funcSuffix} ;;`)}function ke(e,t){let n=e.isGlobal?`_global_arg_values`:`_arg_values`;return t===`bash`?`${n}_${A(e.fieldName)}="$3"`:`${n}[${e.fieldName}]="$3"`}function Ae(e,t){let n=[];for(let r of e){if(r.isPositional||!r.optionTokens||r.optionTokens.length===0)continue;let e=r.pathStrs.flatMap(e=>r.optionTokens.map(t=>`${e}:${t}`)).join(`|`);n.push(` ${e}) ${ke(r,t)} ;;`)}return n}function je(e,t){let n=[];for(let r of e){if(!r.isPositional)continue;let e=r.pathStrs.map(e=>`${e}:${r.position}`).join(`|`);n.push(` ${e}) ${ke(r,t)} ;;`)}return n}function Me(e,t){let n=[];for(let r of e){if(r.optionTokens.length===0)continue;let e=r.pathStrs.flatMap(e=>r.optionTokens.map(t=>`${e}:${t}`)).join(`|`),i=A(r.fieldName),a=r.isGlobal?`_global_used_field_keys`:`_used_field_keys`,o=t===`bash`?`${a}_${i}`:`${a}[${i}]`,s=t===`bash`?`_global_arr_seen_${i}`:`_global_arr_seen[${i}]`,c=`${o}=" $_k "`,l=`${o}+=" $_k "`,u=`${s}=1`;n.push(` ${e})`),n.push(` if [[ "$3" == *=* ]]; then`),n.push(' local _k="${3%%=*}"'),r.isGlobal?(n.push(` if [[ -n "$_k" ]]; then`),n.push(` if [[ -z "\${${s}:-}" ]]; then`),n.push(` ${c}`),n.push(` ${u}`),n.push(` else`),n.push(` ${l}`),n.push(` fi`),n.push(` fi`)):n.push(` [[ -n "$_k" ]] && ${l}`),n.push(` fi`),n.push(` ;;`)}return n}function R(e,t){let n=v(e.cliName,e.alias);if(e.isGlobal===!0){let e=/* @__PURE__ */ new Set;for(let n of t)if(n.isGlobal!==!0)for(let t of p(n.cliName,n.alias))e.add(t);return n.filter(t=>!e.has(t))}let r=ne(t);return r.size===0?n:n.filter(t=>!t.startsWith(`-`)||t.startsWith(`--`)||!r.has(t)?!0:e.alias?.includes(t.slice(1))===!0)}function z(e){let t=[];return Ne(e,[],[``],[],`root`,t),t}function Ne(e,t,n,r,i,a){let o=n[0];for(let s of e.options){let c=s.valueCompletion;if(c?.type===`expand`){let l=s.valueType===`array`;a.push({path:t,pathStr:o,pathStrs:n,intermediatePathStrs:r,funcSuffix:i,fieldName:s.name,isGlobal:s.isGlobal===!0,isPositional:!1,isArrayOption:l,optionTokens:l?R(s,e.options):[],vc:c})}}for(let s of e.positionals){let e=s.valueCompletion;e?.type===`expand`&&a.push({path:t,pathStr:o,pathStrs:n,intermediatePathStrs:r,funcSuffix:i,fieldName:s.name,isGlobal:!1,isPositional:!0,isArrayOption:!1,optionTokens:[],vc:e})}for(let o of N(e.subcommands))Ne(o,[...t,o.name],we(n,o),[...r,...n],i===`root`?A(o.name):`${i}_${A(o.name)}`,a)}function B(e,t,n=[]){let r=Pe(e),i=/* @__PURE__ */ new Map,a=(e,t,n)=>{let r=i.get(e);r||(r={ref:t,pathStrs:[],seen:/* @__PURE__ */ new Set},i.set(e,r));for(let e of n)r.seen.has(e)||(r.seen.add(e),r.pathStrs.push(e))},o=(e,t,n)=>{let i=/* @__PURE__ */ new Map,a=(e,t)=>{if(t.length===0)return;let n=t.join(` `),r=i.get(n);r||(r={tokens:t,paths:[]},i.set(n,r)),r.paths.push(e)};for(let n of t){let t=r.get(n);if(!t)continue;let i=/* @__PURE__ */ new Set;for(let e of t.options)if(e.isGlobal!==!0)for(let t of p(e.cliName,e.alias))i.add(t);a(n,e.filter(e=>!i.has(e)))}for(let t of n)a(t,e);return i},s=(e,t,n)=>{let r=v(t.cliName,t.alias),i=o(r,n.pathStrs,n.intermediatePathStrs);for(let[t,n]of i)a(`g::${e}::${t}`,{fieldName:e,isGlobal:!0,isPositional:!1,optionTokens:n.tokens},n.paths)};for(let e of t){let t=r.get(e.pathStr);if(t)for(let r of e.vc.dependsOn){if(e.isGlobal){let t=n.find(e=>e.name===r);if(!t)continue;s(r,t,e);continue}let i=t.positionals.findIndex(e=>e.name===r);i>=0&&a(`lp::${e.pathStr}::${r}`,{fieldName:r,isGlobal:!1,isPositional:!0,position:i},e.pathStrs);let o=t.options.find(e=>e.name===r);o&&(o.isGlobal===!0?s(r,o,e):a(`lo::${e.pathStr}::${r}`,{fieldName:r,isGlobal:!1,isPositional:!1,optionTokens:R(o,t.options)},e.pathStrs))}}let c=[];for(let e of i.values())e.pathStrs.length!==0&&c.push({...e.ref,pathStr:e.pathStrs[0],pathStrs:e.pathStrs});return c}function Pe(e){let t=/* @__PURE__ */ new Map,n=(e,r)=>{for(let n of r)t.set(n,e);for(let t of N(e.subcommands))n(t,we(r,t))};return n(e,[``]),t}function V(e){for(let t of e.options)if(t.valueCompletion?.type===`dynamic`)return!0;for(let t of e.positionals)if(t.valueCompletion?.type===`dynamic`)return!0;for(let t of e.subcommands)if(V(t))return!0;return!1}function Fe(e,t){let n=new Set(e.options.map(e=>e.name)),r=t.filter(e=>!n.has(e.name));e.options=[...e.options,...r];for(let n of e.subcommands)Fe(n,t)}function H(e,t,r,i=!1){let a=[];if(r){let e=[];a=xe(n(r).fields,e).map(e=>(e.isGlobal=!0,e)),fe({name:t,subcommands:[],options:a,positionals:[]},e,[],i)}let o=Ce(t,e,a,i);return r?Fe(o,a):a=o.options,{command:o,programName:t,globalOptions:a}}function U(e){try{return Math.floor(E(e).mtimeMs/1e3).toString()}catch{return`0`}}function Ie(e){return e.replace(/\r?\n/g,` `)}function Le(e){if(!e||/[/\\\0]/.test(e))return null;let t=process.env.PATH??``;for(let n of t.split(`:`)){if(!n)continue;let t=k(n,e);try{if(E(t).isFile())return t}catch{}}return null}function W(e,t){return t||process.env[j(A(e))]||(Le(e)??process.argv[1]??``)}function G(e){let t=W(e.programName,e.binPath),n=[`# politty-completion-version: 1`,`# politty-bin-sig: ${U(t)}`,`# politty-bin-path: ${Ie(t)}`,`# program: ${e.programName}`];return e.programVersion&&n.push(`# program-version: ${e.programVersion}`),n.push(`# shell: ${e.shell}`),n}function Re(e){let{programName:t,binPath:n}=e,r=A(t),i=j(r),a=W(t,n),o=U(a),s=x(a),c=`__${r}_self_refresh`;return[`${c}() {`,` local _self _bin _sig`," _self=${BASH_SOURCE[0]:-}",` [[ -n "$_self" && -f "$_self" ]] || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qF "# politty-completion-version:" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# program: ${t}" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# shell: bash" || return 1`,` _bin="\${${i}:-$(type -P ${t} 2>/dev/null)}"`,` [[ -n "$_bin" ]] || return 1`,` _sig=${S(`$_bin`,{shell:`posix`})} || return 1`,` [[ "$_sig" != "${o}" || "$_bin" != ${s} ]] || return 1`,` "$_bin" __refresh-completion bash "$_self" --static 2>/dev/null || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-sig: $_sig" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-path: $_bin" || return 1`,` source "$_self" 2>/dev/null || return 1`,` return 0`,`}`,`if ${c}; then`,` unset -f ${c}`,` return 0 2>/dev/null || true`,`else`,` unset -f ${c}`,`fi`,``]}function ze(e){let{programName:t,binPath:n}=e,r=A(t),i=j(r),a=`_${t}`,o=W(t,n),s=U(o),c=x(o),l=`__${r}_self_refresh`;return[`${l}() {`,` emulate -L zsh`,` setopt local_options no_aliases`,` local _self _bin _sig`,' _self="${(%):-%x}"',` [[ -n "$_self" && -f "$_self" ]] || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qF "# politty-completion-version:" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# program: ${t}" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# shell: zsh" || return 1`,` _bin="\${${i}:-$(whence -p ${t} 2>/dev/null)}"`,` [[ -n "$_bin" ]] || return 1`,` _sig=${S(`$_bin`,{shell:`posix`})} || return 1`,` [[ "$_sig" != "${s}" || "$_bin" != ${c} ]] || return 1`,` "$_bin" __refresh-completion zsh "$_self" --static 2>/dev/null || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-sig: $_sig" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-path: $_bin" || return 1`,` source "$_self" 2>/dev/null || return 1`,` ${a} "$@"`,` return 0`,`}`,`if ${l} "$@"; then`,` unfunction ${l} 2>/dev/null`,` return 0 2>/dev/null || true`,`else`,` unfunction ${l} 2>/dev/null`,`fi`,``]}function Be(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\$/g,`\\$`).replace(/`/g,"\\`")}function Ve(e){let t=``,n=new TextEncoder().encode(e);for(let e of n)t+=e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCharCode(e):`_${e.toString(16).toUpperCase().padStart(2,`0`)}`;return t}function He(e,t,n,r){if(!e)return[];switch(e.type){case`expand`:{if(!r)throw Error(`bashValueLines: expand variant requires a location`);let e=M(n,r.funcSuffix,r.fieldName),i=[`local _enc_key='' _enc_v`];r.resolvedDeps.forEach((e,t)=>{let r=A(e.name),a=e.isGlobal?`_global_arg_values_${r}`:`_arg_values_${r}`;i.push(`_enc_v="\${${a}:-}"`),i.push(t===0?`_enc_key="$(__${n}_enc "$_enc_v")"`:`_enc_key+="_$(__${n}_enc "$_enc_v")"`)});let a=t?'"${_inline_prefix}${_c}"':`"$_c"`,o=r.isGlobal?`\${_global_used_field_keys_${A(r.fieldName)}:-}`:`\${_used_field_keys_${A(r.fieldName)}:-}`,s=r.isArrayOption?[` if [[ -n "$_ck" && " ${o} " == *" $_ck "* ]]; then continue; fi`]:[];return[`compopt +o default 2>/dev/null`,...i,`local _varname=${e}__\${_enc_key}`,'local _raw="${!_varname:-}"',`if [[ -n "$_raw" ]]; then`,` local -a _vals=()`,` local _line`,` while IFS= read -r _line; do _vals+=("$_line"); done <<< "$_raw"`,` local _c _ck _seen_keys=" " _had_key=0`,' for _c in "${_vals[@]}"; do',` [[ -z "$_c" ]] && continue`,` if [[ "$_c" == *=* ]]; then`,' _ck="${_c%%=*}"',...s,` if [[ "$_cur" != *=* ]]; then`,` [[ "$_seen_keys" == *" $_ck "* ]] && continue`,` _seen_keys+="$_ck "`,' _c="${_ck}="',` _had_key=1`,` elif [[ "$_c" != *=?* ]]; then`,` continue`,` fi`,` fi`,` [[ "$_c" == "$_cur"* ]] && COMPREPLY+=(${a})`,` done`,` if (( _had_key )); then compopt -o nospace 2>/dev/null; fi`,`fi`,'if (( ${#COMPREPLY[@]} == 0 )); then COMPREPLY=( "" ); fi']}case`dynamic`:return[`local _dyn_out`,`_dyn_out=$(__${n}_invoke_complete bash "\${_words[@]}")`,`__${n}_apply_dynamic_output "$_dyn_out"`];case`choices`:{let n=[`local -a _choices=(${e.choices.map(e=>`"${Be(e)}"`).join(` `)})`,`COMPREPLY=()`,'local _c; for _c in "${_choices[@]}"; do [[ "$_c" == "$_cur"* ]] && COMPREPLY+=("${_inline_prefix}${_c}"); done'];return t&&n.push(`compopt -o nospace`),n.push(`compopt +o default 2>/dev/null`),n}case`file`:return e.matcher?.length?Ue(e.matcher.map(e=>`[[ "\${_f##*/}" == ${e} ]]`).join(` || `)):e.extensions?.length?Ue(e.extensions.map(e=>`[[ "$_f" == *".${e}" ]]`).join(` || `)):[`COMPREPLY=($(compgen -P "$_inline_prefix" -f -- "$_cur"))`,`compopt -o filenames`];case`directory`:return[`COMPREPLY=($(compgen -P "$_inline_prefix" -d -- "$_cur"))`,`compopt -o filenames`];case`command`:return[`COMPREPLY=($(compgen -P "$_inline_prefix" -W "$(${e.shellCommand})" -- "$_cur"))`];case`none`:return[`compopt +o default 2>/dev/null`];case`runtime-expand`:return[]}}function K(e){return`unset $(compgen -v ${e} 2>/dev/null) 2>/dev/null`}function Ue(e){return[`local -a _all_entries=($(compgen -f -- "$_cur"))`,'for _f in "${_all_entries[@]}"; do',` if [[ -d "$_f" ]]; then`,' COMPREPLY+=("${_inline_prefix}$_f")',` elif ${e}; then`,' COMPREPLY+=("${_inline_prefix}$_f")',` fi`,`done`,`compopt -o filenames`,`compopt +o default 2>/dev/null`]}function We(e,t,n,r,i){let a=[];for(let o of e){if(!o.takesValue||!o.valueCompletion)continue;let s=He(o.valueCompletion,n,r,{funcSuffix:i,...b(o,e,t)});if(s.length===0)continue;let c=R(o,e);if(c.length!==0){a.push(` ${c.join(`|`)})`);for(let e of s)a.push(` ${e}`);a.push(` return ;;`)}}return a}function q(e,t,n,r=[]){if(e.length===0)return[];let i=g(e,r,t),a=[...i??[]];a.push(` case "${i?`$_slot`:`$_pos_count`}" in`);for(let o of e){o.variadic&&!i?a.push(` ${o.position}|*)`):a.push(` ${o.position})`);for(let i of He(o.valueCompletion,!1,t,{funcSuffix:n,...y(o,r,e)}))a.push(` ${i}`);a.push(` ;;`)}return a.push(` esac`),a}function Ge(e,t,n,r,i){let a=[`COMPREPLY=($(compgen -W "${e}" -- "$_cur"))`,`compopt +o default 2>/dev/null`];return t.length===0?a:[`local -a _sub_names=(${e})`,`local _sub_name _sub_match=0`,'for _sub_name in "${_sub_names[@]}"; do',` [[ "$_sub_name" == "$_cur"* ]] && _sub_match=1 && break`,`done`,`if (( _sub_match )); then`,...a.map(e=>` ${e}`),`else`,...q(t,n,r,i),`fi`]}function Ke(e,t,n,r){if(!e.some(e=>e.takesValue&&e.valueCompletion))return[];let i=[],a=We(e,t,!1,n,r);a.length>0&&(i.push(` if [[ -z "$_inline_prefix" ]]; then`),i.push(` case "$_prev" in`),i.push(...a),i.push(` esac`),i.push(` fi`));let o=We(e,t,!0,n,r);return o.length>0&&(i.push(` if [[ -n "$_inline_prefix" ]]; then`),i.push(' case "${_inline_prefix%=}" in'),i.push(...o),i.push(` esac`),i.push(` fi`)),i}function qe(e,t){let n=[];for(let r of e){if(r.valueType===`array`){n.push(` _avail+=(--${r.cliName})`);continue}let i=d(r.cliName,r.alias,r.negation,{isGlobal:r.isGlobal===!0,frameOptions:e}),a=`__${t}_not_used ${i.join(` `)}`,o=r.negation?[r.cliName,r.negation]:[r.cliName];for(let e of o)i.includes(`"--${e}"`)&&n.push(` ${a} && _avail+=(--${e})`)}return n.push(` if (( ! _any_opt_used )); then`),n.push(` _avail+=(--help --help-all --help-json)`),n.push(` fi`),n}function Je(e,t,n){let r=[...n,e.name],i=r.map(A).join(`_`),a=`__${t}_complete_${i}`,o=N(e.subcommands),s=[];for(let e of o)s.push(...Je(e,t,r));s.push(`${a}() {`),s.push(...Ke(e.options,e.positionals,t,i));let c=r.join(`:`);if(s.push(` if [[ -z "$_inline_prefix" ]] && __${t}_opt_takes_value "${c}" "$_prev"; then return; fi`),s.push(` if [[ -n "$_inline_prefix" ]] && __${t}_opt_takes_value "${c}" "\${_inline_prefix%=}"; then return; fi`),e.positionals.length>0?(s.push(` if (( _after_dd )); then`),s.push(...q(e.positionals,t,i,e.options).map(e=>` ${e}`)),s.push(` return`),s.push(` fi`)):s.push(` if (( _after_dd )); then return; fi`),s.push(` if [[ "$_cur" == -* ]]; then`),s.push(` local -a _avail=()`),s.push(...qe(e.options,t)),s.push(' COMPREPLY=($(compgen -W "${_avail[*]}" -- "$_cur"))'),s.push(` compopt +o default 2>/dev/null`),s.push(` return`),s.push(` fi`),o.length>0){let n=P(e.subcommands).map(e=>e.name).join(` `);s.push(...Ge(n,e.positionals,t,i,e.options).map(e=>` ${e}`))}else e.positionals.length>0&&s.push(...q(e.positionals,t,i,e.options));return s.push(`}`),s.push(``),s}function Ye(e,t){let{programName:n}=t,r=H(e,n,t.globalArgsSchema),i=A(n),a=t.staticWorker?`${i}_${A(t.staticWorker.functionSuffix)}`:i,o=t.staticWorker!==void 0,s=r.command,c=N(s.subcommands),l=z(s),u=B(s,l,r.globalOptions),d=[];d.push(...G({programName:n,shell:`bash`,binPath:t.binPath,programVersion:t.programVersion})),d.push(`# politty-completion-mode: ${o?`worker`:`static`}`),o&&d.push(`# politty-completion-worker: true`),d.push(`# Generated by politty`),d.push(``),o||d.push(...Re({programName:n,binPath:t.binPath}));let p=l.length>0,m=l.filter(e=>e.isArrayOption),g=m.length>0;p&&(d.push(`__${a}_enc() {`),d.push(` local LC_ALL=C`),d.push(` local _s=$1 _r='' _c _i`),d.push(" for (( _i=0; _i<${#_s}; _i++ )); do"),d.push(" _c=${_s:_i:1}"),d.push(` case "$_c" in`),d.push(` [a-zA-Z0-9]) _r+="$_c" ;;`),d.push(` *) printf -v _r '%s_%02X' "$_r" "'$_c" ;;`),d.push(` esac`),d.push(` done`),d.push(` printf '%s' "$_r"`),d.push(`}`),d.push(``));for(let e of l){let t=M(a,e.funcSuffix,e.fieldName);for(let n of e.vc.table){let e=n.key.map(Ve).join(`_`),r=n.candidates.map(e=>e.value).join(`
1
+ import{a as e,c as t,n}from"./schema-extractor-Cwg_WAC-.js";import{n as r}from"./command-BXsTrIgI.js";import{c as i}from"./subcommand-router-40vA6Mka.js";import{a,i as o,n as s,o as c,r as l,s as u}from"./with-completion-command-DkZmjiSe.js";import{_ as d,c as f,d as p,f as m,g as h,h as g,i as _,l as v,m as y,p as b,s as ee,t as te,u as ne,v as x,y as S}from"./dynamic-CvUL5rZa.js";import{existsSync as C,mkdirSync as re,readFileSync as w,realpathSync as T,renameSync as ie,rmSync as ae,statSync as E,writeFileSync as oe}from"node:fs";import{dirname as D,extname as se,isAbsolute as O,join as k,relative as ce,resolve as le}from"node:path";import{promisify as ue}from"node:util";import{execFile as de}from"node:child_process";function fe(e,t,n=[],r=!1){if(t.length===0)return;let i=pe(e,n);for(let e of t)e.set(me(e,i,r))}function pe(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Set;for(let t of[...e.options,...e.positionals])r.add(t.name);let i=(e,t)=>{for(let i of e){if(n.has(i.name)||t&&r.has(i.name))continue;let e=i.valueCompletion;e?.type===`choices`&&e.choices&&e.choices.length>0&&n.set(i.name,e.choices)}};return i([...e.options,...e.positionals],!1),i(t,!0),n}function me(e,t,n=!1){let{spec:r}=e,i=r.dependsOn;if(i.length===0)throw Error(`Field "${e.describe}": completion.custom.expand.dependsOn must list at least one sibling arg.`);let a=[];for(let n of i){if(n===e.name)throw Error(`Field "${e.describe}": completion.custom.expand.dependsOn cannot reference the field itself ("${n}").`);let r=t.get(n);if(!r)throw Error(`Field "${e.describe}": completion.custom.expand.dependsOn references "${n}", which is not a sibling arg with a static \`choices\`/enum schema on the same command. Chaining expand specs is not supported.`);a.push([...r])}if(n)return{type:`expand`,dependsOn:i,table:[]};let o=[];for(let t of ge(a)){let n={};i.forEach((e,r)=>{n[e]=t[r]});let a;try{a=r.enumerate(n)}catch(t){let r=t instanceof Error?t.message:String(t);throw Error(`Field "${e.describe}": completion.custom.expand.enumerate threw for deps=${JSON.stringify(n)}: ${r}`)}let s=he(a);s.length!==0&&o.push({key:t,candidates:s})}return{type:`expand`,dependsOn:i,table:o}}function he(e){let t=[],n=/* @__PURE__ */ new Set;for(let r of e){let e=typeof r==`string`?r:r.value;if(n.has(e))continue;n.add(e);let i={value:e};typeof r!=`string`&&r.description!==void 0&&(i.description=r.description),t.push(i)}return t}function*ge(e){if(e.length===0){yield[];return}let t=Array.from({length:e.length}).fill(0);for(;;){yield t.map((t,n)=>e[n][t]);let n=e.length-1;for(;n>=0&&(t[n]++,!(t[n]<e[n].length));)t[n]=0,n--;if(n<0)return}}function _e(e,t,n,r){let i=ee(e);i?.type===`pending-expand`?t.push({name:e.name,describe:n,set:r,spec:i.spec}):i!==void 0&&r(i)}function A(e){return e.replace(/[^a-zA-Z0-9_]/g,`_`)}function j(e){let t=e.toUpperCase();return/^[A-Z_]/.test(t)?`${t}_BIN`:`_${t}_BIN`}function M(e,t,n){return`__${e}_expand_${t}__${A(n)}`}function ve(e,t){return[`__${e}_invoke_complete() {`,` local _shell="$1"; shift`,` "\${${j(e)}:-${t}}" __complete --shell "$_shell" -- "$@" 2>/dev/null`,`}`]}function N(e){return e.filter(e=>!e.name.startsWith(`__`))}function P(e){let t=[];for(let n of N(e))if(t.push({name:n.name,description:n.description}),n.aliases)for(let e of n.aliases)t.push({name:e,description:n.description});return t}function ye(e,t){let n=e.type===`boolean`&&e.negation===!0,r={name:e.name,cliName:e.cliName,alias:e.alias,negation:e.negationDisplay,negationDescription:e.negationDescription,description:e.description,takesValue:e.type!==`boolean`,valueType:e.type,required:e.required,defaultNegationAccepted:n};return _e(e,t,`--${e.cliName}`,e=>{r.valueCompletion=e}),r}function be(e){return e.args?t(n(e.args)):[]}function xe(e,t){return e.filter(e=>e.named).map(e=>ye(e,t))}function Se(e,t){return e.filter(e=>e.positional).map((e,n)=>{let r={name:e.name,cliName:e.cliName,position:n,description:e.description,required:e.required,variadic:e.type===`array`};return _e(e,t,`<${e.cliName}>`,e=>{r.valueCompletion=e}),r})}function Ce(r,a,o=[],s=!1){let c=[];if(a.subCommands)for(let[e,t]of Object.entries(a.subCommands)){let n=i(t);n?c.push(Ce(e,n,o,s)):c.push({name:e,description:`(lazy loaded)`,subcommands:[],options:[],positionals:[]})}let l=[],u=a.args?n(a.args):void 0,d={name:r,description:a.description,aliases:a.aliases,subcommands:c,options:xe(u?e(u):[],l),positionals:Se(u?t(u):[],l)};return fe(d,l,o,s),d}function F(e,t,n){return e?`${e}${n}${t}`:t}function we(e,t){let n=[t.name,...t.aliases??[]];return e.flatMap(e=>n.map(t=>F(e,t,`:`)))}function Te(e){let t=[],n=(e,r)=>{let i=new Set(e.options.filter(e=>e.isGlobal!==!0).map(e=>e.name));e.positionals.some(e=>i.has(e.name))&&t.push({pathStrs:r,positionals:e.positionals,options:e.options});for(let t of N(e.subcommands))n(t,we(r,t))};return n(e,[``]),t}function I(e,t){let n=[],r=N(e.subcommands).length>0;for(let i of e.options){if(!i.takesValue)continue;let a=r&&i.isGlobal===!0?v(i.cliName,i.alias):R(i,e.options);a.length!==0&&n.push({parentPath:t,tokens:a})}for(let r of N(e.subcommands))for(let e of[r.name,...r.aliases??[]])n.push(...I(r,F(t,e,`:`)));return n}function Ee(e,t){return I(e,t).map(e=>` ${e.tokens.map(t=>`${e.parentPath}:${t}`).join(`|`)}) return 0 ;;`)}function L(e,t=``,n=``){let r=[];for(let i of N(e.subcommands)){let e=F(n,A(i.name),`_`);for(let n of[i.name,...i.aliases??[]]){let a=F(t,n,`:`);r.push(...L(i,a,e)),r.push({pathStr:a,funcSuffix:e,lookupPattern:`${t}:${n}`})}}return r}function De(e){return e.map(e=>` ${e.lookupPattern}) return 0 ;;`)}function Oe(e,t){return e.map(e=>` ${e.pathStr}) __${t}_complete_${e.funcSuffix} ;;`)}function ke(e,t){let n=e.isGlobal?`_global_arg_values`:`_arg_values`;return t===`bash`?`${n}_${A(e.fieldName)}="$3"`:`${n}[${e.fieldName}]="$3"`}function Ae(e,t){let n=[];for(let r of e){if(r.isPositional||!r.optionTokens||r.optionTokens.length===0)continue;let e=r.pathStrs.flatMap(e=>r.optionTokens.map(t=>`${e}:${t}`)).join(`|`);n.push(` ${e}) ${ke(r,t)} ;;`)}return n}function je(e,t){let n=[];for(let r of e){if(!r.isPositional)continue;let e=r.pathStrs.map(e=>`${e}:${r.position}`).join(`|`);n.push(` ${e}) ${ke(r,t)} ;;`)}return n}function Me(e,t){let n=[];for(let r of e){if(r.optionTokens.length===0)continue;let e=r.pathStrs.flatMap(e=>r.optionTokens.map(t=>`${e}:${t}`)).join(`|`),i=A(r.fieldName),a=r.isGlobal?`_global_used_field_keys`:`_used_field_keys`,o=t===`bash`?`${a}_${i}`:`${a}[${i}]`,s=t===`bash`?`_global_arr_seen_${i}`:`_global_arr_seen[${i}]`,c=`${o}=" $_k "`,l=`${o}+=" $_k "`,u=`${s}=1`;n.push(` ${e})`),n.push(` if [[ "$3" == *=* ]]; then`),n.push(' local _k="${3%%=*}"'),r.isGlobal?(n.push(` if [[ -n "$_k" ]]; then`),n.push(` if [[ -z "\${${s}:-}" ]]; then`),n.push(` ${c}`),n.push(` ${u}`),n.push(` else`),n.push(` ${l}`),n.push(` fi`),n.push(` fi`)):n.push(` [[ -n "$_k" ]] && ${l}`),n.push(` fi`),n.push(` ;;`)}return n}function R(e,t){let n=v(e.cliName,e.alias);if(e.isGlobal===!0){let e=/* @__PURE__ */ new Set;for(let n of t)if(n.isGlobal!==!0)for(let t of p(n.cliName,n.alias))e.add(t);return n.filter(t=>!e.has(t))}let r=ne(t);return r.size===0?n:n.filter(t=>!t.startsWith(`-`)||t.startsWith(`--`)||!r.has(t)?!0:e.alias?.includes(t.slice(1))===!0)}function z(e){let t=[];return Ne(e,[],[``],[],`root`,t),t}function Ne(e,t,n,r,i,a){let o=n[0];for(let s of e.options){let c=s.valueCompletion;if(c?.type===`expand`){let l=s.valueType===`array`;a.push({path:t,pathStr:o,pathStrs:n,intermediatePathStrs:r,funcSuffix:i,fieldName:s.name,isGlobal:s.isGlobal===!0,isPositional:!1,isArrayOption:l,optionTokens:l?R(s,e.options):[],vc:c})}}for(let s of e.positionals){let e=s.valueCompletion;e?.type===`expand`&&a.push({path:t,pathStr:o,pathStrs:n,intermediatePathStrs:r,funcSuffix:i,fieldName:s.name,isGlobal:!1,isPositional:!0,isArrayOption:!1,optionTokens:[],vc:e})}for(let o of N(e.subcommands))Ne(o,[...t,o.name],we(n,o),[...r,...n],i===`root`?A(o.name):`${i}_${A(o.name)}`,a)}function B(e,t,n=[]){let r=Pe(e),i=/* @__PURE__ */ new Map,a=(e,t,n)=>{let r=i.get(e);r||(r={ref:t,pathStrs:[],seen:/* @__PURE__ */ new Set},i.set(e,r));for(let e of n)r.seen.has(e)||(r.seen.add(e),r.pathStrs.push(e))},o=(e,t,n)=>{let i=/* @__PURE__ */ new Map,a=(e,t)=>{if(t.length===0)return;let n=t.join(` `),r=i.get(n);r||(r={tokens:t,paths:[]},i.set(n,r)),r.paths.push(e)};for(let n of t){let t=r.get(n);if(!t)continue;let i=/* @__PURE__ */ new Set;for(let e of t.options)if(e.isGlobal!==!0)for(let t of p(e.cliName,e.alias))i.add(t);a(n,e.filter(e=>!i.has(e)))}for(let t of n)a(t,e);return i},s=(e,t,n)=>{let r=v(t.cliName,t.alias),i=o(r,n.pathStrs,n.intermediatePathStrs);for(let[t,n]of i)a(`g::${e}::${t}`,{fieldName:e,isGlobal:!0,isPositional:!1,optionTokens:n.tokens},n.paths)};for(let e of t){let t=r.get(e.pathStr);if(t)for(let r of e.vc.dependsOn){if(e.isGlobal){let t=n.find(e=>e.name===r);if(!t)continue;s(r,t,e);continue}let i=t.positionals.findIndex(e=>e.name===r);i>=0&&a(`lp::${e.pathStr}::${r}`,{fieldName:r,isGlobal:!1,isPositional:!0,position:i},e.pathStrs);let o=t.options.find(e=>e.name===r);o&&(o.isGlobal===!0?s(r,o,e):a(`lo::${e.pathStr}::${r}`,{fieldName:r,isGlobal:!1,isPositional:!1,optionTokens:R(o,t.options)},e.pathStrs))}}let c=[];for(let e of i.values())e.pathStrs.length!==0&&c.push({...e.ref,pathStr:e.pathStrs[0],pathStrs:e.pathStrs});return c}function Pe(e){let t=/* @__PURE__ */ new Map,n=(e,r)=>{for(let n of r)t.set(n,e);for(let t of N(e.subcommands))n(t,we(r,t))};return n(e,[``]),t}function V(e){for(let t of e.options)if(t.valueCompletion?.type===`dynamic`)return!0;for(let t of e.positionals)if(t.valueCompletion?.type===`dynamic`)return!0;for(let t of e.subcommands)if(V(t))return!0;return!1}function Fe(e,t){let n=new Set(e.options.map(e=>e.name)),r=t.filter(e=>!n.has(e.name));e.options=[...e.options,...r];for(let n of e.subcommands)Fe(n,t)}function H(e,t,r,i=!1){let a=[];if(r){let e=[];a=xe(n(r).fields,e).map(e=>(e.isGlobal=!0,e)),fe({name:t,subcommands:[],options:a,positionals:[]},e,[],i)}let o=Ce(t,e,a,i);return r?Fe(o,a):a=o.options,{command:o,programName:t,globalOptions:a}}function U(e){try{return Math.floor(E(e).mtimeMs/1e3).toString()}catch{return`0`}}function Ie(e){return e.replace(/\r?\n/g,` `)}function Le(e){if(!e||/[/\\\0]/.test(e))return null;let t=process.env.PATH??``;for(let n of t.split(`:`)){if(!n)continue;let t=k(n,e);try{if(E(t).isFile())return t}catch{}}return null}function W(e,t){return t||process.env[j(A(e))]||(Le(e)??process.argv[1]??``)}function G(e){let t=W(e.programName,e.binPath),n=[`# politty-completion-version: 1`,`# politty-bin-sig: ${U(t)}`,`# politty-bin-path: ${Ie(t)}`,`# program: ${e.programName}`];return e.programVersion&&n.push(`# program-version: ${e.programVersion}`),n.push(`# shell: ${e.shell}`),n}function Re(e){let{programName:t,binPath:n}=e,r=A(t),i=j(r),a=W(t,n),o=U(a),s=x(a),c=`__${r}_self_refresh`;return[`${c}() {`,` local _self _bin _sig`," _self=${BASH_SOURCE[0]:-}",` [[ -n "$_self" && -f "$_self" ]] || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qF "# politty-completion-version:" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# program: ${t}" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# shell: bash" || return 1`,` _bin="\${${i}:-$(type -P ${t} 2>/dev/null)}"`,` [[ -n "$_bin" ]] || return 1`,` _sig=${S(`$_bin`,{shell:`posix`})} || return 1`,` [[ "$_sig" != "${o}" || "$_bin" != ${s} ]] || return 1`,` "$_bin" __refresh-completion bash "$_self" --static 2>/dev/null || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-sig: $_sig" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-path: $_bin" || return 1`,` source "$_self" 2>/dev/null || return 1`,` return 0`,`}`,`if ${c}; then`,` unset -f ${c}`,` return 0 2>/dev/null || true`,`else`,` unset -f ${c}`,`fi`,``]}function ze(e){let{programName:t,binPath:n}=e,r=A(t),i=j(r),a=`_${t}`,o=W(t,n),s=U(o),c=x(o),l=`__${r}_self_refresh`;return[`${l}() {`,` emulate -L zsh`,` setopt local_options no_aliases`,` local _self _bin _sig`,' _self="${(%):-%x}"',` [[ -n "$_self" && -f "$_self" ]] || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qF "# politty-completion-version:" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# program: ${t}" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# shell: zsh" || return 1`,` _bin="\${${i}:-$(whence -p ${t} 2>/dev/null)}"`,` [[ -n "$_bin" ]] || return 1`,` _sig=${S(`$_bin`,{shell:`posix`})} || return 1`,` [[ "$_sig" != "${s}" || "$_bin" != ${c} ]] || return 1`,` "$_bin" __refresh-completion zsh "$_self" --static 2>/dev/null || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-sig: $_sig" || return 1`,` head -n 8 "$_self" 2>/dev/null | grep -qxF "# politty-bin-path: $_bin" || return 1`,` source "$_self" 2>/dev/null || return 1`,` ${a} "$@"`,` return 0`,`}`,`if ${l} "$@"; then`,` unfunction ${l} 2>/dev/null`,` return 0 2>/dev/null || true`,`else`,` unfunction ${l} 2>/dev/null`,`fi`,``]}function Be(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\$/g,`\\$`).replace(/`/g,"\\`")}function Ve(e){let t=``,n=new TextEncoder().encode(e);for(let e of n)t+=e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCharCode(e):`_${e.toString(16).toUpperCase().padStart(2,`0`)}`;return t}function He(e,t,n,r){if(!e)return[];switch(e.type){case`expand`:{if(!r)throw Error(`bashValueLines: expand variant requires a location`);let e=M(n,r.funcSuffix,r.fieldName),i=[`local _enc_key='' _enc_v`];r.resolvedDeps.forEach((e,t)=>{let r=A(e.name),a=e.isGlobal?`_global_arg_values_${r}`:`_arg_values_${r}`;i.push(`_enc_v="\${${a}:-}"`),i.push(t===0?`_enc_key="$(__${n}_enc "$_enc_v")"`:`_enc_key+="_$(__${n}_enc "$_enc_v")"`)});let a=t?'"${_inline_prefix}${_c}"':`"$_c"`,o=r.isGlobal?`\${_global_used_field_keys_${A(r.fieldName)}:-}`:`\${_used_field_keys_${A(r.fieldName)}:-}`,s=r.isArrayOption?[` if [[ -n "$_ck" && " ${o} " == *" $_ck "* ]]; then continue; fi`]:[];return[`compopt +o default 2>/dev/null`,...i,`local _varname=${e}__\${_enc_key}`,'local _raw="${!_varname:-}"',`if [[ -n "$_raw" ]]; then`,` local -a _vals=()`,` local _line`,` while IFS= read -r _line; do _vals+=("$_line"); done <<< "$_raw"`,` local _c _ck _seen_keys=" " _had_key=0`,' for _c in "${_vals[@]}"; do',` [[ -z "$_c" ]] && continue`,` if [[ "$_c" == *=* ]]; then`,' _ck="${_c%%=*}"',...s,` if [[ "$_cur" != *=* ]]; then`,` [[ "$_seen_keys" == *" $_ck "* ]] && continue`,` _seen_keys+="$_ck "`,' _c="${_ck}="',` _had_key=1`,` elif [[ "$_c" != *=?* ]]; then`,` continue`,` fi`,` fi`,` [[ "$_c" == "$_cur"* ]] && COMPREPLY+=(${a})`,` done`,` if (( _had_key )); then compopt -o nospace 2>/dev/null; fi`,`fi`,'if (( ${#COMPREPLY[@]} == 0 )); then COMPREPLY=( "" ); fi']}case`dynamic`:return[`local _dyn_out`,`_dyn_out=$(__${n}_invoke_complete bash "\${_words[@]}")`,`__${n}_apply_dynamic_output "$_dyn_out"`];case`choices`:{let n=[`local -a _choices=(${e.choices.map(e=>`"${Be(e)}"`).join(` `)})`,`COMPREPLY=()`,'local _c; for _c in "${_choices[@]}"; do [[ "$_c" == "$_cur"* ]] && COMPREPLY+=("${_inline_prefix}${_c}"); done'];return t&&n.push(`compopt -o nospace`),n.push(`compopt +o default 2>/dev/null`),n}case`file`:return e.matcher?.length?Ue(e.matcher.map(e=>`[[ "\${_f##*/}" == ${e} ]]`).join(` || `)):e.extensions?.length?Ue(e.extensions.map(e=>`[[ "$_f" == *".${e}" ]]`).join(` || `)):[`COMPREPLY=($(compgen -P "$_inline_prefix" -f -- "$_cur"))`,`compopt -o filenames`];case`directory`:return[`COMPREPLY=($(compgen -P "$_inline_prefix" -d -- "$_cur"))`,`compopt -o filenames`];case`command`:return[`COMPREPLY=($(compgen -P "$_inline_prefix" -W "$(${e.shellCommand})" -- "$_cur"))`];case`none`:return[`compopt +o default 2>/dev/null`];case`runtime-expand`:return[]}}function K(e){return`unset $(compgen -v ${e} 2>/dev/null) 2>/dev/null`}function Ue(e){return[`local -a _all_entries=($(compgen -f -- "$_cur"))`,'for _f in "${_all_entries[@]}"; do',` if [[ -d "$_f" ]]; then`,' COMPREPLY+=("${_inline_prefix}$_f")',` elif ${e}; then`,' COMPREPLY+=("${_inline_prefix}$_f")',` fi`,`done`,`compopt -o filenames`,`compopt +o default 2>/dev/null`]}function We(e,t,n,r,i){let a=[];for(let o of e){if(!o.takesValue||!o.valueCompletion)continue;let s=He(o.valueCompletion,n,r,{funcSuffix:i,...b(o,e,t)});if(s.length===0)continue;let c=R(o,e);if(c.length!==0){a.push(` ${c.join(`|`)})`);for(let e of s)a.push(` ${e}`);a.push(` return ;;`)}}return a}function q(e,t,n,r=[]){if(e.length===0)return[];let i=g(e,r,t),a=[...i??[]];a.push(` case "${i?`$_slot`:`$_pos_count`}" in`);for(let o of e){o.variadic&&!i?a.push(` ${o.position}|*)`):a.push(` ${o.position})`);for(let i of He(o.valueCompletion,!1,t,{funcSuffix:n,...y(o,r,e)}))a.push(` ${i}`);a.push(` ;;`)}return a.push(` esac`),a}function Ge(e,t,n,r,i){let a=[`COMPREPLY=($(compgen -W "${e}" -- "$_cur"))`,`compopt +o default 2>/dev/null`];return t.length===0?a:[`local -a _sub_names=(${e})`,`local _sub_name _sub_match=0`,'for _sub_name in "${_sub_names[@]}"; do',` [[ "$_sub_name" == "$_cur"* ]] && _sub_match=1 && break`,`done`,`if (( _sub_match )); then`,...a.map(e=>` ${e}`),`else`,...q(t,n,r,i),`fi`]}function Ke(e,t,n,r){if(!e.some(e=>e.takesValue&&e.valueCompletion))return[];let i=[],a=We(e,t,!1,n,r);a.length>0&&(i.push(` if [[ -z "$_inline_prefix" ]]; then`),i.push(` case "$_prev" in`),i.push(...a),i.push(` esac`),i.push(` fi`));let o=We(e,t,!0,n,r);return o.length>0&&(i.push(` if [[ -n "$_inline_prefix" ]]; then`),i.push(' case "${_inline_prefix%=}" in'),i.push(...o),i.push(` esac`),i.push(` fi`)),i}function qe(e,t){let n=[];for(let r of e){if(r.valueType===`array`){n.push(` _avail+=(--${r.cliName})`);continue}let i=d(r.cliName,r.alias,r.negation,{isGlobal:r.isGlobal===!0,frameOptions:e}),a=`__${t}_not_used ${i.join(` `)}`,o=r.negation?[r.cliName,r.negation]:[r.cliName];for(let e of o)i.includes(`"--${e}"`)&&n.push(` ${a} && _avail+=(--${e})`)}return n.push(` if (( ! _any_opt_used )); then`),n.push(` _avail+=(--help --help-all --help-json)`),n.push(` fi`),n}function Je(e,t,n){let r=[...n,e.name],i=r.map(A).join(`_`),a=`__${t}_complete_${i}`,o=N(e.subcommands),s=[];for(let e of o)s.push(...Je(e,t,r));s.push(`${a}() {`),s.push(...Ke(e.options,e.positionals,t,i));let c=r.join(`:`);if(s.push(` if [[ -z "$_inline_prefix" ]] && __${t}_opt_takes_value "${c}" "$_prev"; then return; fi`),s.push(` if [[ -n "$_inline_prefix" ]] && __${t}_opt_takes_value "${c}" "\${_inline_prefix%=}"; then return; fi`),e.positionals.length>0?(s.push(` if (( _after_dd )); then`),s.push(...q(e.positionals,t,i,e.options).map(e=>` ${e}`)),s.push(` return`),s.push(` fi`)):s.push(` if (( _after_dd )); then return; fi`),s.push(` if [[ "$_cur" == -* ]]; then`),s.push(` local -a _avail=()`),s.push(...qe(e.options,t)),s.push(' COMPREPLY=($(compgen -W "${_avail[*]}" -- "$_cur"))'),s.push(` compopt +o default 2>/dev/null`),s.push(` return`),s.push(` fi`),o.length>0){let n=P(e.subcommands).map(e=>e.name).join(` `);s.push(...Ge(n,e.positionals,t,i,e.options).map(e=>` ${e}`))}else e.positionals.length>0&&s.push(...q(e.positionals,t,i,e.options));return s.push(`}`),s.push(``),s}function Ye(e,t){let{programName:n}=t,r=H(e,n,t.globalArgsSchema),i=A(n),a=t.staticWorker?`${i}_${A(t.staticWorker.functionSuffix)}`:i,o=t.staticWorker!==void 0,s=r.command,c=N(s.subcommands),l=z(s),u=B(s,l,r.globalOptions),d=[];d.push(...G({programName:n,shell:`bash`,binPath:t.binPath,programVersion:t.programVersion})),d.push(`# politty-completion-mode: ${o?`worker`:`static`}`),o&&d.push(`# politty-completion-worker: true`),d.push(`# Generated by politty`),d.push(``),o||d.push(...Re({programName:n,binPath:t.binPath}));let p=l.length>0,m=l.filter(e=>e.isArrayOption),g=m.length>0;p&&(d.push(`__${a}_enc() {`),d.push(` local LC_ALL=C`),d.push(` local _s=$1 _r='' _c _i`),d.push(" for (( _i=0; _i<${#_s}; _i++ )); do"),d.push(" _c=${_s:_i:1}"),d.push(` case "$_c" in`),d.push(` [a-zA-Z0-9]) _r+="$_c" ;;`),d.push(` *) printf -v _r '%s_%02X' "$_r" "'$_c" ;;`),d.push(` esac`),d.push(` done`),d.push(` printf '%s' "$_r"`),d.push(`}`),d.push(``));for(let e of l){let t=M(a,e.funcSuffix,e.fieldName);for(let n of e.vc.table){let e=n.key.map(Ve).join(`_`),r=n.candidates.map(e=>e.value).join(`
2
2
  `);d.push(`${t}__${e}=${f(r)}`)}d.push(``)}V(s)&&(d.push(...ve(a,n)),d.push(``),d.push(`__${a}_apply_dynamic_output() {`),d.push(` local _raw="$1"`),d.push(` COMPREPLY=()`),d.push(` local _directive=0`),d.push(` local -a _lines=()`),d.push(` local _line`),d.push(` while IFS= read -r _line; do _lines+=("$_line"); done <<< "$_raw"`),d.push(" local _last=$((${#_lines[@]} - 1))"),d.push(' if (( _last >= 0 )) && [[ "${_lines[$_last]}" =~ ^:[0-9]+$ ]]; then'),d.push(' _directive="${_lines[$_last]#:}"'),d.push(` unset '_lines[_last]'`),d.push(` fi`),d.push(' for _line in "${_lines[@]}"; do'),d.push(` [[ -z "$_line" ]] && continue`),d.push(` COMPREPLY+=("$_line")`),d.push(` done`),d.push(' local _ip="${_inline_prefix:-}"'),d.push(` if (( _directive & ${_.DirectoryCompletion} )); then`),d.push(` compopt +o default 2>/dev/null`),d.push(` compopt -o filenames 2>/dev/null`),d.push(` local _d`),d.push(' while IFS= read -r _d; do COMPREPLY+=("${_ip}${_d}"); done < <(compgen -d -- "$_cur")'),d.push(' if (( ${#COMPREPLY[@]} == 0 )); then COMPREPLY=( "" ); fi'),d.push(` elif (( _directive & ${_.FileCompletion} )); then`),d.push(' if (( ${#COMPREPLY[@]} > 0 )) || [[ -n "$_ip" ]]; then'),d.push(` compopt -o filenames 2>/dev/null`),d.push(` local _f`),d.push(' while IFS= read -r _f; do COMPREPLY+=("${_ip}${_f}"); done < <(compgen -f -- "$_cur")'),d.push(` else`),d.push(` compopt -o default 2>/dev/null`),d.push(` fi`),d.push(` else`),d.push(` if (( _directive & ${_.NoFileCompletion} )); then`),d.push(` compopt +o default 2>/dev/null`),d.push(' if (( ${#COMPREPLY[@]} == 0 )); then COMPREPLY=( "" ); fi'),d.push(` fi`),d.push(` fi`),d.push(` if (( _directive & ${_.NoSpace} )); then`),d.push(` compopt -o nospace 2>/dev/null`),d.push(` fi`),d.push(`}`),d.push(``)),d.push(`__${a}_not_used() {`),d.push(' for _u in "${_used_opts[@]}"; do'),d.push(` for _chk in "$@"; do`),d.push(` [[ "$_u" == "$_chk" ]] && return 1`),d.push(` done`),d.push(` done`),d.push(` return 0`),d.push(`}`),d.push(``),d.push(`__${a}_opt_takes_value() {`),d.push(` case "$1:$2" in`),d.push(...Ee(s,``)),d.push(` esac`),d.push(` return 1`),d.push(`}`),d.push(``),p&&(d.push(`__${a}_track_opt() {`),d.push(` case "$1:$2" in`),d.push(...Ae(u,`bash`)),d.push(` esac`),d.push(`}`),d.push(``),d.push(`__${a}_track_pos() {`),d.push(` case "$1:$2" in`),d.push(...je(u,`bash`)),d.push(` esac`),d.push(`}`),d.push(``),d.push(...h(a,Te(s)))),g&&(d.push(`__${a}_track_array_expand() {`),d.push(` case "$1:$2" in`),d.push(...Me(m,`bash`)),d.push(` esac`),d.push(`}`),d.push(``));let v=L(s);v.length>0&&(d.push(`__${a}_is_subcmd() {`),d.push(` case "$1:$2" in`),d.push(...De(v)),d.push(` esac`),d.push(` return 1`),d.push(`}`),d.push(``));for(let e of c)d.push(...Je(e,a,[]));if(d.push(`__${a}_complete_root() {`),d.push(...Ke(s.options,s.positionals,a,`root`)),d.push(` if [[ -z "$_inline_prefix" ]] && __${a}_opt_takes_value "" "$_prev"; then return; fi`),d.push(` if [[ -n "$_inline_prefix" ]] && __${a}_opt_takes_value "" "\${_inline_prefix%=}"; then return; fi`),s.positionals.length>0?(d.push(` if (( _after_dd )); then`),d.push(...q(s.positionals,a,`root`,s.options).map(e=>` ${e}`)),d.push(` return`),d.push(` fi`)):d.push(` if (( _after_dd )); then return; fi`),d.push(` if [[ "$_cur" == -* ]]; then`),d.push(` local -a _avail=()`),d.push(...qe(s.options,a)),d.push(' COMPREPLY=($(compgen -W "${_avail[*]}" -- "$_cur"))'),d.push(` compopt +o default 2>/dev/null`),c.length>0){d.push(` else`);let e=P(s.subcommands).map(e=>e.name).join(` `);d.push(...Ge(e,s.positionals,a,`root`,s.options).map(e=>` ${e}`))}else s.positionals.length>0&&(d.push(` else`),d.push(...q(s.positionals,a,`root`,s.options).map(e=>` ${e}`)));d.push(` fi`),d.push(`}`),d.push(``);let y=Oe(v,a).join(`
3
3
  `);d.push(`_${a}_completions() {`),d.push(` COMPREPLY=()`),d.push(``),d.push(` # Rejoin words split by '=' in COMP_WORDBREAKS`),d.push(` local -a _words=()`),d.push(` local _i=1`),d.push(` while (( _i <= COMP_CWORD )); do`),d.push(' if [[ "${COMP_WORDS[_i]}" == "=" && ${#_words[@]} -gt 0 ]]; then'),d.push(' _words[${#_words[@]}-1]+="=${COMP_WORDS[_i+1]:-}"'),d.push(` (( _i += 2 ))`),d.push(` else`),d.push(' _words+=("${COMP_WORDS[_i]}")'),d.push(` (( _i++ ))`),d.push(` fi`),d.push(` done`),d.push(``),d.push(` local _cur=""`),d.push(' (( ${#_words[@]} > 0 )) && _cur="${_words[${#_words[@]}-1]}"'),d.push(` local _inline_prefix=""`),d.push(``),d.push(` local _prev=""`),d.push(' (( ${#_words[@]} > 1 )) && _prev="${_words[${#_words[@]}-2]}"'),d.push(``),d.push(` local _subcmd="" _after_dd=0 _pos_count=0 _skip_next=0`),d.push(` local -a _used_opts=()`),p&&d.push(` local -a _pos_words=()`),d.push(` local _any_opt_used=0`),p&&(d.push(` ${K(`_arg_values_`)}`),d.push(` ${K(`_global_arg_values_`)}`)),g&&(d.push(` ${K(`_used_field_keys_`)}`),d.push(` ${K(`_global_used_field_keys_`)}`),d.push(` ${K(`_global_arr_seen_`)}`)),d.push(``),d.push(` local _j=0`),d.push(" while (( _j < ${#_words[@]} - 1 )); do"),d.push(' local _w="${_words[_j]}"'),d.push(` if (( _skip_next )); then _skip_next=0; (( _j++ )); continue; fi`),d.push(` if [[ "$_w" == "--" ]]; then _after_dd=1; (( _j++ )); continue; fi`);let b=p?`_pos_words+=("$_w"); `:``;d.push(` if (( _after_dd )); then ${b}(( _pos_count++ )); (( _j++ )); continue; fi`),d.push(` if [[ "$_w" == -*=* ]]; then`),d.push(' _used_opts+=("${_w%%=*}")'),d.push(` _any_opt_used=1`),p&&(d.push(` __${a}_track_opt "$_subcmd" "\${_w%%=*}" "\${_w#*=}"`),g&&d.push(` __${a}_track_array_expand "$_subcmd" "\${_w%%=*}" "\${_w#*=}"`)),d.push(` (( _j++ )); continue`),d.push(` fi`),d.push(` if [[ "$_w" == -* ]]; then`),d.push(` _used_opts+=("$_w")`),d.push(` _any_opt_used=1`),d.push(` if __${a}_opt_takes_value "$_subcmd" "$_w"; then`),d.push(' local _next="${_words[_j+1]:-}"'),d.push(` if [[ -n "$_next" && "$_next" != -* ]]; then _skip_next=1; fi`),p&&(d.push(` if (( _skip_next )); then`),d.push(` __${a}_track_opt "$_subcmd" "$_w" "$_next"`),g&&(d.push(" if (( _j + 2 < ${#_words[@]} )); then"),d.push(` __${a}_track_array_expand "$_subcmd" "$_w" "$_next"`),d.push(` fi`)),d.push(` fi`)),d.push(` fi`),d.push(` (( _j++ )); continue`),d.push(` fi`);let ee=g?`; ${K(`_arg_values_`)}; ${K(`_used_field_keys_`)}; ${K(`_global_arr_seen_`)}`:p?`; ${K(`_arg_values_`)}`:``,te=p?`_pos_words+=("$_w"); `:``;return v.length>0?d.push(` if __${a}_is_subcmd "$_subcmd" "$_w"; then _subcmd="\${_subcmd:+\${_subcmd}:}$_w"; _used_opts=(); _pos_count=0${p?`; _pos_words=()`:``}${ee}; else ${te}(( _pos_count++ )); fi`):(p&&d.push(` _pos_words+=("$_w")`),d.push(` (( _pos_count++ ))`)),d.push(` (( _j++ ))`),d.push(` done`),p&&d.push(` __${a}_track_positionals`),d.push(``),d.push(` if (( ! _after_dd )) && [[ "$_cur" == -*=* ]]; then`),d.push(' _inline_prefix="${_cur%%=*}="'),d.push(' _cur="${_cur#*=}"'),d.push(` fi`),d.push(``),d.push(` case "$_subcmd" in`),d.push(y),d.push(` *) __${a}_complete_root ;;`),d.push(` esac`),d.push(`}`),d.push(``),o||d.push(`complete -o default -F _${a}_completions ${n}`),d.push(``),{script:d.join(`
4
4
  `),shell:`bash`,installInstructions:`# To enable auto-refreshing bash completions, add this to your ~/.bashrc:
@@ -1,5 +1,5 @@
1
- import { C as AnyCommand, O as Command, T as ArgsSchema, _ as DynamicCompletionCandidate, b as DynamicCompletionResult, g as CompletionDirectiveMask, m as ExpandCompletion, rt as ResolvedFieldMeta, v as DynamicCompletionContext, y as DynamicCompletionResolver } from "./arg-registry-SvIkYiSr.js";
2
- import { _ as CompletionResult, a as bundledWorkerShellExtension, b as InferInternalArgs, c as validateBundledWorkerFile, d as CompletablePositional, f as CompletableSubcommand, g as CompletionOptions, h as CompletionMode, i as GenerateBundledCompletionWorkerResult, l as BundledWorkerOptions, m as CompletionGenerator, n as withCompletionCommand, o as defaultBundledWorkerOutputPath, p as CompletionData, r as GenerateBundledCompletionWorkerOptions, s as generateBundledCompletionWorker, t as WithCompletionOptions, u as CompletableOption, v as ShellType, x as InternalArgsSchema, y as ValueCompletion } from "./with-completion-command-M2RHrGAp.js";
1
+ import { C as AnyCommand, O as Command, T as ArgsSchema, _ as DynamicCompletionCandidate, b as DynamicCompletionResult, g as CompletionDirectiveMask, m as ExpandCompletion, rt as ResolvedFieldMeta, v as DynamicCompletionContext, y as DynamicCompletionResolver } from "./arg-registry-biPCZomY.js";
2
+ import { _ as CompletionResult, a as bundledWorkerShellExtension, b as InferInternalArgs, c as validateBundledWorkerFile, d as CompletablePositional, f as CompletableSubcommand, g as CompletionOptions, h as CompletionMode, i as GenerateBundledCompletionWorkerResult, l as BundledWorkerOptions, m as CompletionGenerator, n as withCompletionCommand, o as defaultBundledWorkerOutputPath, p as CompletionData, r as GenerateBundledCompletionWorkerOptions, s as generateBundledCompletionWorker, t as WithCompletionOptions, u as CompletableOption, v as ShellType, x as InternalArgsSchema, y as ValueCompletion } from "./with-completion-command-BY-z7NOc.js";
3
3
  /**
4
4
  * Schema for the completion command arguments
5
5
  */
@@ -1 +1 @@
1
- import"./register-BIQ84gFS.js";import{s as e,t}from"./with-completion-command-DSqob4X0.js";import{a as n,i as r,n as i,o as a,r as o,s,t as c}from"./dynamic-D3fYVKon.js";import{a as l,c as u,d,i as f,l as p,n as m,o as h,r as g,s as _,t as v,u as y}from"./completion-07BWyhmL.js";export{r as CompletionDirective,h as bundledWorkerShellExtension,v as createCompletionCommand,m as createCompletionWorkerPathCommand,c as createDynamicCompleteCommand,g as createRefreshCompletionCommand,_ as defaultBundledWorkerOutputPath,e as detectShell,y as extractCompletionData,d as extractPositionals,o as formatForShell,u as generateBundledCompletionWorker,n as generateCandidates,f as generateCompletion,l as getSupportedShells,i as hasCompleteCommand,a as parseCompletionContext,s as resolveValueCompletion,p as validateBundledWorkerFile,t as withCompletionCommand};
1
+ import"./register-BWzt6u5k.js";import{s as e,t}from"./with-completion-command-DkZmjiSe.js";import{a as n,i as r,n as i,o as a,r as o,s,t as c}from"./dynamic-CvUL5rZa.js";import{a as l,c as u,d,i as f,l as p,n as m,o as h,r as g,s as _,t as v,u as y}from"./completion-DXVkj0Uc.js";export{r as CompletionDirective,h as bundledWorkerShellExtension,v as createCompletionCommand,m as createCompletionWorkerPathCommand,c as createDynamicCompleteCommand,g as createRefreshCompletionCommand,_ as defaultBundledWorkerOutputPath,e as detectShell,y as extractCompletionData,d as extractPositionals,o as formatForShell,u as generateBundledCompletionWorker,n as generateCandidates,f as generateCompletion,l as getSupportedShells,i as hasCompleteCommand,a as parseCompletionContext,s as resolveValueCompletion,p as validateBundledWorkerFile,t as withCompletionCommand};
package/dist/docs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as Example, C as AnyCommand, T as ArgsSchema, X as SubCommandValue, ft as SchemaLike, nt as ExtractedFields, rt as ResolvedFieldMeta } from "./arg-registry-SvIkYiSr.js";
1
+ import { A as Example, C as AnyCommand, T as ArgsSchema, X as SubCommandValue, ft as SchemaLike, nt as ExtractedFields, rt as ResolvedFieldMeta } from "./arg-registry-biPCZomY.js";
2
2
  import * as fs$1 from "node:fs";
3
3
  /**
4
4
  * Resolve a lazy-loaded command (sync or async)