import"./powershell-CHePOaos.mjs";import e from"./index.mjs";const t=process.execPath,n=process.argv.slice(1),r=o(t),i=n.map(o),a=`${r} ${process.execArgv.map(o).join(` `)} ${i[0]}`;function o(e){return e.includes(` `)?`'${e}'`:e}function s(t,n){let r=t.name(),i=n?.completionCommandName??`complete`,o=t.createCommand(i).description(`Generate shell completion scripts`).addArgument(t.createArgument(`<shell>`,`Shell type for completion script`).choices([`zsh`,`bash`,`fish`,`powershell`])).action(t=>{e.setup(r,a,t)});o.copyInheritedSettings(t);let s=t.createCommand(`complete`).description(`Generate completion suggestions`).usage(`-- [args...]`).argument(`[args...]`).action(n=>{if(i!==`complete`){let e=t.rawArgs;n.length===1&&!e.includes(`--`)&&t.error(`error: completion requests are called like \`complete -- [args]\`.\n(Did you mean \`${i} ${n[0]}\` to generate shell script?)`)}e.parse(n)});return s.copyInheritedSettings(t),i===`complete`?t.command(`complete`).description(`Generate shell completion scripts`).argument(`[shell]`,`shell type (choices: "zsh", "bash", "fish", "powershell")`).allowExcessArguments().action((e,n,r)=>{let i=t.rawArgs,a=i.indexOf(`complete`),c=i.indexOf(`--`);a!==-1&&c!==-1&&c===a+1?s.parse([`--`,...r.args],{from:`user`}):o.parse(r.args,{from:`user`})}):(t.addCommand(o),t.addCommand(s,{hidden:!0})),l(t),d(t),e}function c(e,t){let n=t.createHelp().visibleOptions(t);for(let t of n){let n=t.short?.slice(1);n&&n[0]===`-`&&(n=void 0);let r=t.long?.slice(2);if(r){let i=t.required||t.optional,a=t.argChoices??[],o;i&&a.length>0?o=e=>{for(let t of a)e(t,``)}:i&&(o=()=>{}),o?e.option(r,t.description,o,n):e.option(r,t.description,n)}}}function l(t){c(e,t),u(e,t)}function u(e,t){for(let n of t.registeredArguments){let t=n.argChoices;t?.length?e.argument(n.name(),e=>{for(let n of t)e(n,``)},n.variadic):e.argument(n.name(),void 0,n.variadic)}}function d(t){let n=new Map;f(t,``,n);for(let[t,r]of n.entries()){if(t===``)continue;let n=e.command(t,r.description()||``);c(n,r),u(n,r)}}function f(e,t,n){n.set(t,e);let r=e.createHelp().visibleCommands(e);for(let e of r)f(e,t?`${t} ${e.name()}`:e.name(),n)}export{s as default};