cli-kiss 0.2.3 → 0.2.5

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.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";var X=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Se=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var de=t=>{throw TypeError(t)};var Te=(t,e)=>{for(var n in e)X(t,n,{get:e[n],enumerable:!0})},ke=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Se(e))!Ce.call(t,r)&&r!==n&&X(t,r,{get:()=>e[r],enumerable:!(o=be(e,r))||o.enumerable});return t};var Ae=t=>ke(X({},"__esModule",{value:!0}),t);var Z=(t,e,n)=>e.has(t)||de("Cannot "+n);var d=(t,e,n)=>(Z(t,e,"read from private field"),n?n.call(t):e.get(t)),f=(t,e,n)=>e.has(t)?de("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),w=(t,e,n,o)=>(Z(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n),m=(t,e,n)=>(Z(t,e,"access private method"),n);var ge=(t,e,n,o)=>({set _(r){w(t,e,r,n)},get _(){return d(t,e,o)}});var rt={};Te(rt,{ReaderArgs:()=>F,TypoError:()=>g,TypoGrid:()=>P,TypoString:()=>s,TypoSupport:()=>$,TypoText:()=>u,command:()=>Pe,commandChained:()=>Ee,commandWithSubcommands:()=>ve,operation:()=>We,optionFlag:()=>Qe,optionRepeatable:()=>ze,optionSingleValue:()=>Je,positionalOptional:()=>Ze,positionalRequired:()=>Xe,positionalVariadics:()=>_e,runAndExit:()=>ot,typeBoolean:()=>Q,typeDate:()=>Be,typeInteger:()=>Ke,typeList:()=>He,typeMapped:()=>Fe,typeNumber:()=>Ge,typeOneOf:()=>Ye,typeString:()=>je,typeTuple:()=>qe,typeUrl:()=>Ne,typoStyleConstants:()=>b,typoStyleFailure:()=>he,typoStyleLogic:()=>R,typoStyleQuote:()=>x,typoStyleRegularStrong:()=>ee,typoStyleRegularWeaker:()=>te,typoStyleTitle:()=>_,typoStyleUserInput:()=>S,usageToStyledLines:()=>ce});module.exports=Ae(rt);var _={fgColor:"darkGreen",bold:!0},R={fgColor:"darkMagenta",bold:!0},x={fgColor:"darkYellow",bold:!0},he={fgColor:"darkRed",bold:!0},b={fgColor:"darkCyan",bold:!0},S={fgColor:"darkBlue",bold:!0},ee={bold:!0},te={italic:!0,dim:!0},L,j,s=class{constructor(e,n={}){f(this,L);f(this,j);w(this,L,e),w(this,j,n)}getRawString(){return d(this,L)}computeStyledString(e){return e.computeStyledString(d(this,L),d(this,j))}};L=new WeakMap,j=new WeakMap;var A,ne=class ne{constructor(...e){f(this,A);w(this,A,[]);for(let n of e)n instanceof ne?this.pushText(n):n instanceof s?this.pushString(n):typeof n=="string"&&this.pushString(new s(n))}pushString(e){typeof e=="string"?d(this,A).push(new s(e)):d(this,A).push(e)}pushText(e){if(typeof e=="string")this.pushString(e);else for(let n of d(e,A))d(this,A).push(n)}computeStyledString(e){return d(this,A).map(n=>n.computeStyledString(e)).join("")}computeRawString(){return d(this,A).map(e=>e.getRawString()).join("")}computeRawLength(){let e=0;for(let n of d(this,A))e+=n.getRawString().length;return e}};A=new WeakMap;var u=ne,M,P=class{constructor(){f(this,M);w(this,M,[])}pushRow(e){d(this,M).push(e)}computeStyledGrid(e){let n=new Array,o=new Array;for(let r of d(this,M))for(let i=0;i<r.length;i++){let a=r[i].computeRawLength();(n[i]===void 0||a>n[i])&&(n[i]=a)}for(let r of d(this,M)){let i=new Array;for(let l=0;l<r.length;l++){let a=r[l],c=a.computeStyledString(e);if(i.push(c),l<r.length-1){let p=a.computeRawLength(),y=" ".repeat(n[l]-p);i.push(y)}}o.push(i)}return o}};M=new WeakMap;var W,H=class H extends Error{constructor(n,o){let r=new u;r.pushText(n),o instanceof H?(r.pushString(new s(": ")),r.pushText(d(o,W))):o instanceof Error?r.pushString(new s(`: ${o.message}`)):o!==void 0&&r.pushString(new s(`: ${String(o)}`));super(r.computeRawString());f(this,W);w(this,W,r)}computeStyledString(n){return d(this,W).computeStyledString(n)}static tryWithContext(n,o){try{return n()}catch(r){throw new H(o(),r)}}};W=new WeakMap;var g=H,V,k=class k{constructor(e){f(this,V);w(this,V,e)}static none(){return new k("none")}static tty(){return new k("tty")}static mock(){return new k("mock")}static inferFromProcess(){if(!process)return k.none();if(process.env){if(process.env.FORCE_COLOR==="0")return k.none();if(process.env.FORCE_COLOR)return k.tty();if("NO_COLOR"in process.env)return k.none()}return process.stdout&&process.stdout.isTTY?k.tty():k.none()}computeStyledString(e,n){if(d(this,V)==="none")return e;if(d(this,V)==="tty"){let o=n.fgColor?De[n.fgColor]:"",r=n.bgColor?Me[n.bgColor]:"",i=n.bold?Ue:"",l=n.dim?Oe:"",a=n.italic?Ve:"",c=n.underline?$e:"",p=n.strikethrough?Ie:"";return`${o}${r}${i}${l}${a}${c}${p}${e}${Re}`}if(d(this,V)==="mock"){let o=n.fgColor?`{${e}}@${n.fgColor}`:e,r=n.bgColor?`{${o}}#${n.bgColor}`:o,i=n.bold?`{${r}}+`:r,l=n.dim?`{${i}}-`:i,a=n.italic?`{${l}}*`:l,c=n.underline?`{${a}}_`:a;return n.strikethrough?`{${c}}~`:c}throw new Error(`Unknown TypoSupport kind: ${d(this,V)}`)}computeStyledErrorMessage(e){return[this.computeStyledString("Error:",he),e instanceof g?e.computeStyledString(this):e instanceof Error?e.message:String(e)].join(" ")}};V=new WeakMap;var $=k,Re="\x1B[0m",Ue="\x1B[1m",Oe="\x1B[2m",Ve="\x1B[3m",$e="\x1B[4m",Ie="\x1B[9m",De={darkBlack:"\x1B[30m",darkRed:"\x1B[31m",darkGreen:"\x1B[32m",darkYellow:"\x1B[33m",darkBlue:"\x1B[34m",darkMagenta:"\x1B[35m",darkCyan:"\x1B[36m",darkWhite:"\x1B[37m",brightBlack:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},Me={darkBlack:"\x1B[40m",darkRed:"\x1B[41m",darkGreen:"\x1B[42m",darkYellow:"\x1B[43m",darkBlue:"\x1B[44m",darkMagenta:"\x1B[45m",darkCyan:"\x1B[46m",darkWhite:"\x1B[47m",brightBlack:"\x1B[100m",brightRed:"\x1B[101m",brightGreen:"\x1B[102m",brightYellow:"\x1B[103m",brightBlue:"\x1B[104m",brightMagenta:"\x1B[105m",brightCyan:"\x1B[106m",brightWhite:"\x1B[107m"};function Pe(t,e){return{getInformation(){return t},consumeAndMakeDecoder(n){try{let o=e.consumeAndMakeDecoder(n),r=n.consumePositional();if(r!==void 0)throw new g(new u(new s("Unexpected argument: "),new s(`"${r}"`,x)));return{generateUsage:()=>B(t,e),decodeAndMakeInterpreter(){let i=o.decodeAndMakeInterpreter();return{async executeWithContext(l){return await i.executeWithContext(l)}}}}}catch(o){return{generateUsage:()=>B(t,e),decodeAndMakeInterpreter(){throw o}}}}}}function ve(t,e,n){return{getInformation(){return t},consumeAndMakeDecoder(o){try{let r=e.consumeAndMakeDecoder(o),i=o.consumePositional();if(i===void 0)throw new g(new u(new s("<SUBCOMMAND>",S),new s(": Is required, but was not provided")));let l=n[i];if(l===void 0)throw new g(new u(new s("<SUBCOMMAND>",S),new s(": Invalid value: "),new s(`"${i}"`,x)));let a=l.consumeAndMakeDecoder(o);return{generateUsage(){let c=a.generateUsage(),p=B(t,e);return p.segments.push(Le(i)),p.segments.push(...c.segments),p.information=c.information,p.positionals.push(...c.positionals),p.subcommands=c.subcommands,p.options.push(...c.options),p},decodeAndMakeInterpreter(){let c=r.decodeAndMakeInterpreter(),p=a.decodeAndMakeInterpreter();return{async executeWithContext(y){return await p.executeWithContext(await c.executeWithContext(y))}}}}}catch(r){return{generateUsage(){let i=B(t,e);i.segments.push(oe("<SUBCOMMAND>"));for(let[l,a]of Object.entries(n)){let{description:c,hint:p}=a.getInformation();i.subcommands.push({name:l,description:c,hint:p})}return i},decodeAndMakeInterpreter(){throw r}}}}}}function Ee(t,e,n){return{getInformation(){return t},consumeAndMakeDecoder(o){try{let r=e.consumeAndMakeDecoder(o),i=n.consumeAndMakeDecoder(o);return{generateUsage(){let l=i.generateUsage(),a=B(t,e);return a.segments.push(...l.segments),a.information=l.information,a.positionals.push(...l.positionals),a.subcommands=l.subcommands,a.options.push(...l.options),a},decodeAndMakeInterpreter(){let l=r.decodeAndMakeInterpreter(),a=i.decodeAndMakeInterpreter();return{async executeWithContext(c){return await a.executeWithContext(await l.executeWithContext(c))}}}}}catch(r){return{generateUsage(){let i=B(t,e);return i.segments.push(oe("[REST]...")),i},decodeAndMakeInterpreter(){throw r}}}}}}function oe(t){return{positional:t}}function Le(t){return{command:t}}function B(t,e){let{positionals:n,options:o}=e.generateUsage();return{segments:n.map(r=>oe(r.label)),information:t,positionals:n,subcommands:[],options:o}}function We(t,e){return{generateUsage(){let n=new Array;for(let r in t.options){let i=t.options[r];i&&n.push(i.generateUsage())}let o=new Array;for(let r of t.positionals)o.push(r.generateUsage());return{options:n,positionals:o}},consumeAndMakeDecoder(n){let o={};for(let i in t.options){let l=t.options[i];o[i]=l.registerAndMakeDecoder(n)}let r=[];for(let i of t.positionals)r.push(i.consumeAndMakeDecoder(n));return{decodeAndMakeInterpreter(){let i={};for(let a in o)i[a]=o[a].getAndDecodeValue();let l=[];for(let a of r)l.push(a.decodeValue());return{executeWithContext(a){return e(a,{options:i,positionals:l})}}}}}}}var Q={content:"Boolean",decoder(t){let e=t.toLowerCase();if(e==="true"||e==="yes")return!0;if(e==="false"||e==="no")return!1;throw new g(new u(new s("Invalid value: "),new s(`"${t}"`,x)))}},Be={content:"Date",decoder(t){try{let e=Date.parse(t);if(isNaN(e))throw new Error;return new Date(e)}catch{throw new g(new u(new s("Not a valid ISO_8601: "),new s(`"${t}"`,x)))}}},Ge={content:"Number",decoder(t){try{let e=Number(t);if(isNaN(e))throw new Error;return e}catch{throw new g(new u(new s("Unable to parse: "),new s(`"${t}"`,x)))}}},Ke={content:"Integer",decoder(t){try{return BigInt(t)}catch{throw new g(new u(new s("Unable to parse: "),new s(`"${t}"`,x)))}}},Ne={content:"Url",decoder(t){try{return new URL(t)}catch{throw new g(new u(new s("Unable to parse: "),new s(`"${t}"`,x)))}}},je={content:"String",decoder(t){return t}};function Fe(t,e){return{content:e.content,decoder:n=>e.decoder(g.tryWithContext(()=>t.decoder(n),()=>new u(new s("from: "),new s(t.content,R))))}}function Ye(t,e){return{content:t,decoder(n){for(let r of e)if(n===r)return r;let o=[];for(let r of e){if(o.length>=5){o.push(new s("..."));break}o.length>0&&o.push(new s(" | ")),o.push(new s(`"${r}"`,x))}throw new g(new u(new s("Invalid value: "),new s(`"${n}"`,x),new s(" (expected one of: "),...o,new s(")")))}}}function qe(t,e=","){return{content:t.map(n=>n.content).join(e),decoder(n){let o=n.split(e,t.length);if(o.length!==t.length)throw new g(new u(new s(`Found ${o.length} splits: `),new s(`Expected ${t.length} splits from: `),new s(`"${n}"`,x)));return o.map((r,i)=>{let l=t[i];return g.tryWithContext(()=>l.decoder(r),()=>new u(new s(`at ${i}: `),new s(l.content,R)))})}}}function He(t,e=","){return{content:`${t.content}[${e}${t.content}]...`,decoder(n){return n.split(e).map((r,i)=>g.tryWithContext(()=>t.decoder(r),()=>new u(new s(`at ${i}: `),new s(t.content,R))))}}}function Qe(t){let e=`<${Q.content.toUpperCase()}>`;return{generateUsage(){return{description:t.description,hint:t.hint,long:t.long,short:t.short,label:void 0}},registerAndMakeDecoder(n){let o=se(n,{...t,valued:!1});return{getAndDecodeValue(){let r=n.getOptionValues(o);if(r.length>1)throw new g(new u(new s(`--${t.long}`,b),new s(": Must not be set multiple times")));let i=r[0];if(i===void 0)try{return t.default?t.default():!1}catch(l){throw new g(new u(new s(`--${t.long}`,b),new s(": Failed to get default value")),l)}return re({long:t.long,short:t.short,label:e,type:Q,input:i})}}}}}function Je(t){let e=`<${t.label??t.type.content.toUpperCase()}>`;return{generateUsage(){return{description:t.description,hint:t.hint,long:t.long,short:t.short,label:e}},registerAndMakeDecoder(n){let o=se(n,{...t,valued:!0});return{getAndDecodeValue(){let r=n.getOptionValues(o);if(r.length>1)throw new g(new u(new s(`--${t.long}`,b),new s(": Requires a single value, but got multiple")));let i=r[0];if(i===void 0)try{return t.default()}catch(l){throw new g(new u(new s(`--${t.long}`,b),new s(": Failed to get default value")),l)}return re({long:t.long,short:t.short,label:e,type:t.type,input:i})}}}}}function ze(t){let e=`<${t.label??t.type.content.toUpperCase()}>`;return{generateUsage(){return{description:t.description,hint:t.hint,long:t.long,short:t.short,label:e}},registerAndMakeDecoder(n){let o=se(n,{...t,valued:!0});return{getAndDecodeValue(){return n.getOptionValues(o).map(i=>re({long:t.long,short:t.short,label:e,type:t.type,input:i}))}}}}}function re(t){return g.tryWithContext(()=>t.type.decoder(t.input),()=>{let e=new u;return t.short&&(e.pushString(new s(`-${t.short}`,b)),e.pushString(new s(", "))),e.pushString(new s(`--${t.long}`,b)),e.pushString(new s(": ")),e.pushString(new s(t.label,S)),e.pushString(new s(": ")),e.pushString(new s(t.type.content,R)),e})}function se(t,e){let{long:n,short:o,aliases:r,valued:i}=e,l=n?[n]:[];r?.longs&&l.push(...r?.longs);let a=o?[o]:[];return r?.shorts&&a.push(...r?.shorts),t.registerOption({longs:l,shorts:a,valued:i})}function Xe(t){let e=`<${t.label??t.type.content.toUpperCase()}>`;return{generateUsage(){return{description:t.description,hint:t.hint,label:e}},consumeAndMakeDecoder(n){let o=n.consumePositional();if(o===void 0)throw new g(new u(new s(e,S),new s(": Is required, but was not provided")));return{decodeValue(){return ie(e,t.type,o)}}}}}function Ze(t){let e=`[${t.label??t.type.content.toUpperCase()}]`;return{generateUsage(){return{description:t.description,hint:t.hint,label:e}},consumeAndMakeDecoder(n){let o=n.consumePositional();return{decodeValue(){if(o===void 0)try{return t.default()}catch(r){throw new g(new u(new s(e,S),new s(": Failed to get default value")),r)}return ie(e,t.type,o)}}}}}function _e(t){let e=`[${t.label??t.type.content.toUpperCase()}]`;return{generateUsage(){return{description:t.description,hint:t.hint,label:`${e}...`+(t.endDelimiter?`["${t.endDelimiter}"]`:"")}},consumeAndMakeDecoder(n){let o=new Array;for(;;){let r=n.consumePositional();if(r===void 0||r===t.endDelimiter)break;o.push(r)}return{decodeValue(){return o.map(r=>ie(e,t.type,r))}}}}}function ie(t,e,n){return g.tryWithContext(()=>e.decoder(n),()=>new u(new s(t,S),new s(": "),new s(e.content,R)))}var Y,G,D,v,O,E,K,h,J,me,ae,ye,pe,I,ue,F=class{constructor(e){f(this,h);f(this,Y);f(this,G);f(this,D);f(this,v);f(this,O);f(this,E);f(this,K);w(this,Y,e),w(this,G,0),w(this,D,!1),w(this,v,new Map),w(this,O,new Map),w(this,E,new Map),w(this,K,new Map)}registerOption(e){let n=[...e.longs.map(o=>`--${o}`),...e.shorts.map(o=>`-${o}`)].join(", ");for(let o of e.longs){if(!m(this,h,ue).call(this,o))throw new Error(`Invalid option name: --${o}`);if(d(this,v).has(o))throw new Error(`Option already registered: --${o}`)}for(let o of e.shorts){if(!m(this,h,ue).call(this,o))throw new Error(`Invalid option name: -${o}`);if(d(this,O).has(o))throw new Error(`Option already registered: -${o}`);for(let r=0;r<o.length;r++){let i=o.slice(0,r);if(d(this,O).has(i))throw new Error(`Option -${o} overlap with shorter option: -${i}`)}for(let r of d(this,O).keys())if(r.startsWith(o))throw new Error(`Option -${o} overlap with longer option: -${r}`)}for(let o of e.longs)d(this,v).set(o,n);for(let o of e.shorts)d(this,O).set(o,n);return d(this,E).set(n,e.valued),d(this,K).set(n,new Array),n}getOptionValues(e){let n=d(this,K).get(e);if(n===void 0)throw new Error(`Unregistered option: ${e}`);return n}consumePositional(){for(;;){let e=m(this,h,J).call(this);if(e===null)return;if(m(this,h,me).call(this,e))return e}}};Y=new WeakMap,G=new WeakMap,D=new WeakMap,v=new WeakMap,O=new WeakMap,E=new WeakMap,K=new WeakMap,h=new WeakSet,J=function(){let e=d(this,Y)[d(this,G)];return e===void 0?null:(ge(this,G)._++,!d(this,D)&&e==="--"?(w(this,D,!0),m(this,h,J).call(this)):e)},me=function(e){if(d(this,D))return!0;if(e.startsWith("--")){let n=e.indexOf("=");return n===-1?m(this,h,ae).call(this,e.slice(2),null):m(this,h,ae).call(this,e.slice(2,n),e.slice(n+1)),!1}if(e.startsWith("-")){let n=1,o=2;for(;o<=e.length;){let r=m(this,h,ye).call(this,e.slice(n,o),e.slice(o));if(r===!0)return!1;r===!1&&(n=o),o++}throw new g(new u(new s(`-${e.slice(n)}`,b),new s(": Unexpected unknown option")))}return!0},ae=function(e,n){let o=`--${e}`,r=d(this,v).get(e);if(r!==void 0)return n!==null?m(this,h,I).call(this,r,n):d(this,E).get(r)?m(this,h,I).call(this,r,m(this,h,pe).call(this,o)):m(this,h,I).call(this,r,"true");throw new g(new u(new s(o,b),new s(": Unexpected unknown option")))},ye=function(e,n){let o=d(this,O).get(e);return o!==void 0?n.startsWith("=")?(m(this,h,I).call(this,o,n.slice(1)),!0):d(this,E).get(o)?(n===""?m(this,h,I).call(this,o,m(this,h,pe).call(this,`-${e}`)):m(this,h,I).call(this,o,n),!0):(m(this,h,I).call(this,o,"true"),n===""):null},pe=function(e){let n=m(this,h,J).call(this);if(n===null)throw new g(new u(new s(e,b),new s(": Requires a value, but got end of input")));if(d(this,D))throw new g(new u(new s(e,b),new s(": Requires a value before "),new s('"--"',x)));if(n.startsWith("-"))throw new g(new u(new s(e,b),new s(": Requires a value, but got: "),new s(`"${n}"`,x)));return n},I=function(e,n){this.getOptionValues(e).push(n)},ue=function(e){return e.length>0&&!e.includes("=")};function ce(t){let{cliName:e,commandUsage:n,typoSupport:o}=t,r=new Array,i=[et("Usage:").computeStyledString(o),U(e).computeStyledString(o)].concat(n.segments.map(a=>{if("positional"in a)return q(a.positional).computeStyledString(o);if("command"in a)return U(a.command).computeStyledString(o);throw new Error(`Unknown segment: ${JSON.stringify(a)}`)}));r.push(i.join(" ")),r.push("");let l=new u;l.pushString(tt(n.information.description)),n.information.hint&&(l.pushString(C(" ")),l.pushString(N(`(${n.information.hint})`))),r.push(l.computeStyledString(o));for(let a of n.information.details??[]){let c=new u;c.pushString(N(a)),r.push(c.computeStyledString(o))}if(n.positionals.length>0){r.push(""),r.push(z("Positionals:").computeStyledString(o));let a=new P;for(let c of n.positionals){let p=new Array;p.push(new u(C(" "))),p.push(new u(q(c.label))),p.push(...le(c)),a.pushRow(p)}r.push(...a.computeStyledGrid(o).map(c=>c.join("")))}if(n.subcommands.length>0){r.push(""),r.push(z("Subcommands:").computeStyledString(o));let a=new P;for(let c of n.subcommands){let p=new Array;p.push(new u(C(" "))),p.push(new u(U(c.name))),p.push(...le(c)),a.pushRow(p)}r.push(...a.computeStyledGrid(o).map(c=>c.join("")))}if(n.options.length>0){r.push(""),r.push(z("Options:").computeStyledString(o));let a=new P;for(let c of n.options){let p=new Array;p.push(new u(C(" "))),c.short?p.push(new u(U(`-${c.short}`),C(", "))):p.push(new u),c.label?p.push(new u(U(`--${c.long}`),C(" "),q(c.label))):p.push(new u(U(`--${c.long}`),N("[=no]"))),p.push(...le(c)),a.pushRow(p)}r.push(...a.computeStyledGrid(o).map(c=>c.join("")))}if(n.information.examples){r.push(""),r.push(z("Examples:").computeStyledString(o));for(let a of n.information.examples){let c=new u;c.pushString(C(" ")),c.pushString(N(`# ${a.explanation}`)),r.push(c.computeStyledString(o));let p=new u;p.pushString(C(" ")),p.pushString(U(e));for(let y of a.commandArgs)if(p.pushString(C(" ")),typeof y=="string")p.pushString(y);else if("positional"in y)p.pushString(q(y.positional));else if("subcommand"in y)p.pushString(U(y.subcommand));else if("option"in y){let T=y.option;"short"in T?p.pushString(U(`-${T.short}`)):p.pushString(U(`--${T.long}`)),T.value!==void 0&&(p.pushString(N("=")),p.pushString(q(T.value)))}r.push(p.computeStyledString(o))}}return r.push(""),r}function le(t){let e=[];return t.description&&(e.push(C(" ")),e.push(nt(t.description))),t.hint&&(e.push(C(" ")),e.push(N(`(${t.hint})`))),e.length>0?[new u(C(" "),...e)]:[]}function et(t){return new s(t,R)}function tt(t){return new s(t,ee)}function nt(t){return new s(t)}function z(t){return new s(t,_)}function N(t){return new s(t,te)}function U(t){return new s(t,b)}function q(t){return new s(t,S)}function C(t){return new s(t)}async function ot(t,e,n,o,r){let i=new F(e),l=r?.usageOnHelp??!0;l&&i.registerOption({shorts:[],longs:["help"],valued:!1});let a=r?.buildVersion;a&&i.registerOption({shorts:[],longs:["version"],valued:!1});let c=o.consumeAndMakeDecoder(i);for(;;)try{if(i.consumePositional()===void 0)break}catch{}let p=r?.onExit??process.exit,y=r?.useTtyColors===void 0?$.inferFromProcess():r.useTtyColors==="mock"?$.mock():r.useTtyColors?$.tty():$.none();if(l&&i.getOptionValues("--help").length>0)return console.log(fe(t,c,y)),p(0);if(a&&i.getOptionValues("--version").length>0)return console.log([t,a].join(" ")),p(0);try{let T=c.decodeAndMakeInterpreter();try{return await T.executeWithContext(n),p(0)}catch(xe){return we(r?.onError,xe,y),p(1)}}catch(T){return(r?.usageOnError??!0)&&console.error(fe(t,c,y)),we(r?.onError,T,y),p(1)}}function we(t,e,n){t!==void 0?t(e):console.error(n.computeStyledErrorMessage(e))}function fe(t,e,n){return ce({cliName:t,commandUsage:e.generateUsage(),typoSupport:n}).join(`
2
- `)}0&&(module.exports={ReaderArgs,TypoError,TypoGrid,TypoString,TypoSupport,TypoText,command,commandChained,commandWithSubcommands,operation,optionFlag,optionRepeatable,optionSingleValue,positionalOptional,positionalRequired,positionalVariadics,runAndExit,typeBoolean,typeDate,typeInteger,typeList,typeMapped,typeNumber,typeOneOf,typeString,typeTuple,typeUrl,typoStyleConstants,typoStyleFailure,typoStyleLogic,typoStyleQuote,typoStyleRegularStrong,typoStyleRegularWeaker,typoStyleTitle,typoStyleUserInput,usageToStyledLines});
1
+ "use strict";var _=Object.defineProperty;var ke=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var he=n=>{throw TypeError(n)};var Ue=(n,e)=>{for(var t in e)_(n,t,{get:e[t],enumerable:!0})},De=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Oe(e))!Ve.call(n,o)&&o!==t&&_(n,o,{get:()=>e[o],enumerable:!(r=ke(e,o))||r.enumerable});return n};var $e=n=>De(_({},"__esModule",{value:!0}),n);var ee=(n,e,t)=>e.has(n)||he("Cannot "+t);var c=(n,e,t)=>(ee(n,e,"read from private field"),t?t.call(n):e.get(n)),b=(n,e,t)=>e.has(n)?he("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),w=(n,e,t,r)=>(ee(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),x=(n,e,t)=>(ee(n,e,"access private method"),t);var me=(n,e,t,r)=>({set _(o){w(n,e,o,t)},get _(){return c(n,e,r)}});var dt={};Ue(dt,{ReaderArgs:()=>Q,TypoError:()=>g,TypoGrid:()=>E,TypoString:()=>i,TypoSupport:()=>O,TypoText:()=>d,command:()=>Ne,commandChained:()=>Ke,commandWithSubcommands:()=>Be,operation:()=>Fe,optionFlag:()=>J,optionRepeatable:()=>nt,optionSingleValue:()=>ae,positionalOptional:()=>rt,positionalRequired:()=>ot,positionalVariadics:()=>st,runAndExit:()=>lt,type:()=>Je,typeBoolean:()=>se,typeChoice:()=>ie,typeConverted:()=>Xe,typeDatetime:()=>qe,typeInteger:()=>He,typeList:()=>tt,typeNumber:()=>Qe,typePath:()=>_e,typeRenamed:()=>Ze,typeTuple:()=>et,typeUrl:()=>ze,typoStyleConstants:()=>R,typoStyleFailure:()=>ye,typoStyleLogic:()=>V,typoStyleQuote:()=>f,typoStyleRegularStrong:()=>ne,typoStyleRegularWeaker:()=>oe,typoStyleTitle:()=>te,typoStyleUserInput:()=>T,usageToStyledLines:()=>ge});module.exports=$e(dt);var te={fgColor:"darkGreen",bold:!0},V={fgColor:"darkMagenta",bold:!0},f={fgColor:"darkYellow",bold:!0},ye={fgColor:"darkRed",bold:!0},R={fgColor:"darkCyan",bold:!0},T={fgColor:"darkBlue",bold:!0},ne={bold:!0},oe={italic:!0,dim:!0},L,q,i=class{constructor(e,t={}){b(this,L);b(this,q);w(this,L,e),w(this,q,t)}computeStyledString(e){return e.computeStyledString(c(this,L),c(this,q))}getRawString(){return c(this,L)}};L=new WeakMap,q=new WeakMap;var A,re=class re{constructor(...e){b(this,A);w(this,A,[]);for(let t of e)this.push(t)}push(e){if(typeof e=="string")c(this,A).push(new i(e));else if(e instanceof re)c(this,A).push(...c(e,A));else if(Array.isArray(e))for(let t of e)c(this,A).push(t);else c(this,A).push(e)}computeStyledString(e){return c(this,A).map(t=>t.computeStyledString(e)).join("")}computeRawString(){return c(this,A).map(e=>e.getRawString()).join("")}computeRawLength(){let e=0;for(let t of c(this,A))e+=t.getRawString().length;return e}};A=new WeakMap;var d=re,M,E=class{constructor(){b(this,M);w(this,M,[])}pushRow(e){c(this,M).push(e)}computeStyledLines(e){let t=new Array,r=new Array;for(let o of c(this,M))for(let s=0;s<o.length;s++){let a=o[s].computeRawLength();(t[s]===void 0||a>t[s])&&(t[s]=a)}for(let o of c(this,M)){let s=new Array;for(let u=0;u<o.length;u++){let a=o[u];if(s.push(a.computeStyledString(e)),u<o.length-1){let p=a.computeRawLength(),l=" ".repeat(t[u]-p);s.push(l)}}r.push(s.join(""))}return r}};M=new WeakMap;var G,H=class H extends Error{constructor(t,r){let o=new d;o.push(t),r instanceof H?(o.push(new i(": ")),o.push(c(r,G))):r instanceof Error?o.push(new i(`: ${r.message}`)):r!==void 0&&o.push(new i(`: ${String(r)}`));super(o.computeRawString());b(this,G);w(this,G,o)}computeStyledString(t){return c(this,G).computeStyledString(t)}static tryWithContext(t,r){try{return t()}catch(o){throw new H(r(),o)}}};G=new WeakMap;var g=H,I,k=class k{constructor(e){b(this,I);w(this,I,e)}static none(){return new k("none")}static tty(){return new k("tty")}static mock(){return new k("mock")}static inferFromEnv(){if(!process||!process.env)return k.none();function e(r){if(r in process.env)return process.env[r]}let t=e("FORCE_COLOR");return t==="0"||(t!==void 0&&k.tty(),e("NO_COLOR")!==void 0)?k.none():e("MOCK_COLOR")!==void 0?k.mock():k.tty()}computeStyledString(e,t){let r=e;if(t.case==="upper"&&(r=r.toUpperCase()),t.case==="lower"&&(r=r.toLowerCase()),c(this,I)==="none")return r;if(c(this,I)==="tty"){let o=t.fgColor?Le[t.fgColor]:"",s=t.bgColor?Ge[t.bgColor]:"",u=t.bold?Pe:"",a=t.dim?Me:"",p=t.italic?Ee:"",l=t.underline?ve:"",h=t.strikethrough?We:"";return`${o}${s}${u}${a}${p}${l}${h}${r}${Ie}`}if(c(this,I)==="mock"){let o=t.fgColor?`{${r}}@${t.fgColor}`:r,s=t.bgColor?`{${o}}#${t.bgColor}`:o,u=t.bold?`{${s}}+`:s,a=t.dim?`{${u}}-`:u,p=t.italic?`{${a}}*`:a,l=t.underline?`{${p}}_`:p;return t.strikethrough?`{${l}}~`:l}throw new Error(`Unknown TypoSupport kind: ${c(this,I)}`)}computeStyledErrorMessage(e){return[this.computeStyledString("Error:",ye),e instanceof g?e.computeStyledString(this):e instanceof Error?e.message:String(e)].join(" ")}};I=new WeakMap;var O=k,Ie="\x1B[0m",Pe="\x1B[1m",Me="\x1B[2m",Ee="\x1B[3m",ve="\x1B[4m",We="\x1B[9m",Le={darkBlack:"\x1B[30m",darkRed:"\x1B[31m",darkGreen:"\x1B[32m",darkYellow:"\x1B[33m",darkBlue:"\x1B[34m",darkMagenta:"\x1B[35m",darkCyan:"\x1B[36m",darkWhite:"\x1B[37m",brightBlack:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},Ge={darkBlack:"\x1B[40m",darkRed:"\x1B[41m",darkGreen:"\x1B[42m",darkYellow:"\x1B[43m",darkBlue:"\x1B[44m",darkMagenta:"\x1B[45m",darkCyan:"\x1B[46m",darkWhite:"\x1B[47m",brightBlack:"\x1B[100m",brightRed:"\x1B[101m",brightGreen:"\x1B[102m",brightYellow:"\x1B[103m",brightBlue:"\x1B[104m",brightMagenta:"\x1B[105m",brightCyan:"\x1B[106m",brightWhite:"\x1B[107m"};function Ne(n,e){return{getInformation(){return n},consumeAndMakeDecoder(t){try{let r=e.consumeAndMakeDecoder(t),o=t.consumePositional();if(o!==void 0)throw new g(new d(new i("Unexpected argument: "),new i(`"${o}"`,f)));return{generateUsage:()=>N(n,e),decodeAndMakeInterpreter(){let s=r.decodeAndMakeInterpreter();return{async executeWithContext(u){return await s.executeWithContext(u)}}}}}catch(r){return{generateUsage:()=>N(n,e),decodeAndMakeInterpreter(){throw r}}}}}}function Be(n,e,t){return{getInformation(){return n},consumeAndMakeDecoder(r){try{let o=e.consumeAndMakeDecoder(r),s=r.consumePositional();if(s===void 0)throw new g(new d(new i("<subcommand>",T),new i(": Is required, but was not provided")));let u=t[s];if(u===void 0)throw new g(new d(new i("<subcommand>",T),new i(": Invalid value: "),new i(`"${s}"`,f)));let a=u.consumeAndMakeDecoder(r);return{generateUsage(){let p=a.generateUsage(),l=N(n,e);return l.segments.push({subcommand:s}),l.segments.push(...p.segments),l.information=p.information,l.positionals.push(...p.positionals),l.subcommands=p.subcommands,l.options.push(...p.options),l},decodeAndMakeInterpreter(){let p=o.decodeAndMakeInterpreter(),l=a.decodeAndMakeInterpreter();return{async executeWithContext(h){return await l.executeWithContext(await p.executeWithContext(h))}}}}}catch(o){return{generateUsage(){let s=N(n,e);s.segments.push({positional:"<subcommand>"});for(let[u,a]of Object.entries(t)){let{description:p,hint:l}=a.getInformation();s.subcommands.push({name:u,description:p,hint:l})}return s},decodeAndMakeInterpreter(){throw o}}}}}}function Ke(n,e,t){return{getInformation(){return n},consumeAndMakeDecoder(r){try{let o=e.consumeAndMakeDecoder(r),s=t.consumeAndMakeDecoder(r);return{generateUsage(){let u=s.generateUsage(),a=N(n,e);return a.segments.push(...u.segments),a.information=u.information,a.positionals.push(...u.positionals),a.subcommands=u.subcommands,a.options.push(...u.options),a},decodeAndMakeInterpreter(){let u=o.decodeAndMakeInterpreter(),a=s.decodeAndMakeInterpreter();return{async executeWithContext(p){return await a.executeWithContext(await u.executeWithContext(p))}}}}}catch(o){return{generateUsage(){let s=N(n,e);return s.segments.push({positional:"[REST]..."}),s},decodeAndMakeInterpreter(){throw o}}}}}}function N(n,e){let{positionals:t,options:r}=e.generateUsage();return{segments:t.map(o=>({positional:o.label})),information:n,positionals:t,subcommands:[],options:r}}function Fe(n,e){return{generateUsage(){let t=new Array;for(let o in n.options){let s=n.options[o];t.push(s.generateUsage())}let r=new Array;for(let o of n.positionals)r.push(o.generateUsage());return{options:t,positionals:r}},consumeAndMakeDecoder(t){let r={};for(let s in n.options){let u=n.options[s];r[s]=u.registerAndMakeDecoder(t)}let o=[];for(let s of n.positionals)o.push(s.consumeAndMakeDecoder(t));return{decodeAndMakeInterpreter(){let s={};for(let a in r)s[a]=r[a].getAndDecodeValue();let u=[];for(let a of o)u.push(a.decodeValue());return{executeWithContext(a){return e(a,{options:s,positionals:u})}}}}}}}var fe=require("fs");function se(n){return{content:n??"boolean",decoder(e){let t=e.toLowerCase();if(je.has(t))return!0;if(Ye.has(t))return!1;throw new g(new d(new i("Not a boolean: "),new i(`"${e}"`,f)))}}}var je=new Set(["true","yes","on","1","y","t"]),Ye=new Set(["false","no","off","0","n","f"]);function qe(n){return{content:n??"datetime",decoder(e){try{let t=Date.parse(e);if(isNaN(t))throw new Error;return new Date(t)}catch{throw new g(new d(new i("Not a valid ISO_8601 datetime: "),new i(`"${e}"`,f)))}}}}function Qe(n){return{content:n??"number",decoder(e){try{let t=Number(e);if(isNaN(t))throw new Error;return t}catch{throw new g(new d(new i("Not a number: "),new i(`"${e}"`,f)))}}}}function He(n){return{content:n??"integer",decoder(e){try{return BigInt(e)}catch{throw new g(new d(new i("Not an integer: "),new i(`"${e}"`,f)))}}}}function ze(n){return{content:n??"url",decoder(e){try{return new URL(e)}catch{throw new g(new d(new i("Not an URL: "),new i(`"${e}"`,f)))}}}}function Je(n){return{content:n??"string",decoder:e=>e}}function Xe(n,e,t){return{content:n,decoder:r=>t(g.tryWithContext(()=>e.decoder(r),()=>new d(new i("from: "),new i(e.content,V))))}}function Ze(n,e){return{content:e,decoder:t=>g.tryWithContext(()=>n.decoder(t),()=>new d(new i("from: "),new i(n.content,V)))}}function _e(n,e){return{content:n??"path",decoder(t){if(t.length===0)throw new Error("Path cannot be empty");if(t.includes("\0"))throw new Error("Path cannot contain null characters");if(e?.checkSyncExistAs!==void 0){let r=(0,fe.statSync)(t),o=r.isDirectory()?"directory":r.isFile()?"file":"unknown";if(e.checkSyncExistAs==="file"&&!r.isFile())throw new g(new d(new i(`Expected a 'file' but found '${o}': `),new i(`"${t}"`,f)));if(e.checkSyncExistAs==="directory"&&!r.isDirectory())throw new g(new d(new i(`Expected a 'directory' but found '${o}': `),new i(`"${t}"`,f)))}return t}}}function ie(n,e,t=!1){let r=t?s=>s:s=>s.toLowerCase(),o=new Map(e.map(s=>[r(s),s]));return{content:n,decoder(s){let u=r(s),a=o.get(u);if(a!==void 0)return a;let p=[];for(let l of e){if(p.length>=5){p.push(new i("..."));break}p.length>0&&p.push(new i(" | ")),p.push(new i(`"${l}"`,f))}throw new g(new d(new i("Invalid value: "),new i(`"${s}"`,f),new i(" (expected one of: "),...p,new i(")")))}}}function et(n,e=","){return{content:n.map(t=>t.content).join(e),decoder(t){let r=t.split(e,n.length);if(r.length!==n.length)throw new g(new d(new i(`Found ${r.length} splits: `),new i(`Expected ${n.length} splits from: `),new i(`"${t}"`,f)));return r.map((o,s)=>{let u=n[s];return g.tryWithContext(()=>u.decoder(o),()=>new d(new i(`at ${s}: `),new i(u.content,V)))})}}}function tt(n,e=","){return{content:`${n.content}[${e}${n.content}]...`,decoder(t){return t.split(e).map((o,s)=>g.tryWithContext(()=>n.decoder(o),()=>new d(new i(`at ${s}: `),new i(n.content,V))))}}}function J(n){let e=se("value"),{long:t,short:r,description:o,hint:s,aliases:u}=n;return{generateUsage(){return{short:r,long:t,annotation:"[=no]",description:o,hint:s}},registerAndMakeDecoder(a){let p=ue(a,{long:t,short:r,aliasesLongs:u?.longs,aliasesShorts:u?.shorts,parsing:{consumeShortGroup:!1,consumeNextArg:()=>!1}});return{getAndDecodeValue(){let l=a.getOptionValues(p);if(l.length>1&&xe(t),l.length===0)return n.default===void 0?!1:n.default;let h=l[0],m=h.inlined===null?"true":h.inlined;return z({long:t,short:r,type:e,input:m})}}}}}function ae(n){let{long:e,short:t,description:r,hint:o,aliases:s,type:u}=n,a=`<${u.content}>`;return{generateUsage(){return{short:t,long:e,label:a,description:r,hint:o}},registerAndMakeDecoder(p){let l=ue(p,{long:e,short:t,aliasesLongs:s?.longs,aliasesShorts:s?.shorts,parsing:{consumeShortGroup:!0,consumeNextArg(h,m){return n.defaultWhenNotInlined!==void 0?!1:h===null&&m.length===0}}});return{getAndDecodeValue(){let h=p.getOptionValues(l);h.length>1&&xe(e);let m=h[0];if(m===void 0)try{return n.defaultWhenNotDefined()}catch($){we(e,$,"not set")}if(m.inlined){let $=m.inlined;return z({long:e,short:t,label:a,type:u,input:$})}if(n.defaultWhenNotInlined!==void 0)try{return n.defaultWhenNotInlined()}catch($){we(e,$,"not inlined")}let S=m.separated[0];return z({long:e,short:t,label:a,type:u,input:S})}}}}}function nt(n){let{long:e,short:t,description:r,hint:o,aliases:s,type:u}=n,a=`<${u.content}>`;return{generateUsage(){return{short:t,long:e,label:a,annotation:" [*]",description:r,hint:o}},registerAndMakeDecoder(p){let l=ue(p,{long:e,short:t,aliasesLongs:s?.longs,aliasesShorts:s?.shorts,parsing:{consumeShortGroup:!0,consumeNextArg:(h,m)=>h===null&&m.length===0}});return{getAndDecodeValue(){return p.getOptionValues(l).map(m=>{let S=m.inlined??m.separated[0];return z({long:e,short:t,label:a,type:u,input:S})})}}}}}function z(n){return g.tryWithContext(()=>n.type.decoder(n.input),()=>{let e=new d;return n.short&&(e.push(new i(`-${n.short}`,R)),e.push(new i(", "))),e.push(new i(`--${n.long}`,R)),n.label?(e.push(new i(": ")),e.push(new i(n.label,T))):(e.push(new i(": ")),e.push(new i(n.type.content,V))),e})}function ue(n,e){let{long:t,short:r,aliasesLongs:o,aliasesShorts:s,parsing:u}=e,a=t?[t]:[];o&&a.push(...o);let p=r?[r]:[];return s&&p.push(...s),n.registerOption({longs:a,shorts:p,parsing:u})}function xe(n){throw new g(new d(new i(`--${n}`,R),new i(": Must not be set multiple times")))}function we(n,e,t){throw new g(new d(new i(`--${n}`,R),new i(`: Failed to get default value (${t})`)),e)}function ot(n){let{description:e,hint:t,type:r}=n,o=`<${r.content}>`;return{generateUsage(){return{description:e,hint:t,label:o}},consumeAndMakeDecoder(s){let u=s.consumePositional();if(u===void 0)throw new g(new d(new i(o,T),new i(": Is required, but was not provided")));return{decodeValue(){return pe(o,n.type,u)}}}}}function rt(n){let{description:e,hint:t,type:r}=n,o=`[${r.content}]`;return{generateUsage(){return{description:e,hint:t,label:o}},consumeAndMakeDecoder(s){let u=s.consumePositional();return{decodeValue(){if(u===void 0)try{return n.default()}catch{it(o)}return pe(o,n.type,u)}}}}}function st(n){let{description:e,hint:t,type:r}=n,o=`[${r.content}]`,s=`${o}...`+(n.endDelimiter?` ["${n.endDelimiter}"]`:"");return{generateUsage(){return{description:e,hint:t,label:s}},consumeAndMakeDecoder(u){let a=new Array;for(;;){let p=u.consumePositional();if(p===void 0||p===n.endDelimiter)break;a.push(p)}return{decodeValue(){return a.map(p=>pe(o,n.type,p))}}}}}function pe(n,e,t){return g.tryWithContext(()=>e.decoder(t),()=>new d(new i(n,T)))}function it(n){throw new g(new d(new i(n,T),new i(": Failed to get default value")))}var K,v,P,W,U,F,y,X,be,le,Ce,B,Se,de,Q=class{constructor(e){b(this,y);b(this,K);b(this,v);b(this,P);b(this,W);b(this,U);b(this,F);w(this,K,e),w(this,v,0),w(this,P,!1),w(this,W,new Map),w(this,U,new Map),w(this,F,new Map)}registerOption(e){let t=[...e.longs.map(o=>`--${o}`),...e.shorts.map(o=>`-${o}`)].join(", ");for(let o of e.longs){if(!x(this,y,de).call(this,o))throw new Error(`Invalid option name: --${o}`);if(c(this,W).has(o))throw new Error(`Option already registered: --${o}`)}for(let o of e.shorts){if(!x(this,y,de).call(this,o))throw new Error(`Invalid option name: -${o}`);if(c(this,U).has(o))throw new Error(`Option already registered: -${o}`);for(let s=0;s<o.length;s++){let u=o.slice(0,s);if(c(this,U).has(u))throw new Error(`Option -${o} overlap with shorter option: -${u}`)}for(let s of c(this,U).keys())if(s.startsWith(o))throw new Error(`Option -${o} overlap with longer option: -${s}`)}let r={parsing:e.parsing,results:new Array};for(let o of e.longs)c(this,W).set(o,r);for(let o of e.shorts)c(this,U).set(o,r);return c(this,F).set(t,r),t}getOptionValues(e){let t=c(this,F).get(e);if(t===void 0)throw new Error(`Unregistered option: ${e}`);return t.results}consumePositional(){for(;;){let e=x(this,y,X).call(this);if(e===void 0)return;if(!x(this,y,be).call(this,e))return e}}};K=new WeakMap,v=new WeakMap,P=new WeakMap,W=new WeakMap,U=new WeakMap,F=new WeakMap,y=new WeakSet,X=function(){let e=c(this,K)[c(this,v)];if(e!==void 0)return me(this,v)._++,!c(this,P)&&e==="--"?(w(this,P,!0),x(this,y,X).call(this)):e},be=function(e){if(c(this,P))return!1;if(e.startsWith("--")){let t=e.indexOf("=");return t===-1?x(this,y,le).call(this,e.slice(2),null):x(this,y,le).call(this,e.slice(2,t),e.slice(t+1)),!0}if(e.startsWith("-")){let t=1,r=2;for(;r<=e.length;){let o=e.slice(t,r),s=c(this,U).get(o);if(s!==void 0){let u=e.slice(r);if(x(this,y,Ce).call(this,s,o,u))return!0;t=r}r++}throw new g(new d(new i("Unexpected unknown option(s): "),new i(`-${e.slice(t)}`,f)))}return!1},le=function(e,t){let r=`--${e}`,o=c(this,W).get(e);if(o!==void 0)return x(this,y,B).call(this,o,r,t);throw new g(new d(new i("Unexpected unknown option: "),new i(r,f)))},Ce=function(e,t,r){let o=`-${t}`;return r.startsWith("=")?(x(this,y,B).call(this,e,o,r.slice(1)),!0):r.length===0?(x(this,y,B).call(this,e,o,null),!0):e.parsing.consumeShortGroup?(x(this,y,B).call(this,e,o,r),!0):(x(this,y,B).call(this,e,o,null),!1)},B=function(e,t,r){let o=new Array;for(;e.parsing.consumeNextArg(r,o,c(this,K)[c(this,v)]);)o.push(x(this,y,Se).call(this,t));e.results.push({inlined:r,separated:o})},Se=function(e){let t=x(this,y,X).call(this);if(t===void 0)throw new g(new d(new i(e,R),new i(": Requires a value, but got end of input")));if(c(this,P))throw new g(new d(new i(e,R),new i(": Requires a value before "),new i('"--"',f)));if(t.startsWith("-"))throw new g(new d(new i(e,R),new i(": Requires a value, but got: "),new i(`"${t}"`,f)));return t},de=function(e){return e.length>0&&!e.includes("=")&&!e.includes("\0")};function ge(n){let{cliName:e,usage:t,typoSupport:r}=n,o=new Array,s=new d;s.push(at("Usage:")),s.push(C(" ")),s.push(D(e));for(let a of t.segments)s.push(C(" ")),"positional"in a&&s.push(j(a.positional)),"subcommand"in a&&s.push(D(a.subcommand));o.push(s.computeStyledString(r)),o.push("");let u=new d;u.push(ut(t.information.description)),t.information.hint&&(u.push(C(" ")),u.push(Y(`(${t.information.hint})`))),o.push(u.computeStyledString(r));for(let a of t.information.details??[]){let p=new d;p.push(Y(a)),o.push(p.computeStyledString(r))}if(t.positionals.length>0){o.push(""),o.push(Z("Positionals:").computeStyledString(r));let a=new E;for(let p of t.positionals){let l=new Array;l.push(new d(C(" "))),l.push(new d(j(p.label))),l.push(...ce(p)),a.pushRow(l)}o.push(...a.computeStyledLines(r))}if(t.subcommands.length>0){o.push(""),o.push(Z("Subcommands:").computeStyledString(r));let a=new E;for(let p of t.subcommands){let l=new Array;l.push(new d(C(" "))),l.push(new d(D(p.name))),l.push(...ce(p)),a.pushRow(l)}o.push(...a.computeStyledLines(r))}if(t.options.length>0){o.push(""),o.push(Z("Options:").computeStyledString(r));let a=new E;for(let p of t.options){let l=new Array;l.push(new d(C(" "))),p.short?l.push(new d(D(`-${p.short}`),C(", "))):l.push(new d);let h=new d(D(`--${p.long}`));p.label&&(h.push(C(" ")),h.push(j(p.label))),p.annotation&&h.push(Y(p.annotation)),l.push(h),l.push(...ce(p)),a.pushRow(l)}o.push(...a.computeStyledLines(r))}if(t.information.examples){o.push(""),o.push(Z("Examples:").computeStyledString(r));for(let a of t.information.examples){let p=new d;p.push(C(" ")),p.push(Y(`# ${a.explanation}`)),o.push(p.computeStyledString(r));let l=new d;l.push(C(" ")),l.push(D(e));for(let h of a.commandArgs)if(l.push(C(" ")),typeof h=="string")l.push(h);else if("positional"in h)l.push(j(h.positional));else if("subcommand"in h)l.push(D(h.subcommand));else if("option"in h){let m=h.option;if("short"in m?l.push(D(`-${m.short}`)):l.push(D(`--${m.long}`)),m.inlined!==void 0&&(l.push(Y("=")),l.push(j(m.inlined))),m.separated!==void 0)for(let S of m.separated)l.push(C(" ")),l.push(j(S))}o.push(l.computeStyledString(r))}}return o.push(""),o}function ce(n){let e=[];return n.description&&(e.push(C(" ")),e.push(pt(n.description))),n.hint&&(e.push(C(" ")),e.push(Y(`(${n.hint})`))),e.length>0?[new d(C(" "),...e)]:[]}function at(n){return new i(n,V)}function ut(n){return new i(n,ne)}function pt(n){return new i(n)}function Z(n){return new i(n,te)}function Y(n){return new i(n,oe)}function D(n){return new i(n,R)}function j(n){return new i(n,T)}function C(n){return new i(n)}async function lt(n,e,t,r,o){let s=new Q(e),u=new Array,a=O.none(),p=o?.colorSetup??"flag";if(p==="flag"){let m=ae({long:"color",type:ie("color-mode",["auto","always","never","mock"]),defaultWhenNotDefined:()=>"auto",defaultWhenNotInlined:()=>"always"}).registerAndMakeDecoder(s);u.push(()=>{try{a=Te(m.getAndDecodeValue())}catch(S){throw a=O.inferFromEnv(),S}})}else p==="env"?a=O.inferFromEnv():a=Te(p);if(o?.usageOnHelp??!0){let m=J({long:"help"}).registerAndMakeDecoder(s);u.push(S=>{if(m.getAndDecodeValue())return console.log(Re(n,S,a)),0})}if(o?.buildVersion){let m=J({long:"version"}).registerAndMakeDecoder(s);u.push(()=>{if(m.getAndDecodeValue())return console.log([n,o.buildVersion].join(" ")),0})}let l=r.consumeAndMakeDecoder(s);for(;;)try{if(s.consumePositional()===void 0)break}catch{}let h=o?.onExit??process.exit;try{for(let S of u){let $=S(l);if($!==void 0)return h($)}let m=l.decodeAndMakeInterpreter();try{return await m.executeWithContext(t),h(0)}catch(S){return Ae(o?.onError,S,a),h(1)}}catch(m){return(o?.usageOnError??!0)&&console.error(Re(n,l,a)),Ae(o?.onError,m,a),h(1)}}function Ae(n,e,t){n!==void 0?n(e):console.error(t.computeStyledErrorMessage(e))}function Re(n,e,t){return ge({cliName:n,usage:e.generateUsage(),typoSupport:t}).join(`
2
+ `)}function Te(n){switch(n){case"auto":return O.inferFromEnv();case"always":return O.tty();case"never":return O.none();case"mock":return O.mock()}}0&&(module.exports={ReaderArgs,TypoError,TypoGrid,TypoString,TypoSupport,TypoText,command,commandChained,commandWithSubcommands,operation,optionFlag,optionRepeatable,optionSingleValue,positionalOptional,positionalRequired,positionalVariadics,runAndExit,type,typeBoolean,typeChoice,typeConverted,typeDatetime,typeInteger,typeList,typeNumber,typePath,typeRenamed,typeTuple,typeUrl,typoStyleConstants,typoStyleFailure,typoStyleLogic,typoStyleQuote,typoStyleRegularStrong,typoStyleRegularWeaker,typoStyleTitle,typoStyleUserInput,usageToStyledLines});
3
3
  //# sourceMappingURL=index.js.map