cli-kiss 0.2.2 → 0.2.4

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 J=Object.defineProperty;var wt=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var xt=Object.prototype.hasOwnProperty;var ct=e=>{throw TypeError(e)};var bt=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:!0})},Ct=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ft(t))!xt.call(e,o)&&o!==n&&J(e,o,{get:()=>t[o],enumerable:!(r=wt(t,o))||r.enumerable});return e};var St=e=>Ct(J({},"__esModule",{value:!0}),e);var z=(e,t,n)=>t.has(e)||ct("Cannot "+n);var c=(e,t,n)=>(z(e,t,"read from private field"),n?n.call(e):t.get(e)),w=(e,t,n)=>t.has(e)?ct("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),m=(e,t,n,r)=>(z(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),h=(e,t,n)=>(z(e,t,"access private method"),n);var gt=(e,t,n,r)=>({set _(o){m(e,t,o,n)},get _(){return c(e,t,r)}});var ee={};bt(ee,{ReaderArgs:()=>N,TypoError:()=>d,TypoGrid:()=>A,TypoString:()=>s,TypoSupport:()=>k,TypoText:()=>l,command:()=>$t,commandChained:()=>vt,commandWithSubcommands:()=>At,operation:()=>Ft,optionFlag:()=>Yt,optionRepeatable:()=>Ht,optionSingleValue:()=>qt,positionalOptional:()=>Jt,positionalRequired:()=>Qt,positionalVariadics:()=>zt,runAndExit:()=>te,typeBoolean:()=>q,typeConverted:()=>Kt,typeDate:()=>Bt,typeInteger:()=>Wt,typeList:()=>jt,typeNumber:()=>Lt,typeOneOf:()=>Dt,typeString:()=>Mt,typeTuple:()=>Nt,typeUrl:()=>Gt,typoStyleConstants:()=>x,typoStyleFailure:()=>dt,typoStyleLogic:()=>S,typoStyleQuote:()=>f,typoStyleRegularStrong:()=>Z,typoStyleRegularWeaker:()=>_,typoStyleTitle:()=>X,typoStyleUserInput:()=>b,usageToStyledLines:()=>lt});module.exports=St(ee);var X={fgColor:"darkGreen",bold:!0},S={fgColor:"darkMagenta",bold:!0},f={fgColor:"darkYellow",bold:!0},dt={fgColor:"darkRed",bold:!0},x={fgColor:"darkCyan",bold:!0},b={fgColor:"darkBlue",bold:!0},Z={bold:!0},_={italic:!0,dim:!0},B,D,s=class{constructor(t,n={}){w(this,B);w(this,D);m(this,B,t),m(this,D,n)}getRawString(){return c(this,B)}computeStyledString(t){return t.computeStyledString(c(this,B),c(this,D))}};B=new WeakMap,D=new WeakMap;var U,tt=class tt{constructor(...t){w(this,U);m(this,U,[]);for(let n of t)n instanceof tt?this.pushText(n):n instanceof s?this.pushString(n):typeof n=="string"&&this.pushString(new s(n))}pushString(t){c(this,U).push(t)}pushText(t){for(let n of c(t,U))c(this,U).push(n)}computeStyledString(t){return c(this,U).map(n=>n.computeStyledString(t)).join("")}computeRawString(){return c(this,U).map(t=>t.getRawString()).join("")}computeRawLength(){let t=0;for(let n of c(this,U))t+=n.getRawString().length;return t}};U=new WeakMap;var l=tt,$,A=class{constructor(){w(this,$);m(this,$,[])}pushRow(t){c(this,$).push(t)}computeStyledGrid(t){let n=new Array,r=new Array;for(let o of c(this,$))for(let a=0;a<o.length;a++){let i=o[a].computeRawLength();(n[a]===void 0||i>n[a])&&(n[a]=i)}for(let o of c(this,$)){let a=new Array;for(let p=0;p<o.length;p++){let i=o[p],u=i.computeStyledString(t);if(a.push(u),p<o.length-1){let g=i.computeRawLength(),T=" ".repeat(n[p]-g);a.push(T)}}r.push(a)}return r}};$=new WeakMap;var L,Y=class Y extends Error{constructor(n,r){let o=new l;o.pushText(n),r instanceof Y?(o.pushString(new s(": ")),o.pushText(c(r,L))):r instanceof Error?o.pushString(new s(`: ${r.message}`)):r!==void 0&&o.pushString(new s(`: ${String(r)}`));super(o.computeRawString());w(this,L);m(this,L,o)}computeStyledString(n){return c(this,L).computeStyledString(n)}static tryWithContext(n,r){try{return n()}catch(o){throw new Y(r(),o)}}};L=new WeakMap;var d=Y,P,C=class C{constructor(t){w(this,P);m(this,P,t)}static none(){return new C("none")}static tty(){return new C("tty")}static mock(){return new C("mock")}static inferFromProcess(){if(!process)return C.none();if(process.env){if(process.env.FORCE_COLOR==="0")return C.none();if(process.env.FORCE_COLOR)return C.tty();if("NO_COLOR"in process.env)return C.none()}return process.stdout&&process.stdout.isTTY?C.tty():C.none()}computeStyledString(t,n){if(c(this,P)==="none")return t;if(c(this,P)==="tty"){let r=n.fgColor?Vt[n.fgColor]:"",o=n.bgColor?It[n.bgColor]:"",a=n.bold?Ut:"",p=n.dim?Rt:"",i=n.italic?Ot:"",u=n.underline?Pt:"",g=n.strikethrough?kt:"";return`${r}${o}${a}${p}${i}${u}${g}${t}${Tt}`}if(c(this,P)==="mock"){let r=n.fgColor?`{${t}}@${n.fgColor}`:t,o=n.bgColor?`{${r}}#${n.bgColor}`:r,a=n.bold?`{${o}}+`:o,p=n.dim?`{${a}}-`:a,i=n.italic?`{${p}}*`:p,u=n.underline?`{${i}}_`:i;return n.strikethrough?`{${u}}~`:u}throw new Error(`Unknown TypoSupport kind: ${c(this,P)}`)}computeStyledErrorMessage(t){return[this.computeStyledString("Error:",dt),t instanceof d?t.computeStyledString(this):t instanceof Error?t.message:String(t)].join(" ")}};P=new WeakMap;var k=C,Tt="\x1B[0m",Ut="\x1B[1m",Rt="\x1B[2m",Ot="\x1B[3m",Pt="\x1B[4m",kt="\x1B[9m",Vt={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"},It={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 $t(e,t){return{getInformation(){return e},createFactory(n){function r(){let o=t.generateUsage();return{breadcrumbs:o.positionals.map(a=>v(a.label)),information:e,positionals:o.positionals,subcommands:[],options:o.options}}try{let o=t.createFactory(n),a=n.consumePositional();if(a!==void 0)throw new d(new l(new s("Unexpected argument: "),new s(`"${a}"`,f)));return{generateUsage:r,createInstance(){let p=o.createInstance();return{async executeWithContext(i){return await p.executeWithContext(i)}}}}}catch(o){return{generateUsage:r,createInstance(){throw o}}}}}}function At(e,t,n){return{getInformation(){return e},createFactory(r){try{let o=t.createFactory(r),a=r.consumePositional();if(a===void 0)throw new d(new l(new s("<SUBCOMMAND>",b),new s(": Is required, but was not provided")));let p=n[a];if(p===void 0)throw new d(new l(new s("<SUBCOMMAND>",b),new s(": Invalid value: "),new s(`"${a}"`,f)));let i=p.createFactory(r);return{generateUsage(){let u=t.generateUsage(),g=i.generateUsage();return{breadcrumbs:u.positionals.map(T=>v(T.label)).concat([Et(a)]).concat(g.breadcrumbs),information:g.information,positionals:u.positionals.concat(g.positionals),subcommands:g.subcommands,options:u.options.concat(g.options)}},createInstance(){let u=o.createInstance(),g=i.createInstance();return{async executeWithContext(T){return await g.executeWithContext(await u.executeWithContext(T))}}}}}catch(o){return{generateUsage(){let a=t.generateUsage();return{breadcrumbs:a.positionals.map(p=>v(p.label)).concat([v("<SUBCOMMAND>")]),information:e,positionals:a.positionals,subcommands:Object.entries(n).map(p=>{let i=p[1].getInformation();return{name:p[0],description:i.description,hint:i.hint}}),options:a.options}},createInstance(){throw o}}}}}}function vt(e,t,n){return{getInformation(){return e},createFactory(r){try{let o=t.createFactory(r),a=n.createFactory(r);return{generateUsage(){let p=t.generateUsage(),i=a.generateUsage();return{breadcrumbs:p.positionals.map(u=>v(u.label)).concat(i.breadcrumbs),information:i.information,positionals:p.positionals.concat(i.positionals),subcommands:i.subcommands,options:p.options.concat(i.options)}},createInstance(){let p=o.createInstance(),i=a.createInstance();return{async executeWithContext(u){return await i.executeWithContext(await p.executeWithContext(u))}}}}}catch(o){return{generateUsage(){let a=t.generateUsage();return{breadcrumbs:a.positionals.map(p=>v(p.label)).concat([v("[REST]...")]),information:e,positionals:a.positionals,subcommands:[],options:a.options}},createInstance(){throw o}}}}}}function v(e){return{positional:e}}function Et(e){return{command:e}}function Ft(e,t){return{generateUsage(){let n=new Array;for(let o in e.options){let a=e.options[o];a&&n.push(a.generateUsage())}let r=new Array;for(let o of e.positionals)r.push(o.generateUsage());return{options:n,positionals:r}},createFactory(n){let r={};for(let a in e.options){let p=e.options[a];r[a]=p.createParser(n)}let o=[];for(let a of e.positionals)o.push(a.createParser(n));return{createInstance(){let a={};for(let i in r)a[i]=r[i].parseValue();let p=[];for(let i of o)p.push(i.parseValue());return{executeWithContext(i){return t(i,{options:a,positionals:p})}}}}}}}var q={content:"Boolean",decoder(e){let t=e.toLowerCase();if(t==="true"||t==="yes")return!0;if(t==="false"||t==="no")return!1;throw new d(new l(new s("Invalid value: "),new s(`"${e}"`,f)))}},Bt={content:"Date",decoder(e){try{let t=Date.parse(e);if(isNaN(t))throw new Error;return new Date(t)}catch{throw new d(new l(new s("Not a valid ISO_8601: "),new s(`"${e}"`,f)))}}},Lt={content:"Number",decoder(e){try{let t=Number(e);if(isNaN(t))throw new Error;return t}catch{throw new d(new l(new s("Unable to parse: "),new s(`"${e}"`,f)))}}},Wt={content:"Integer",decoder(e){try{return BigInt(e)}catch{throw new d(new l(new s("Unable to parse: "),new s(`"${e}"`,f)))}}},Gt={content:"Url",decoder(e){try{return new URL(e)}catch{throw new d(new l(new s("Unable to parse: "),new s(`"${e}"`,f)))}}},Mt={content:"String",decoder(e){return e}};function Kt(e,t){return{content:t.content,decoder:n=>t.decoder(d.tryWithContext(()=>e.decoder(n),()=>new l(new s("from: "),new s(e.content,S))))}}function Dt(e,t){let n=new Set(t);return{content:e,decoder(r){if(n.has(r))return r;let o=[];for(let a of t){if(o.length>=5){o.push(new s("..."));break}o.length>0&&o.push(new s(" | ")),o.push(new s(`"${a}"`,f))}throw new d(new l(new s("Invalid value: "),new s(`"${r}"`,f),new s(" (expected one of: "),...o,new s(")")))}}}function Nt(e,t=","){return{content:e.map(n=>n.content).join(t),decoder(n){let r=n.split(t,e.length);if(r.length!==e.length)throw new d(new l(new s(`Found ${r.length} splits: `),new s(`Expected ${e.length} splits from: `),new s(`"${n}"`,f)));return r.map((o,a)=>{let p=e[a];return d.tryWithContext(()=>p.decoder(o),()=>new l(new s(`at ${a}: `),new s(p.content,S)))})}}}function jt(e,t=","){return{content:`${e.content}[${t}${e.content}]...`,decoder(n){return n.split(t).map((o,a)=>d.tryWithContext(()=>e.decoder(o),()=>new l(new s(`at ${a}: `),new s(e.content,S))))}}}function Yt(e){let t=`<${q.content.toUpperCase()}>`;return{generateUsage(){return{description:e.description,hint:e.hint,long:e.long,short:e.short,label:void 0}},createParser(n){let r=nt(n,{...e,valued:!1});return{parseValue(){let o=n.getOptionValues(r);if(o.length>1)throw new d(new l(new s(`--${e.long}`,x),new s(": Must not be set multiple times")));let a=o[0];if(a===void 0)try{return e.default?e.default():!1}catch(p){throw new d(new l(new s(`--${e.long}`,x),new s(": Failed to get default value")),p)}return et(e.long,t,q,a)}}}}}function qt(e){let t=`<${e.label??e.type.content.toUpperCase()}>`;return{generateUsage(){return{description:e.description,hint:e.hint,long:e.long,short:e.short,label:t}},createParser(n){let r=nt(n,{...e,valued:!0});return{parseValue(){let o=n.getOptionValues(r);if(o.length>1)throw new d(new l(new s(`--${e.long}`,x),new s(": Requires a single value, but got multiple")));let a=o[0];if(a===void 0)try{return e.default()}catch(p){throw new d(new l(new s(`--${e.long}`,x),new s(": Failed to get default value")),p)}return et(e.long,t,e.type,a)}}}}}function Ht(e){let t=`<${e.label??e.type.content.toUpperCase()}>`;return{generateUsage(){return{description:e.description,hint:e.hint,long:e.long,short:e.short,label:t}},createParser(n){let r=nt(n,{...e,valued:!0});return{parseValue(){return n.getOptionValues(r).map(a=>et(e.long,t,e.type,a))}}}}}function et(e,t,n,r){return d.tryWithContext(()=>n.decoder(r),()=>new l(new s(`--${e}`,x),new s(": "),new s(t,b),new s(": "),new s(n.content,S)))}function nt(e,t){let{long:n,short:r,aliases:o,valued:a}=t,p=n?[n]:[];o?.longs&&p.push(...o?.longs);let i=r?[r]:[];return o?.shorts&&i.push(...o?.shorts),e.registerOption({longs:p,shorts:i,valued:a})}function Qt(e){let t=`<${e.label??e.type.content.toUpperCase()}>`;return{generateUsage(){return{description:e.description,hint:e.hint,label:t}},createParser(n){let r=n.consumePositional();if(r===void 0)throw new d(new l(new s(t,b),new s(": Is required, but was not provided")));return{parseValue(){return ot(t,e.type,r)}}}}}function Jt(e){let t=`[${e.label??e.type.content.toUpperCase()}]`;return{generateUsage(){return{description:e.description,hint:e.hint,label:t}},createParser(n){let r=n.consumePositional();return{parseValue(){if(r===void 0)try{return e.default()}catch(o){throw new d(new l(new s(t,b),new s(": Failed to get default value")),o)}return ot(t,e.type,r)}}}}}function zt(e){let t=`[${e.label??e.type.content.toUpperCase()}]`;return{generateUsage(){return{description:e.description,hint:e.hint,label:`${t}...`+(e.endDelimiter?`["${e.endDelimiter}"]`:"")}},createParser(n){let r=new Array;for(;;){let o=n.consumePositional();if(o===void 0||o===e.endDelimiter)break;r.push(o)}return{parseValue(){return r.map(o=>ot(t,e.type,o))}}}}}function ot(e,t,n){return d.tryWithContext(()=>t.decoder(n),()=>new l(new s(e,b),new s(": "),new s(t.content,S)))}var j,W,I,E,R,F,G,y,H,yt,rt,mt,st,V,N=class{constructor(t){w(this,y);w(this,j);w(this,W);w(this,I);w(this,E);w(this,R);w(this,F);w(this,G);m(this,j,t),m(this,W,0),m(this,I,!1),m(this,E,new Map),m(this,R,new Map),m(this,F,new Map),m(this,G,new Map)}registerOption(t){let n=[...t.longs.map(r=>`--${r}`),...t.shorts.map(r=>`-${r}`)].join(", ");for(let r of t.longs){if(c(this,E).has(r))throw new Error(`Option already registered: --${r}`);c(this,E).set(r,n)}for(let r of t.shorts){if(c(this,R).has(r))throw new Error(`Option already registered: -${r}`);for(let o=0;o<r.length;o++){let a=r.slice(0,o);if(c(this,R).has(a))throw new Error(`Option -${r} overlap with shorter option: -${a}`)}for(let o of c(this,R).keys())if(o.startsWith(r))throw new Error(`Option -${r} overlap with longer option: -${o}`);c(this,R).set(r,n)}return c(this,F).set(n,t.valued),c(this,G).set(n,new Array),n}getOptionValues(t){let n=c(this,G).get(t);if(n===void 0)throw new Error(`Unregistered option: ${t}`);return n}consumePositional(){for(;;){let t=h(this,y,H).call(this);if(t===null)return;if(h(this,y,yt).call(this,t))return t}}};j=new WeakMap,W=new WeakMap,I=new WeakMap,E=new WeakMap,R=new WeakMap,F=new WeakMap,G=new WeakMap,y=new WeakSet,H=function(){let t=c(this,j)[c(this,W)];return t===void 0?null:(gt(this,W)._++,!c(this,I)&&t==="--"?(m(this,I,!0),h(this,y,H).call(this)):t)},yt=function(t){if(c(this,I))return!0;if(t.startsWith("--")){let n=t.indexOf("=");return n===-1?h(this,y,rt).call(this,t.slice(2),null):h(this,y,rt).call(this,t.slice(2,n),t.slice(n+1)),!1}if(t.startsWith("-")){let n=1,r=2;for(;r<=t.length;){let o=h(this,y,mt).call(this,t.slice(n,r),t.slice(r));if(o===!0)return!1;o===!1&&(n=r),r++}throw new d(new l(new s(`-${t.slice(n)}`,x),new s(": Unexpected unknown option")))}return!0},rt=function(t,n){let r=`--${t}`,o=c(this,E).get(t);if(o!==void 0)return n!==null?h(this,y,V).call(this,o,n):c(this,F).get(o)?h(this,y,V).call(this,o,h(this,y,st).call(this,r)):h(this,y,V).call(this,o,"true");throw new d(new l(new s(r,x),new s(": Unexpected unknown option")))},mt=function(t,n){let r=c(this,R).get(t);return r!==void 0?n.startsWith("=")?(h(this,y,V).call(this,r,n.slice(1)),!0):c(this,F).get(r)?(n===""?h(this,y,V).call(this,r,h(this,y,st).call(this,`-${t}`)):h(this,y,V).call(this,r,n),!0):(h(this,y,V).call(this,r,"true"),n===""):null},st=function(t){let n=h(this,y,H).call(this);if(n===null)throw new d(new l(new s(t,x),new s(": Requires a value, but got end of input")));if(c(this,I))throw new d(new l(new s(t,x),new s(": Requires a value before "),new s('"--"',f)));if(n.startsWith("-"))throw new d(new l(new s(t,x),new s(": Requires a value, but got: "),new s(`"${n}"`,f)));return n},V=function(t,n){this.getOptionValues(t).push(n)};function lt(e){let{cliName:t,commandUsage:n,typoSupport:r}=e,o=new Array,a=[Xt("Usage:").computeStyledString(r),M(t).computeStyledString(r)].concat(n.breadcrumbs.map(i=>{if("positional"in i)return pt(i.positional).computeStyledString(r);if("command"in i)return M(i.command).computeStyledString(r);throw new Error(`Unknown breadcrumb: ${JSON.stringify(i)}`)}));o.push(a.join(" ")),o.push("");let p=new l;p.pushString(Zt(n.information.description)),n.information.hint&&(p.pushString(O(" ")),p.pushString(Q(`(${n.information.hint})`))),o.push(p.computeStyledString(r));for(let i of n.information.details??[]){let u=new l;u.pushString(Q(i)),o.push(u.computeStyledString(r))}if(n.positionals.length>0){o.push(""),o.push(it("Positionals:").computeStyledString(r));let i=new A;for(let u of n.positionals){let g=new Array;g.push(new l(O(" "))),g.push(new l(pt(u.label))),g.push(...at(u)),i.pushRow(g)}o.push(...i.computeStyledGrid(r).map(u=>u.join("")))}if(n.subcommands.length>0){o.push(""),o.push(it("Subcommands:").computeStyledString(r));let i=new A;for(let u of n.subcommands){let g=new Array;g.push(new l(O(" "))),g.push(new l(M(u.name))),g.push(...at(u)),i.pushRow(g)}o.push(...i.computeStyledGrid(r).map(u=>u.join("")))}if(n.options.length>0){o.push(""),o.push(it("Options:").computeStyledString(r));let i=new A;for(let u of n.options){let g=new Array;g.push(new l(O(" "))),u.short?g.push(new l(M(`-${u.short}`),O(", "))):g.push(new l),u.label?g.push(new l(M(`--${u.long}`),O(" "),pt(u.label))):g.push(new l(M(`--${u.long}`),Q("[=no]"))),g.push(...at(u)),i.pushRow(g)}o.push(...i.computeStyledGrid(r).map(u=>u.join("")))}return o.push(""),o}function at(e){let t=[];return e.description&&(t.push(O(" ")),t.push(_t(e.description))),e.hint&&(t.push(O(" ")),t.push(Q(`(${e.hint})`))),t.length>0?[new l(O(" "),...t)]:[]}function Xt(e){return new s(e,S)}function Zt(e){return new s(e,Z)}function _t(e){return new s(e)}function it(e){return new s(e,X)}function Q(e){return new s(e,_)}function M(e){return new s(e,x)}function pt(e){return new s(e,b)}function O(e){return new s(e)}async function te(e,t,n,r,o){let a=new N(t),p=o?.usageOnHelp??!0;p&&a.registerOption({shorts:[],longs:["help"],valued:!1});let i=o?.buildVersion;i&&a.registerOption({shorts:[],longs:["version"],valued:!1});let u=r.createFactory(a);for(;;)try{if(a.consumePositional()===void 0)break}catch{}let g=o?.onExit??process.exit,T=o?.useTtyColors===void 0?k.inferFromProcess():o.useTtyColors==="mock"?k.mock():o.useTtyColors?k.tty():k.none();if(p&&a.getOptionValues("--help").length>0)return console.log(ht(e,u,T)),g(0);if(i&&a.getOptionValues("--version").length>0)return console.log([e,i].join(" ")),g(0);try{let K=u.createInstance();try{return await K.executeWithContext(n),g(0)}catch(ut){return o?.onError?o.onError(ut):console.error(T.computeStyledErrorMessage(ut)),g(1)}}catch(K){return(o?.usageOnError??!0)&&console.error(ht(e,u,T)),console.error(T.computeStyledErrorMessage(K)),g(1)}}function ht(e,t,n){return lt({cliName:e,commandUsage:t.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,typeConverted,typeDate,typeInteger,typeList,typeNumber,typeOneOf,typeString,typeTuple,typeUrl,typoStyleConstants,typoStyleFailure,typoStyleLogic,typoStyleQuote,typoStyleRegularStrong,typoStyleRegularWeaker,typoStyleTitle,typoStyleUserInput,usageToStyledLines});
1
+ "use strict";var X=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var Ce=Object.prototype.hasOwnProperty;var le=e=>{throw TypeError(e)};var Se=(e,t)=>{for(var n in t)X(e,n,{get:t[n],enumerable:!0})},Re=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of be(t))!Ce.call(e,o)&&o!==n&&X(e,o,{get:()=>t[o],enumerable:!(r=xe(t,o))||r.enumerable});return e};var Ae=e=>Re(X({},"__esModule",{value:!0}),e);var Z=(e,t,n)=>t.has(e)||le("Cannot "+n);var g=(e,t,n)=>(Z(e,t,"read from private field"),n?n.call(e):t.get(e)),b=(e,t,n)=>t.has(e)?le("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),f=(e,t,n,r)=>(Z(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),x=(e,t,n)=>(Z(e,t,"access private method"),n);var ce=(e,t,n,r)=>({set _(o){f(e,t,o,n)},get _(){return g(e,t,r)}});var it={};Se(it,{ReaderArgs:()=>j,TypoError:()=>d,TypoGrid:()=>D,TypoString:()=>s,TypoSupport:()=>$,TypoText:()=>c,command:()=>De,commandChained:()=>ve,commandWithSubcommands:()=>Me,operation:()=>Ee,optionFlag:()=>ze,optionRepeatable:()=>Xe,optionSingleValue:()=>Je,positionalOptional:()=>_e,positionalRequired:()=>Ze,positionalVariadics:()=>et,runAndExit:()=>rt,typeBoolean:()=>H,typeDate:()=>Ge,typeInteger:()=>Ke,typeList:()=>Qe,typeMapped:()=>Ye,typeNumber:()=>Ne,typeOneOf:()=>qe,typeString:()=>je,typeTuple:()=>He,typeUrl:()=>Fe,typoStyleConstants:()=>w,typoStyleFailure:()=>ge,typoStyleLogic:()=>k,typoStyleQuote:()=>y,typoStyleRegularStrong:()=>ee,typoStyleRegularWeaker:()=>te,typoStyleTitle:()=>_,typoStyleUserInput:()=>R,usageToStyledLines:()=>ue});module.exports=Ae(it);var _={fgColor:"darkGreen",bold:!0},k={fgColor:"darkMagenta",bold:!0},y={fgColor:"darkYellow",bold:!0},ge={fgColor:"darkRed",bold:!0},w={fgColor:"darkCyan",bold:!0},R={fgColor:"darkBlue",bold:!0},ee={bold:!0},te={italic:!0,dim:!0},L,F,s=class{constructor(t,n={}){b(this,L);b(this,F);f(this,L,t),f(this,F,n)}computeStyledString(t){return t.computeStyledString(g(this,L),g(this,F))}getRawString(){return g(this,L)}};L=new WeakMap,F=new WeakMap;var S,ne=class ne{constructor(...t){b(this,S);f(this,S,[]);for(let n of t)this.push(n)}push(t){if(typeof t=="string")g(this,S).push(new s(t));else if(t instanceof ne)g(this,S).push(...g(t,S));else if(Array.isArray(t))for(let n of t)g(this,S).push(n);else g(this,S).push(t)}computeStyledString(t){return g(this,S).map(n=>n.computeStyledString(t)).join("")}computeRawString(){return g(this,S).map(t=>t.getRawString()).join("")}computeRawLength(){let t=0;for(let n of g(this,S))t+=n.getRawString().length;return t}};S=new WeakMap;var c=ne,P,D=class{constructor(){b(this,P);f(this,P,[])}pushRow(t){g(this,P).push(t)}computeStyledLines(t){let n=new Array,r=new Array;for(let o of g(this,P))for(let i=0;i<o.length;i++){let a=o[i].computeRawLength();(n[i]===void 0||a>n[i])&&(n[i]=a)}for(let o of g(this,P)){let i=new Array;for(let u=0;u<o.length;u++){let a=o[u];if(i.push(a.computeStyledString(t)),u<o.length-1){let l=a.computeRawLength(),p=" ".repeat(n[u]-l);i.push(p)}}r.push(i.join(""))}return r}};P=new WeakMap;var E,q=class q extends Error{constructor(n,r){let o=new c;o.push(n),r instanceof q?(o.push(new s(": ")),o.push(g(r,E))):r instanceof Error?o.push(new s(`: ${r.message}`)):r!==void 0&&o.push(new s(`: ${String(r)}`));super(o.computeRawString());b(this,E);f(this,E,o)}computeStyledString(n){return g(this,E).computeStyledString(n)}static tryWithContext(n,r){try{return n()}catch(o){throw new q(r(),o)}}};E=new WeakMap;var d=q,V,T=class T{constructor(t){b(this,V);f(this,V,t)}static none(){return new T("none")}static tty(){return new T("tty")}static mock(){return new T("mock")}static inferFromProcess(){if(!process)return T.none();if(process.env){if(process.env.FORCE_COLOR==="0")return T.none();if(process.env.FORCE_COLOR)return T.tty();if("NO_COLOR"in process.env)return T.none()}return process.stdout&&process.stdout.isTTY?T.tty():T.none()}computeStyledString(t,n){if(g(this,V)==="none")return t;if(g(this,V)==="tty"){let r=n.fgColor?Ie[n.fgColor]:"",o=n.bgColor?Pe[n.bgColor]:"",i=n.bold?ke:"",u=n.dim?Oe:"",a=n.italic?Ue:"",l=n.underline?Ve:"",p=n.strikethrough?$e:"";return`${r}${o}${i}${u}${a}${l}${p}${t}${Te}`}if(g(this,V)==="mock"){let r=n.fgColor?`{${t}}@${n.fgColor}`:t,o=n.bgColor?`{${r}}#${n.bgColor}`:r,i=n.bold?`{${o}}+`:o,u=n.dim?`{${i}}-`:i,a=n.italic?`{${u}}*`:u,l=n.underline?`{${a}}_`:a;return n.strikethrough?`{${l}}~`:l}throw new Error(`Unknown TypoSupport kind: ${g(this,V)}`)}computeStyledErrorMessage(t){return[this.computeStyledString("Error:",ge),t instanceof d?t.computeStyledString(this):t instanceof Error?t.message:String(t)].join(" ")}};V=new WeakMap;var $=T,Te="\x1B[0m",ke="\x1B[1m",Oe="\x1B[2m",Ue="\x1B[3m",Ve="\x1B[4m",$e="\x1B[9m",Ie={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"},Pe={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 De(e,t){return{getInformation(){return e},consumeAndMakeDecoder(n){try{let r=t.consumeAndMakeDecoder(n),o=n.consumePositional();if(o!==void 0)throw new d(new c(new s("Unexpected argument: "),new s(`"${o}"`,y)));return{generateUsage:()=>W(e,t),decodeAndMakeInterpreter(){let i=r.decodeAndMakeInterpreter();return{async executeWithContext(u){return await i.executeWithContext(u)}}}}}catch(r){return{generateUsage:()=>W(e,t),decodeAndMakeInterpreter(){throw r}}}}}}function Me(e,t,n){return{getInformation(){return e},consumeAndMakeDecoder(r){try{let o=t.consumeAndMakeDecoder(r),i=r.consumePositional();if(i===void 0)throw new d(new c(new s("<SUBCOMMAND>",R),new s(": Is required, but was not provided")));let u=n[i];if(u===void 0)throw new d(new c(new s("<SUBCOMMAND>",R),new s(": Invalid value: "),new s(`"${i}"`,y)));let a=u.consumeAndMakeDecoder(r);return{generateUsage(){let l=a.generateUsage(),p=W(e,t);return p.segments.push(Le(i)),p.segments.push(...l.segments),p.information=l.information,p.positionals.push(...l.positionals),p.subcommands=l.subcommands,p.options.push(...l.options),p},decodeAndMakeInterpreter(){let l=o.decodeAndMakeInterpreter(),p=a.decodeAndMakeInterpreter();return{async executeWithContext(m){return await p.executeWithContext(await l.executeWithContext(m))}}}}}catch(o){return{generateUsage(){let i=W(e,t);i.segments.push(oe("<SUBCOMMAND>"));for(let[u,a]of Object.entries(n)){let{description:l,hint:p}=a.getInformation();i.subcommands.push({name:u,description:l,hint:p})}return i},decodeAndMakeInterpreter(){throw o}}}}}}function ve(e,t,n){return{getInformation(){return e},consumeAndMakeDecoder(r){try{let o=t.consumeAndMakeDecoder(r),i=n.consumeAndMakeDecoder(r);return{generateUsage(){let u=i.generateUsage(),a=W(e,t);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=i.decodeAndMakeInterpreter();return{async executeWithContext(l){return await a.executeWithContext(await u.executeWithContext(l))}}}}}catch(o){return{generateUsage(){let i=W(e,t);return i.segments.push(oe("[REST]...")),i},decodeAndMakeInterpreter(){throw o}}}}}}function oe(e){return{positional:e}}function Le(e){return{subcommand:e}}function W(e,t){let{positionals:n,options:r}=t.generateUsage();return{segments:n.map(o=>oe(o.label)),information:e,positionals:n,subcommands:[],options:r}}function Ee(e,t){return{generateUsage(){let n=new Array;for(let o in e.options){let i=e.options[o];n.push(i.generateUsage())}let r=new Array;for(let o of e.positionals)r.push(o.generateUsage());return{options:n,positionals:r}},consumeAndMakeDecoder(n){let r={};for(let i in e.options){let u=e.options[i];r[i]=u.registerAndMakeDecoder(n)}let o=[];for(let i of e.positionals)o.push(i.consumeAndMakeDecoder(n));return{decodeAndMakeInterpreter(){let i={};for(let a in r)i[a]=r[a].getAndDecodeValue();let u=[];for(let a of o)u.push(a.decodeValue());return{executeWithContext(a){return t(a,{options:i,positionals:u})}}}}}}}var H={content:"Boolean",decoder(e){let t=e.toLowerCase();if(We.has(t))return!0;if(Be.has(t))return!1;throw new d(new c(new s("Invalid value: "),new s(`"${e}"`,y)))}},We=new Set(["true","yes","on","1","y","t"]),Be=new Set(["false","no","off","0","n","f"]),Ge={content:"Date",decoder(e){try{let t=Date.parse(e);if(isNaN(t))throw new Error;return new Date(t)}catch{throw new d(new c(new s("Not a valid ISO_8601: "),new s(`"${e}"`,y)))}}},Ne={content:"Number",decoder(e){try{let t=Number(e);if(isNaN(t))throw new Error;return t}catch{throw new d(new c(new s("Unable to parse: "),new s(`"${e}"`,y)))}}},Ke={content:"Integer",decoder(e){try{return BigInt(e)}catch{throw new d(new c(new s("Unable to parse: "),new s(`"${e}"`,y)))}}},Fe={content:"Url",decoder(e){try{return new URL(e)}catch{throw new d(new c(new s("Unable to parse: "),new s(`"${e}"`,y)))}}},je={content:"String",decoder(e){return e}};function Ye(e,t){return{content:t.content,decoder:n=>t.decoder(d.tryWithContext(()=>e.decoder(n),()=>new c(new s("from: "),new s(e.content,k))))}}function qe(e,t){return{content:e,decoder(n){for(let o of t)if(n===o)return o;let r=[];for(let o of t){if(r.length>=5){r.push(new s("..."));break}r.length>0&&r.push(new s(" | ")),r.push(new s(`"${o}"`,y))}throw new d(new c(new s("Invalid value: "),new s(`"${n}"`,y),new s(" (expected one of: "),...r,new s(")")))}}}function He(e,t=","){return{content:e.map(n=>n.content).join(t),decoder(n){let r=n.split(t,e.length);if(r.length!==e.length)throw new d(new c(new s(`Found ${r.length} splits: `),new s(`Expected ${e.length} splits from: `),new s(`"${n}"`,y)));return r.map((o,i)=>{let u=e[i];return d.tryWithContext(()=>u.decoder(o),()=>new c(new s(`at ${i}: `),new s(u.content,k)))})}}}function Qe(e,t=","){return{content:`${e.content}[${t}${e.content}]...`,decoder(n){return n.split(t).map((o,i)=>d.tryWithContext(()=>e.decoder(o),()=>new c(new s(`at ${i}: `),new s(e.content,k))))}}}function ze(e){let t=`<${H.content.toUpperCase()}>`;return{generateUsage(){return{short:e.short,long:e.long,label:void 0,annotation:"[=no]",description:e.description,hint:e.hint}},registerAndMakeDecoder(n){let r=`no-${e.long}`,o=e.aliases?.longs?.map(a=>`no-${a}`),i=Q(n,{long:r,short:void 0,aliasesShorts:void 0,aliasesLongs:o,parsing:{consumeShortGroup:!1,consumeNextArg:()=>!1}}),u=Q(n,{long:e.long,short:e.short,aliasesLongs:e.aliases?.longs,aliasesShorts:e.aliases?.shorts,parsing:{consumeShortGroup:!1,consumeNextArg:()=>!1}});return{getAndDecodeValue(){let a=n.getOptionValues(i),l=n.getOptionValues(u);if(l.length>1)throw new d(new c(new s(`--${e.long}`,w),new s(": Must not be set multiple times")));if(a.length>1)throw new d(new c(new s(`--${r}`,w),new s(": Must not be set multiple times")));if(a.length>0&&l.length>0)throw new d(new c(new s(`--${e.long}`,w),new s(": Must not be set in combination with: "),new s(`--${r}`,w)));if(a.length>0){if(a[0].inlined)throw new d(new c(new s(`--${r}`,w),new s(": Must not have a value")));return!1}if(l.length>0){let p=l[0];return re({long:e.long,short:e.short,label:t,type:H,input:p.inlined===null?"true":p.inlined})}return e.default??!1}}}}}function Je(e){let t=`<${e.label??e.type.content.toUpperCase()}>`;return{generateUsage(){return{short:e.short,long:e.long,label:t,annotation:void 0,description:e.description,hint:e.hint}},registerAndMakeDecoder(n){let r=Q(n,{long:e.long,short:e.short,aliasesLongs:e.aliases?.longs,aliasesShorts:e.aliases?.shorts,parsing:{consumeShortGroup:!0,consumeNextArg:(o,i)=>o===null&&i.length===0}});return{getAndDecodeValue(){let o=n.getOptionValues(r);if(o.length>1)throw new d(new c(new s(`--${e.long}`,w),new s(": Requires a single value, but got multiple")));let i=o[0];if(i===void 0)try{return e.default()}catch(u){throw new d(new c(new s(`--${e.long}`,w),new s(": Failed to get default value")),u)}return re({long:e.long,short:e.short,label:t,type:e.type,input:i.inlined??i.separated[0]})}}}}}function Xe(e){let t=`<${e.label??e.type.content.toUpperCase()}>`;return{generateUsage(){return{short:e.short,long:e.long,label:t,annotation:" [*]",description:e.description,hint:e.hint}},registerAndMakeDecoder(n){let r=Q(n,{long:e.long,short:e.short,aliasesLongs:e.aliases?.longs,aliasesShorts:e.aliases?.shorts,parsing:{consumeShortGroup:!0,consumeNextArg:(o,i)=>o===null&&i.length===0}});return{getAndDecodeValue(){return n.getOptionValues(r).map(i=>re({long:e.long,short:e.short,label:t,type:e.type,input:i.inlined??i.separated[0]}))}}}}}function re(e){return d.tryWithContext(()=>e.type.decoder(e.input),()=>{let t=new c;return e.short&&(t.push(new s(`-${e.short}`,w)),t.push(new s(", "))),t.push(new s(`--${e.long}`,w)),t.push(new s(": ")),t.push(new s(e.label,R)),t.push(new s(": ")),t.push(new s(e.type.content,k)),t})}function Q(e,t){let{long:n,short:r,aliasesLongs:o,aliasesShorts:i,parsing:u}=t,a=n?[n]:[];o&&a.push(...o);let l=r?[r]:[];return i&&l.push(...i),e.registerOption({longs:a,shorts:l,parsing:u})}function Ze(e){let t=`<${e.label??e.type.content.toUpperCase()}>`;return{generateUsage(){return{description:e.description,hint:e.hint,label:t}},consumeAndMakeDecoder(n){let r=n.consumePositional();if(r===void 0)throw new d(new c(new s(t,R),new s(": Is required, but was not provided")));return{decodeValue(){return se(t,e.type,r)}}}}}function _e(e){let t=`[${e.label??e.type.content.toUpperCase()}]`;return{generateUsage(){return{description:e.description,hint:e.hint,label:t}},consumeAndMakeDecoder(n){let r=n.consumePositional();return{decodeValue(){if(r===void 0)try{return e.default()}catch(o){throw new d(new c(new s(t,R),new s(": Failed to get default value")),o)}return se(t,e.type,r)}}}}}function et(e){let t=`[${e.label??e.type.content.toUpperCase()}]`;return{generateUsage(){return{description:e.description,hint:e.hint,label:`${t}...`+(e.endDelimiter?` ["${e.endDelimiter}"]`:"")}},consumeAndMakeDecoder(n){let r=new Array;for(;;){let o=n.consumePositional();if(o===void 0||o===e.endDelimiter)break;r.push(o)}return{decodeValue(){return r.map(o=>se(t,e.type,o))}}}}}function se(e,t,n){return d.tryWithContext(()=>t.decoder(n),()=>new c(new s(e,R),new s(": "),new s(t.content,k)))}var G,M,I,v,O,N,h,z,de,ie,he,B,me,ae,j=class{constructor(t){b(this,h);b(this,G);b(this,M);b(this,I);b(this,v);b(this,O);b(this,N);f(this,G,t),f(this,M,0),f(this,I,!1),f(this,v,new Map),f(this,O,new Map),f(this,N,new Map)}registerOption(t){let n=[...t.longs.map(o=>`--${o}`),...t.shorts.map(o=>`-${o}`)].join(", ");for(let o of t.longs){if(!x(this,h,ae).call(this,o))throw new Error(`Invalid option name: --${o}`);if(g(this,v).has(o))throw new Error(`Option already registered: --${o}`)}for(let o of t.shorts){if(!x(this,h,ae).call(this,o))throw new Error(`Invalid option name: -${o}`);if(g(this,O).has(o))throw new Error(`Option already registered: -${o}`);for(let i=0;i<o.length;i++){let u=o.slice(0,i);if(g(this,O).has(u))throw new Error(`Option -${o} overlap with shorter option: -${u}`)}for(let i of g(this,O).keys())if(i.startsWith(o))throw new Error(`Option -${o} overlap with longer option: -${i}`)}let r={parsing:t.parsing,results:new Array};for(let o of t.longs)g(this,v).set(o,r);for(let o of t.shorts)g(this,O).set(o,r);return g(this,N).set(n,r),n}getOptionValues(t){let n=g(this,N).get(t);if(n===void 0)throw new Error(`Unregistered option: ${t}`);return n.results}consumePositional(){for(;;){let t=x(this,h,z).call(this);if(t===void 0)return;if(!x(this,h,de).call(this,t))return t}}};G=new WeakMap,M=new WeakMap,I=new WeakMap,v=new WeakMap,O=new WeakMap,N=new WeakMap,h=new WeakSet,z=function(){let t=g(this,G)[g(this,M)];if(t!==void 0)return ce(this,M)._++,!g(this,I)&&t==="--"?(f(this,I,!0),x(this,h,z).call(this)):t},de=function(t){if(g(this,I))return!1;if(t.startsWith("--")){let n=t.indexOf("=");return n===-1?x(this,h,ie).call(this,t.slice(2),null):x(this,h,ie).call(this,t.slice(2,n),t.slice(n+1)),!0}if(t.startsWith("-")){let n=1,r=2;for(;r<=t.length;){let o=t.slice(n,r),i=g(this,O).get(o);if(i!==void 0){let u=t.slice(r);if(x(this,h,he).call(this,i,o,u))return!0;n=r}r++}throw new d(new c(new s("Unexpected unknown option(s): "),new s(`-${t.slice(n)}`,y)))}return!1},ie=function(t,n){let r=`--${t}`,o=g(this,v).get(t);if(o!==void 0)return x(this,h,B).call(this,o,r,n);throw new d(new c(new s("Unexpected unknown option: "),new s(r,y)))},he=function(t,n,r){let o=`-${n}`;return r.startsWith("=")?(x(this,h,B).call(this,t,o,r.slice(1)),!0):r.length===0?(x(this,h,B).call(this,t,o,null),!0):t.parsing.consumeShortGroup?(x(this,h,B).call(this,t,o,r),!0):(x(this,h,B).call(this,t,o,null),!1)},B=function(t,n,r){let o=new Array;for(;t.parsing.consumeNextArg(r,o,g(this,G)[g(this,M)]);)o.push(x(this,h,me).call(this,n));t.results.push({inlined:r,separated:o})},me=function(t){let n=x(this,h,z).call(this);if(n===void 0)throw new d(new c(new s(t,w),new s(": Requires a value, but got end of input")));if(g(this,I))throw new d(new c(new s(t,w),new s(": Requires a value before "),new s('"--"',y)));if(n.startsWith("-"))throw new d(new c(new s(t,w),new s(": Requires a value, but got: "),new s(`"${n}"`,y)));return n},ae=function(t){return t.length>0&&!t.includes("=")};function ue(e){let{cliName:t,usage:n,typoSupport:r}=e,o=new Array,i=new c;i.push(tt("Usage:")),i.push(C(" ")),i.push(U(t));for(let a of n.segments)i.push(C(" ")),"positional"in a&&i.push(Y(a.positional)),"subcommand"in a&&i.push(U(a.subcommand));o.push(i.computeStyledString(r)),o.push("");let u=new c;u.push(nt(n.information.description)),n.information.hint&&(u.push(C(" ")),u.push(K(`(${n.information.hint})`))),o.push(u.computeStyledString(r));for(let a of n.information.details??[]){let l=new c;l.push(K(a)),o.push(l.computeStyledString(r))}if(n.positionals.length>0){o.push(""),o.push(J("Positionals:").computeStyledString(r));let a=new D;for(let l of n.positionals){let p=new Array;p.push(new c(C(" "))),p.push(new c(Y(l.label))),p.push(...pe(l)),a.pushRow(p)}o.push(...a.computeStyledLines(r))}if(n.subcommands.length>0){o.push(""),o.push(J("Subcommands:").computeStyledString(r));let a=new D;for(let l of n.subcommands){let p=new Array;p.push(new c(C(" "))),p.push(new c(U(l.name))),p.push(...pe(l)),a.pushRow(p)}o.push(...a.computeStyledLines(r))}if(n.options.length>0){o.push(""),o.push(J("Options:").computeStyledString(r));let a=new D;for(let l of n.options){let p=new Array;p.push(new c(C(" "))),l.short?p.push(new c(U(`-${l.short}`),C(", "))):p.push(new c);let m=new c(U(`--${l.long}`));l.label&&(m.push(C(" ")),m.push(Y(l.label))),l.annotation&&m.push(K(l.annotation)),p.push(m),p.push(...pe(l)),a.pushRow(p)}o.push(...a.computeStyledLines(r))}if(n.information.examples){o.push(""),o.push(J("Examples:").computeStyledString(r));for(let a of n.information.examples){let l=new c;l.push(C(" ")),l.push(K(`# ${a.explanation}`)),o.push(l.computeStyledString(r));let p=new c;p.push(C(" ")),p.push(U(t));for(let m of a.commandArgs)if(p.push(C(" ")),typeof m=="string")p.push(m);else if("positional"in m)p.push(Y(m.positional));else if("subcommand"in m)p.push(U(m.subcommand));else if("option"in m){let A=m.option;"short"in A?p.push(U(`-${A.short}`)):p.push(U(`--${A.long}`)),A.value!==void 0&&(p.push(K("=")),p.push(Y(A.value)))}o.push(p.computeStyledString(r))}}return o.push(""),o}function pe(e){let t=[];return e.description&&(t.push(C(" ")),t.push(ot(e.description))),e.hint&&(t.push(C(" ")),t.push(K(`(${e.hint})`))),t.length>0?[new c(C(" "),...t)]:[]}function tt(e){return new s(e,k)}function nt(e){return new s(e,ee)}function ot(e){return new s(e)}function J(e){return new s(e,_)}function K(e){return new s(e,te)}function U(e){return new s(e,w)}function Y(e){return new s(e,R)}function C(e){return new s(e)}async function rt(e,t,n,r,o){let i=new j(t),u=o?.usageOnHelp??!0;u&&i.registerOption({shorts:[],longs:["help"],parsing:{consumeShortGroup:!1,consumeNextArg:()=>!1}});let a=o?.buildVersion;a&&i.registerOption({shorts:[],longs:["version"],parsing:{consumeShortGroup:!1,consumeNextArg:()=>!1}});let l=r.consumeAndMakeDecoder(i);for(;;)try{if(i.consumePositional()===void 0)break}catch{}let p=st(o?.useTtyColors),m=o?.onExit??process.exit;if(u&&i.getOptionValues("--help").length>0)return console.log(we(e,l,p)),m(0);if(a&&i.getOptionValues("--version").length>0)return console.log([e,a].join(" ")),m(0);try{let A=l.decodeAndMakeInterpreter();try{return await A.executeWithContext(n),m(0)}catch(fe){return ye(o?.onError,fe,p),m(1)}}catch(A){return(o?.usageOnError??!0)&&console.error(we(e,l,p)),ye(o?.onError,A,p),m(1)}}function ye(e,t,n){e!==void 0?e(t):console.error(n.computeStyledErrorMessage(t))}function we(e,t,n){return ue({cliName:e,usage:t.generateUsage(),typoSupport:n}).join(`
2
+ `)}function st(e){return e===void 0?$.inferFromProcess():e==="mock"?$.mock():e?$.tty():$.none()}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});
3
3
  //# sourceMappingURL=index.js.map