import{c as e,d as t,l as n,s as r,u as i}from"./t-DYl0qC9V.js";import{t as a}from"./shared-BE1U9MBi.js";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();p(o),m(o),o.command(`complete [shell]`).description(`Generate shell completion scripts`).action(async r=>{switch(r){case`zsh`:{let e=t(s,u);console.log(e);break}case`bash`:{let e=i(s,u);console.log(e);break}case`fish`:{let e=n(s,u);console.log(e);break}case`powershell`:{let t=e(s,u);console.log(t);break}case`debug`:{let e=new Map;h(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: ${r}`),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,i=n.findIndex(e=>e===`complete`),l=n.findIndex(e=>e===`--`);if(i!==-1&&l!==-1&&l>i){let e=n.slice(l+1);return a(s),r.parse(e),o}return c(e,t)},r}function p(e){for(let t of e.options){let e=t.flags,n=e.match(/^-([a-zA-Z]), --/)?.[1],i=e.match(/--([a-zA-Z0-9-]+)/)?.[1];i&&(n?r.option(i,t.description||``,n):r.option(i,t.description||``))}}function m(e){let t=new Map;h(e,``,t);for(let[e,n]of t.entries()){if(e===``)continue;let t=r.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&&(r?t.option(i,e.description||``,r):t.option(i,e.description||``))}}}function h(e,t,n){n.set(t,e);for(let r of e.commands)r.name()!==`complete`&&h(r,t?`${t} ${r.name()}`:r.name(),n)}export{f as default};