Comparing version 0.28.0 to 0.28.1
@@ -167,3 +167,3 @@ /** | ||
type MaybeArray$1<T> = T | T[]; | ||
type CamelCase<T extends string> = T extends `${infer A}-${infer B}${infer C}` ? `${A}${Capitalize<B>}${CamelCase<C>}` : T; | ||
type CamelCase<T extends string> = (T extends `${infer Prefix}-${infer Suffix}` | `${infer Prefix} ${infer Suffix}` ? `${Prefix}${Capitalize<CamelCase<Suffix>>}` : T); | ||
@@ -170,0 +170,0 @@ declare const DOUBLE_DASH = "--"; |
@@ -1,2 +0,2 @@ | ||
import oe from"tty";class pt{constructor(){this.listenerMap={},this.wildcardListeners=new Set}on(t,n){return t==="*"?(this.wildcardListeners.add(n),this):(this.listenerMap[t]||(this.listenerMap[t]=new Set),this.listenerMap[t].add(n),this)}emit(t,...n){return this.listenerMap[t]&&(this.wildcardListeners.forEach(r=>r(t,...n)),this.listenerMap[t].forEach(r=>r(...n))),this}off(t,n){var r,o;return t==="**"?(this.listenerMap={},this.wildcardListeners.clear(),this):t==="*"?(n?this.wildcardListeners.delete(n):this.wildcardListeners.clear(),this):(n?(r=this.listenerMap[t])==null||r.delete(n):(o=this.listenerMap[t])==null||o.clear(),this)}}const gt="known-flag",dt="unknown-flag",ft="argument",{stringify:U}=JSON,xt=/\B([A-Z])/g,$t=e=>e.replace(xt,"-$1").toLowerCase(),{hasOwnProperty:Bt}=Object.prototype,Y=(e,t)=>Bt.call(e,t),St=e=>Array.isArray(e),Be=e=>typeof e=="function"?[e,!1]:St(e)?[e[0],!0]:Be(e.type),wt=(e,t)=>e===Boolean?t!=="false":t,yt=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),Ct=/[\s.:=]/,bt=e=>{const t=`Flag name ${U(e)}`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const n=e.match(Ct);if(n)throw new Error(`${t} cannot contain ${U(n==null?void 0:n[0])}`)},Et=e=>{const t={},n=(r,o)=>{if(Y(t,r))throw new Error(`Duplicate flags named ${U(r)}`);t[r]=o};for(const r in e){if(!Y(e,r))continue;bt(r);const o=e[r],s=[[],...Be(o),o];n(r,s);const i=$t(r);if(r!==i&&n(i,s),"alias"in o&&typeof o.alias=="string"){const{alias:u}=o,a=`Flag alias ${U(u)} for flag ${U(r)}`;if(u.length===0)throw new Error(`${a} cannot be empty`);if(u.length>1)throw new Error(`${a} must be a single character`);n(u,s)}}return t},vt=(e,t)=>{const n={};for(const r in e){if(!Y(e,r))continue;const[o,,s,i]=t[r];if(o.length===0&&"default"in i){let{default:u}=i;typeof u=="function"&&(u=u()),n[r]=u}else n[r]=s?o:o.pop()}return n},J="--",At=/[.:=]/,Ot=/^-{1,2}\w/,_t=e=>{if(!Ot.test(e))return;const t=!e.startsWith(J);let n=e.slice(t?1:2),r;const o=n.match(At);if(o){const{index:s}=o;r=n.slice(s+1),n=n.slice(0,s)}return[n,r,t]},Tt=(e,{onFlag:t,onArgument:n})=>{let r;const o=(s,i)=>{if(typeof r!="function")return!0;r(s,i),r=void 0};for(let s=0;s<e.length;s+=1){const i=e[s];if(i===J){o();const a=e.slice(s+1);n==null||n(a,[s],!0);break}const u=_t(i);if(u){if(o(),!t)continue;const[a,l,p]=u;if(p)for(let g=0;g<a.length;g+=1){o();const c=g===a.length-1;r=t(a[g],c?l:void 0,[s,g+1,c])}else r=t(a,l,[s])}else o(i,[s])&&(n==null||n([i],[s]))}o()},Mt=(e,t)=>{for(const[n,r,o]of t.reverse()){if(r){const s=e[n];let i=s.slice(0,r);if(o||(i+=s.slice(r+1)),i!=="-"){e[n]=i;continue}}e.splice(n,1)}},It=(e,t=process.argv.slice(2),{ignore:n}={})=>{const r=[],o=Et(e),s={},i=[];return i[J]=[],Tt(t,{onFlag(u,a,l){const p=Y(o,u);if(!(n!=null&&n(p?gt:dt,u,a))){if(p){const[g,c]=o[u],h=wt(c,a),m=(d,x)=>{r.push(l),x&&r.push(x),g.push(yt(c,d||""))};return h===void 0?m:m(h)}Y(s,u)||(s[u]=[]),s[u].push(a===void 0?!0:a),r.push(l)}},onArgument(u,a,l){n!=null&&n(ft,t[a[0]])||(i.push(...u),l?(i[J]=u,t.splice(a[0])):r.push(a))}}),Mt(t,r),{flags:vt(e,o),unknownFlags:s,_:i}},se=e=>Array.isArray(e)?e:[e],kt=e=>e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase()),Ft=(e,t)=>t.length!==e.length?!1:e.every((n,r)=>n===t[r]),Se=(e,t)=>t.length>e.length?!1:Ft(e.slice(0,t.length),t);class we extends Error{constructor(t){super(`Command "${t}" exists.`),this.commandName=t}}class z extends Error{constructor(t){super(`No such command: ${t}`),this.commandName=t}}class K extends Error{constructor(){super("No command given.")}}class ye extends Error{constructor(t,n){super(`Command name ${t} conflicts with ${n}. Maybe caused by alias.`),this.n1=t,this.n2=n}}class Ce extends Error{constructor(){super("Name not set.")}}class be extends Error{constructor(){super("Description not set.")}}class Ee extends Error{constructor(){super("Version not set.")}}class ve extends Error{constructor(t){super(`Bad name format: ${t}`),this.commandName=t}}const Ae=typeof Deno!="undefined",Lt=typeof process!="undefined"&&!Ae,Rt=process.versions.electron&&!process.defaultApp;function Oe(e,t,n){if(n.alias){const r=se(n.alias);for(const o of r){if(o in t)throw new ye(t[o].name,n.name);e.set(typeof o=="symbol"?o:o.split(" "),{...n,__isAlias:!0})}}}function _e(e){const t=new Map;e[y]&&(t.set(y,e[y]),Oe(t,e,e[y]));for(const n of Object.values(e))Oe(t,e,n),t.set(n.name.split(" "),n);return t}function ie(e,t){if(t===y)return e[y];const n=se(t),r=_e(e);let o,s;return r.forEach((i,u)=>{if(u===y){o=r.get(y),s=y;return}Se(n,u)&&(!s||s===y||u.length>s.length)&&(o=i,s=u)}),o}function Te(e,t,n=1/0){const r=t===""?[]:Array.isArray(t)?t:t.split(" ");return Object.values(e).filter(o=>{const s=o.name.split(" ");return Se(s,r)&&s.length-r.length<=n})}const Dt=e=>Te(e,"",1);function Me(e){const t=[];for(const n of e){if(n.startsWith("-"))break;t.push(n)}return t}const ae=()=>Lt?process.argv.slice(Rt?1:2):Ae?Deno.args:[];function Ie(e){const t={pre:[],normal:[],post:[]};for(const r of e){const o=typeof r=="object"?r:{fn:r},{enforce:s,fn:i}=o;s==="post"||s==="pre"?t[s].push(i):t.normal.push(i)}const n=[...t.pre,...t.normal,...t.post];return r=>{return o(0);function o(s){const i=n[s];return i(r(),o.bind(null,s+1))}}}const ke=e=>typeof e=="string"&&(e.startsWith(" ")||e.endsWith(" ")),Fe=(e,t)=>t?`[${e}]`:`<${e}>`,jt="<Root>",j=e=>Array.isArray(e)?e.join(" "):typeof e=="string"?e:jt,{stringify:N}=JSON;function le(e){const t=[];let n,r;for(const o of e){if(r)throw new Error(`Invalid parameter: Spread parameter ${N(r)} must be last`);const s=o[0],i=o[o.length-1];let u;if(s==="<"&&i===">"&&(u=!0,n))throw new Error(`Invalid parameter: Required parameter ${N(o)} cannot come after optional parameter ${N(n)}`);if(s==="["&&i==="]"&&(u=!1,n=o),u===void 0)throw new Error(`Invalid parameter: ${N(o)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=o.slice(1,-1);const l=a.slice(-3)==="...";l&&(r=o,a=a.slice(0,-3)),t.push({name:a,required:u,spread:l})}return t}function ue(e,t,n){for(let r=0;r<t.length;r+=1){const{name:o,required:s,spread:i}=t[r],u=kt(o);if(u in e)return new Error(`Invalid parameter: ${N(o)} is used more than once.`);const a=i?n.slice(r):n[r];if(i&&(r=t.length),s&&(!a||i&&a.length===0))return new Error(`Error: Missing required parameter ${N(o)}`);e[u]=a}}var ce=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},$=(e,t,n)=>(ce(e,t,"read from private field"),n?n.call(e):t.get(e)),v=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},k=(e,t,n,r)=>(ce(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Nt=(e,t,n)=>(ce(e,t,"access private method"),n),F,L,R,V,G,Q,W,X,me,Le,he,Re,pe,De;const y=Symbol("Root"),je=class{constructor(e,t,n){v(this,me),v(this,he),v(this,pe),v(this,F,""),v(this,L,""),v(this,R,""),v(this,V,[]),v(this,G,{}),v(this,Q,new pt),v(this,W,new Set),v(this,X,void 0),k(this,F,e||$(this,F)),k(this,L,t||$(this,L)),k(this,R,n||$(this,R))}get _name(){return $(this,F)}get _description(){return $(this,L)}get _version(){return $(this,R)}get _inspectors(){return $(this,V)}get _commands(){return $(this,G)}static create(e,t,n){return new je(e,t,n)}name(e){return k(this,F,e),this}description(e){return k(this,L,e),this}version(e){return k(this,R,e),this}command(e,t,n={}){const r=(l=>!(typeof l=="string"||l===y))(e),o=r?e.name:e;if(ke(o))throw new ve(o);const{handler:s=void 0,...i}=r?e:{name:o,description:t,...n},u=[i.name],a=i.alias?se(i.alias):[];i.alias&&u.push(...a);for(const l of u)if($(this,W).has(l))throw new we(j(l));return $(this,G)[o]=i,$(this,W).add(i.name),a.forEach(l=>$(this,W).add(l)),r&&s&&this.on(e.name,s),this}on(e,t){return $(this,Q).on(e,t),this}use(e){return e.setup(this)}inspector(e){return $(this,V).push(e),this}parse(e=ae()){const{argv:t,run:n}=Array.isArray(e)?{argv:e,run:!0}:{argv:ae(),...e};return k(this,X,t),Nt(this,pe,De).call(this),n&&this.runMatchedCommand(),this}runMatchedCommand(){const e=$(this,X);if(!e)throw new Error("cli.parse() must be called.");const t=Me(e),n=t.join(" "),r=()=>ie($(this,G),t),o=[],s=()=>{o.length=0;const a=r(),l=!!a,p=It((a==null?void 0:a.flags)||{},[...e]),{_:g,flags:c,unknownFlags:h}=p;let m=!l||a.name===y?g:g.slice(a.name.split(" ").length),d=(a==null?void 0:a.parameters)||[];const x=d.indexOf("--"),O=d.slice(x+1)||[],f=Object.create(null);if(x>-1&&O.length>0){d=d.slice(0,x);const E=g["--"];m=m.slice(0,-E.length||void 0),o.push(ue(f,le(d),m)),o.push(ue(f,le(O),E))}else o.push(ue(f,le(d),m));const I={...c,...h};return{name:a==null?void 0:a.name,called:t.length===0&&(a==null?void 0:a.name)?y:n,resolved:l,hasRootOrAlias:$(this,me,Le),hasRoot:$(this,he,Re),raw:{...p,parameters:m,mergedFlags:I},parameters:f,flags:c,unknownFlags:h,cli:this}},i={enforce:"post",fn:()=>{const a=r(),l=s(),p=o.filter(Boolean);if(p.length>0)throw p[0];if(!a)throw n?new z(n):new K;$(this,Q).emit(a.name,l)}},u=[...$(this,V),i];return Ie(u)(s),this}};let Wt=je;F=new WeakMap,L=new WeakMap,R=new WeakMap,V=new WeakMap,G=new WeakMap,Q=new WeakMap,W=new WeakMap,X=new WeakMap,me=new WeakSet,Le=function(){return $(this,W).has(y)},he=new WeakSet,Re=function(){return Object.prototype.hasOwnProperty.call(this._commands,y)},pe=new WeakSet,De=function(){if(!$(this,F))throw new Ce;if(!$(this,L))throw new be;if(!$(this,R))throw new Ee};const D=e=>e,Pt=(e,t,n)=>n,Ht=(e,t)=>t,Ut=(e,t)=>({...e,handler:t}),Yt=e=>` | ||
import oe from"tty";class pt{constructor(){this.listenerMap={},this.wildcardListeners=new Set}on(t,n){return t==="*"?(this.wildcardListeners.add(n),this):(this.listenerMap[t]||(this.listenerMap[t]=new Set),this.listenerMap[t].add(n),this)}emit(t,...n){return this.listenerMap[t]&&(this.wildcardListeners.forEach(r=>r(t,...n)),this.listenerMap[t].forEach(r=>r(...n))),this}off(t,n){var r,o;return t==="**"?(this.listenerMap={},this.wildcardListeners.clear(),this):t==="*"?(n?this.wildcardListeners.delete(n):this.wildcardListeners.clear(),this):(n?(r=this.listenerMap[t])==null||r.delete(n):(o=this.listenerMap[t])==null||o.clear(),this)}}const gt="known-flag",dt="unknown-flag",ft="argument",{stringify:U}=JSON,xt=/\B([A-Z])/g,$t=e=>e.replace(xt,"-$1").toLowerCase(),{hasOwnProperty:Bt}=Object.prototype,Y=(e,t)=>Bt.call(e,t),St=e=>Array.isArray(e),Be=e=>typeof e=="function"?[e,!1]:St(e)?[e[0],!0]:Be(e.type),wt=(e,t)=>e===Boolean?t!=="false":t,yt=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),Ct=/[\s.:=]/,bt=e=>{const t=`Flag name ${U(e)}`;if(e.length===0)throw new Error(`${t} cannot be empty`);if(e.length===1)throw new Error(`${t} must be longer than a character`);const n=e.match(Ct);if(n)throw new Error(`${t} cannot contain ${U(n==null?void 0:n[0])}`)},Et=e=>{const t={},n=(r,o)=>{if(Y(t,r))throw new Error(`Duplicate flags named ${U(r)}`);t[r]=o};for(const r in e){if(!Y(e,r))continue;bt(r);const o=e[r],s=[[],...Be(o),o];n(r,s);const i=$t(r);if(r!==i&&n(i,s),"alias"in o&&typeof o.alias=="string"){const{alias:u}=o,a=`Flag alias ${U(u)} for flag ${U(r)}`;if(u.length===0)throw new Error(`${a} cannot be empty`);if(u.length>1)throw new Error(`${a} must be a single character`);n(u,s)}}return t},vt=(e,t)=>{const n={};for(const r in e){if(!Y(e,r))continue;const[o,,s,i]=t[r];if(o.length===0&&"default"in i){let{default:u}=i;typeof u=="function"&&(u=u()),n[r]=u}else n[r]=s?o:o.pop()}return n},J="--",At=/[.:=]/,Ot=/^-{1,2}\w/,_t=e=>{if(!Ot.test(e))return;const t=!e.startsWith(J);let n=e.slice(t?1:2),r;const o=n.match(At);if(o){const{index:s}=o;r=n.slice(s+1),n=n.slice(0,s)}return[n,r,t]},Tt=(e,{onFlag:t,onArgument:n})=>{let r;const o=(s,i)=>{if(typeof r!="function")return!0;r(s,i),r=void 0};for(let s=0;s<e.length;s+=1){const i=e[s];if(i===J){o();const a=e.slice(s+1);n==null||n(a,[s],!0);break}const u=_t(i);if(u){if(o(),!t)continue;const[a,l,p]=u;if(p)for(let g=0;g<a.length;g+=1){o();const c=g===a.length-1;r=t(a[g],c?l:void 0,[s,g+1,c])}else r=t(a,l,[s])}else o(i,[s])&&(n==null||n([i],[s]))}o()},Mt=(e,t)=>{for(const[n,r,o]of t.reverse()){if(r){const s=e[n];let i=s.slice(0,r);if(o||(i+=s.slice(r+1)),i!=="-"){e[n]=i;continue}}e.splice(n,1)}},It=(e,t=process.argv.slice(2),{ignore:n}={})=>{const r=[],o=Et(e),s={},i=[];return i[J]=[],Tt(t,{onFlag(u,a,l){const p=Y(o,u);if(!(n!=null&&n(p?gt:dt,u,a))){if(p){const[g,c]=o[u],h=wt(c,a),m=(d,x)=>{r.push(l),x&&r.push(x),g.push(yt(c,d||""))};return h===void 0?m:m(h)}Y(s,u)||(s[u]=[]),s[u].push(a===void 0?!0:a),r.push(l)}},onArgument(u,a,l){n!=null&&n(ft,t[a[0]])||(i.push(...u),l?(i[J]=u,t.splice(a[0])):r.push(a))}}),Mt(t,r),{flags:vt(e,o),unknownFlags:s,_:i}},se=e=>Array.isArray(e)?e:[e],kt=e=>e.replace(/[-_ ](\w)/g,(t,n)=>n.toUpperCase()),Ft=(e,t)=>t.length!==e.length?!1:e.every((n,r)=>n===t[r]),Se=(e,t)=>t.length>e.length?!1:Ft(e.slice(0,t.length),t);class we extends Error{constructor(t){super(`Command "${t}" exists.`),this.commandName=t}}class z extends Error{constructor(t){super(`No such command: ${t}`),this.commandName=t}}class K extends Error{constructor(){super("No command given.")}}class ye extends Error{constructor(t,n){super(`Command name ${t} conflicts with ${n}. Maybe caused by alias.`),this.n1=t,this.n2=n}}class Ce extends Error{constructor(){super("Name not set.")}}class be extends Error{constructor(){super("Description not set.")}}class Ee extends Error{constructor(){super("Version not set.")}}class ve extends Error{constructor(t){super(`Bad name format: ${t}`),this.commandName=t}}const Ae=typeof Deno!="undefined",Lt=typeof process!="undefined"&&!Ae,Rt=process.versions.electron&&!process.defaultApp;function Oe(e,t,n){if(n.alias){const r=se(n.alias);for(const o of r){if(o in t)throw new ye(t[o].name,n.name);e.set(typeof o=="symbol"?o:o.split(" "),{...n,__isAlias:!0})}}}function _e(e){const t=new Map;e[y]&&(t.set(y,e[y]),Oe(t,e,e[y]));for(const n of Object.values(e))Oe(t,e,n),t.set(n.name.split(" "),n);return t}function ie(e,t){if(t===y)return e[y];const n=se(t),r=_e(e);let o,s;return r.forEach((i,u)=>{if(u===y){o=r.get(y),s=y;return}Se(n,u)&&(!s||s===y||u.length>s.length)&&(o=i,s=u)}),o}function Te(e,t,n=1/0){const r=t===""?[]:Array.isArray(t)?t:t.split(" ");return Object.values(e).filter(o=>{const s=o.name.split(" ");return Se(s,r)&&s.length-r.length<=n})}const Dt=e=>Te(e,"",1);function Me(e){const t=[];for(const n of e){if(n.startsWith("-"))break;t.push(n)}return t}const ae=()=>Lt?process.argv.slice(Rt?1:2):Ae?Deno.args:[];function Ie(e){const t={pre:[],normal:[],post:[]};for(const r of e){const o=typeof r=="object"?r:{fn:r},{enforce:s,fn:i}=o;s==="post"||s==="pre"?t[s].push(i):t.normal.push(i)}const n=[...t.pre,...t.normal,...t.post];return r=>{return o(0);function o(s){const i=n[s];return i(r(),o.bind(null,s+1))}}}const ke=e=>typeof e=="string"&&(e.startsWith(" ")||e.endsWith(" ")),Fe=(e,t)=>t?`[${e}]`:`<${e}>`,jt="<Root>",j=e=>Array.isArray(e)?e.join(" "):typeof e=="string"?e:jt,{stringify:N}=JSON;function le(e){const t=[];let n,r;for(const o of e){if(r)throw new Error(`Invalid parameter: Spread parameter ${N(r)} must be last`);const s=o[0],i=o[o.length-1];let u;if(s==="<"&&i===">"&&(u=!0,n))throw new Error(`Invalid parameter: Required parameter ${N(o)} cannot come after optional parameter ${N(n)}`);if(s==="["&&i==="]"&&(u=!1,n=o),u===void 0)throw new Error(`Invalid parameter: ${N(o)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=o.slice(1,-1);const l=a.slice(-3)==="...";l&&(r=o,a=a.slice(0,-3)),t.push({name:a,required:u,spread:l})}return t}function ue(e,t,n){for(let r=0;r<t.length;r+=1){const{name:o,required:s,spread:i}=t[r],u=kt(o);if(u in e)return new Error(`Invalid parameter: ${N(o)} is used more than once.`);const a=i?n.slice(r):n[r];if(i&&(r=t.length),s&&(!a||i&&a.length===0))return new Error(`Error: Missing required parameter ${N(o)}`);e[u]=a}}var ce=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},$=(e,t,n)=>(ce(e,t,"read from private field"),n?n.call(e):t.get(e)),v=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},k=(e,t,n,r)=>(ce(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Nt=(e,t,n)=>(ce(e,t,"access private method"),n),F,L,R,V,G,Q,W,X,me,Le,he,Re,pe,De;const y=Symbol("Root"),je=class{constructor(e,t,n){v(this,me),v(this,he),v(this,pe),v(this,F,""),v(this,L,""),v(this,R,""),v(this,V,[]),v(this,G,{}),v(this,Q,new pt),v(this,W,new Set),v(this,X,void 0),k(this,F,e||$(this,F)),k(this,L,t||$(this,L)),k(this,R,n||$(this,R))}get _name(){return $(this,F)}get _description(){return $(this,L)}get _version(){return $(this,R)}get _inspectors(){return $(this,V)}get _commands(){return $(this,G)}static create(e,t,n){return new je(e,t,n)}name(e){return k(this,F,e),this}description(e){return k(this,L,e),this}version(e){return k(this,R,e),this}command(e,t,n={}){const r=(l=>!(typeof l=="string"||l===y))(e),o=r?e.name:e;if(ke(o))throw new ve(o);const{handler:s=void 0,...i}=r?e:{name:o,description:t,...n},u=[i.name],a=i.alias?se(i.alias):[];i.alias&&u.push(...a);for(const l of u)if($(this,W).has(l))throw new we(j(l));return $(this,G)[o]=i,$(this,W).add(i.name),a.forEach(l=>$(this,W).add(l)),r&&s&&this.on(e.name,s),this}on(e,t){return $(this,Q).on(e,t),this}use(e){return e.setup(this)}inspector(e){return $(this,V).push(e),this}parse(e=ae()){const{argv:t,run:n}=Array.isArray(e)?{argv:e,run:!0}:{argv:ae(),...e};return k(this,X,t),Nt(this,pe,De).call(this),n&&this.runMatchedCommand(),this}runMatchedCommand(){const e=$(this,X);if(!e)throw new Error("cli.parse() must be called.");const t=Me(e),n=t.join(" "),r=()=>ie($(this,G),t),o=[],s=()=>{o.length=0;const a=r(),l=!!a,p=It((a==null?void 0:a.flags)||{},[...e]),{_:g,flags:c,unknownFlags:h}=p;let m=!l||a.name===y?g:g.slice(a.name.split(" ").length),d=(a==null?void 0:a.parameters)||[];const x=d.indexOf("--"),O=d.slice(x+1)||[],f=Object.create(null);if(x>-1&&O.length>0){d=d.slice(0,x);const E=g["--"];m=m.slice(0,-E.length||void 0),o.push(ue(f,le(d),m)),o.push(ue(f,le(O),E))}else o.push(ue(f,le(d),m));const I={...c,...h};return{name:a==null?void 0:a.name,called:t.length===0&&(a==null?void 0:a.name)?y:n,resolved:l,hasRootOrAlias:$(this,me,Le),hasRoot:$(this,he,Re),raw:{...p,parameters:m,mergedFlags:I},parameters:f,flags:c,unknownFlags:h,cli:this}},i={enforce:"post",fn:()=>{const a=r(),l=s(),p=o.filter(Boolean);if(p.length>0)throw p[0];if(!a)throw n?new z(n):new K;$(this,Q).emit(a.name,l)}},u=[...$(this,V),i];return Ie(u)(s),this}};let Wt=je;F=new WeakMap,L=new WeakMap,R=new WeakMap,V=new WeakMap,G=new WeakMap,Q=new WeakMap,W=new WeakMap,X=new WeakMap,me=new WeakSet,Le=function(){return $(this,W).has(y)},he=new WeakSet,Re=function(){return Object.prototype.hasOwnProperty.call(this._commands,y)},pe=new WeakSet,De=function(){if(!$(this,F))throw new Ce;if(!$(this,L))throw new be;if(!$(this,R))throw new Ee};const D=e=>e,Pt=(e,t,n)=>n,Ht=(e,t)=>t,Ut=(e,t)=>({...e,handler:t}),Yt=e=>` | ||
${e}) | ||
@@ -3,0 +3,0 @@ cmd+="__${e}" |
{ | ||
"name": "clerc", | ||
"version": "0.28.0", | ||
"version": "0.28.1", | ||
"author": "Ray <nn_201312@163.com> (https://github.com/so1ve)", | ||
@@ -50,9 +50,9 @@ "description": "Clerc: The full-featured cli framework.", | ||
"devDependencies": { | ||
"@clerc/plugin-completions": "0.28.0", | ||
"@clerc/plugin-friendly-error": "0.28.0", | ||
"@clerc/core": "0.28.0", | ||
"@clerc/plugin-not-found": "0.28.0", | ||
"@clerc/plugin-strict-flags": "0.28.0", | ||
"@clerc/plugin-help": "0.28.0", | ||
"@clerc/plugin-version": "0.28.0" | ||
"@clerc/core": "0.28.1", | ||
"@clerc/plugin-friendly-error": "0.28.1", | ||
"@clerc/plugin-help": "0.28.1", | ||
"@clerc/plugin-not-found": "0.28.1", | ||
"@clerc/plugin-completions": "0.28.1", | ||
"@clerc/plugin-strict-flags": "0.28.1", | ||
"@clerc/plugin-version": "0.28.1" | ||
}, | ||
@@ -59,0 +59,0 @@ "scripts": { |
55369