import{i as e,n as t,r as n,t as r}from"./powershell-CHePOaos.mjs";import i from"./index.mjs";import{t as a}from"./shared-DAgv99GA.mjs";const o=process.execPath,s=process.argv.slice(1),c=d(o),l=s.map(d),u=`${c} ${process.execArgv.map(d).join(` `)} ${l[0]}`;function d(e){return e.includes(` `)?`'${e}'`:e}function f(o){let s=o.name();h(o),g(o),o.command(`complete [shell]`).description(`Generate shell completion scripts`).action(async i=>{switch(i){case`zsh`:{let t=e(s,u);console.log(t);break}case`bash`:{let e=n(s,u);console.log(e);break}case`fish`:{let e=t(s,u);console.log(e);break}case`powershell`:{let e=r(s,u);console.log(e);break}case`debug`:{let e=new Map;_(o,``,e),console.log(`Collected commands:`);for(let[t,n]of e.entries())console.log(`- ${t||`<root>`}: ${n.description()||`No description`}`);break}default:console.error(`Unknown shell: ${i}`),console.error(`Supported shells: zsh, bash, fish, powershell`),process.exit(1)}});let c=o.parse.bind(o);return o.parse=function(e,t){let n=e||process.argv,r=n.findIndex(e=>e===`complete`),l=n.findIndex(e=>e===`--`);if(r!==-1&&l!==-1&&l>r){let e=n.slice(l+1);return a(s),i.parse(e),o}return c(e,t)},i}function p(e){return e.includes(`<`)||e.includes(`[`)}function m(e,t,n,r,i){let a=p(t);i?a?e.option(n,r,()=>{},i):e.option(n,r,i):a?e.option(n,r,()=>{}):e.option(n,r)}function h(e){for(let t of e.options){let e=t.flags,n=e.match(/^-([a-zA-Z]), --/)?.[1],r=e.match(/--([a-zA-Z0-9-]+)/)?.[1];r&&m(i,e,r,t.description||``,n)}}function g(e){let t=new Map;_(e,``,t);for(let[e,n]of t.entries()){if(e===``)continue;let t=i.command(e,n.description()||``);for(let e of n.options){let n=e.flags,r=n.match(/^-([a-zA-Z]), --/)?.[1],i=n.match(/--([a-zA-Z0-9-]+)/)?.[1];i&&m(t,n,i,e.description||``,r)}}}function _(e,t,n){n.set(t,e);for(let r of e.commands)r.name()!==`complete`&&_(r,t?`${t} ${r.name()}`:r.name(),n)}export{f as default};