@clerc/core 0.30.1 → 0.32.0
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.d.ts +22 -19
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -164,7 +164,10 @@ type LiteralUnion<
|
|
|
164
164
|
type Equals<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
165
165
|
type Dict<T> = Record<string, T>;
|
|
166
166
|
type MaybeArray$1<T> = T | T[];
|
|
167
|
-
type
|
|
167
|
+
type AlphabetLowercase = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
168
|
+
type Numeric = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
|
169
|
+
type AlphaNumeric = AlphabetLowercase | Uppercase<AlphabetLowercase> | Numeric;
|
|
170
|
+
type CamelCase<Word extends string> = (Word extends `${infer FirstCharacter}${infer Rest}` ? (FirstCharacter extends AlphaNumeric ? `${FirstCharacter}${CamelCase<Rest>}` : Capitalize<CamelCase<Rest>>) : Word);
|
|
168
171
|
|
|
169
172
|
declare const DOUBLE_DASH = "--";
|
|
170
173
|
type TypeFunction<ReturnType = any> = (value: any) => ReturnType;
|
|
@@ -240,18 +243,18 @@ type NonNullableParameters<T extends string[] | undefined> = T extends undefined
|
|
|
240
243
|
type TransformParameters<C extends Command> = {
|
|
241
244
|
[Parameter in NonNullableParameters<C["parameters"]>[number] as CamelCase<StripBrackets<Parameter>>]: ParameterType<Parameter>;
|
|
242
245
|
};
|
|
243
|
-
type MakeEventMap<T extends
|
|
246
|
+
type MakeEventMap<T extends Commands> = {
|
|
244
247
|
[K in keyof T]: [InspectorContext];
|
|
245
248
|
};
|
|
246
249
|
type FallbackFlags<C extends Command> = Equals<NonNullableFlag<C>["flags"], {}> extends true ? Dict<any> : NonNullableFlag<C>["flags"];
|
|
247
250
|
type NonNullableFlag<C extends Command> = TypeFlag<NonNullable<C["flags"]>>;
|
|
248
|
-
type ParseFlag<C extends
|
|
251
|
+
type ParseFlag<C extends Commands, N extends keyof C> = N extends keyof C ? OmitIndexSignature<NonNullableFlag<C[N]>["flags"]> : FallbackFlags<C[N]>["flags"];
|
|
249
252
|
type ParseRaw<C extends Command> = NonNullableFlag<C> & {
|
|
250
253
|
flags: FallbackFlags<C>;
|
|
251
254
|
parameters: string[];
|
|
252
255
|
mergedFlags: FallbackFlags<C> & NonNullableFlag<C>["unknownFlags"];
|
|
253
256
|
};
|
|
254
|
-
type ParseParameters<C extends
|
|
257
|
+
type ParseParameters<C extends Commands = Commands, N extends keyof C = keyof C> = Equals<TransformParameters<C[N]>, {}> extends true ? N extends keyof C ? TransformParameters<C[N]> : Dict<string | string[] | undefined> : TransformParameters<C[N]>;
|
|
255
258
|
|
|
256
259
|
interface Plugin<T extends Clerc = Clerc, U extends Clerc = Clerc> {
|
|
257
260
|
setup: (cli: T) => U;
|
|
@@ -291,14 +294,14 @@ type CommandAlias<N extends string | RootType = string, O extends CommandOptions
|
|
|
291
294
|
type CommandWithHandler<N extends string | RootType = string, O extends CommandOptions = CommandOptions> = Command<N, O> & {
|
|
292
295
|
handler?: HandlerInCommand<HandlerContext<Record<N, Command<N, O>> & Record<never, never>, N>>;
|
|
293
296
|
};
|
|
294
|
-
type
|
|
297
|
+
type Commands = Dict<Command> & {
|
|
295
298
|
[Root]?: Command;
|
|
296
299
|
};
|
|
297
300
|
interface ParseOptions {
|
|
298
301
|
argv?: string[];
|
|
299
302
|
run?: boolean;
|
|
300
303
|
}
|
|
301
|
-
interface HandlerContext<C extends
|
|
304
|
+
interface HandlerContext<C extends Commands = Commands, N extends keyof C = keyof C> {
|
|
302
305
|
name?: LiteralUnion<N, string>;
|
|
303
306
|
called?: string | RootType;
|
|
304
307
|
resolved: boolean;
|
|
@@ -316,31 +319,31 @@ interface HandlerContext<C extends CommandRecord = CommandRecord, N extends keyo
|
|
|
316
319
|
};
|
|
317
320
|
cli: Clerc<C>;
|
|
318
321
|
}
|
|
319
|
-
type Handler<C extends
|
|
322
|
+
type Handler<C extends Commands = Commands, K extends keyof C = keyof C> = (ctx: HandlerContext<C, K>) => void;
|
|
320
323
|
type HandlerInCommand<C extends HandlerContext> = (ctx: {
|
|
321
324
|
[K in keyof C]: C[K];
|
|
322
325
|
}) => void;
|
|
323
326
|
type FallbackType<T, U> = {} extends T ? U : T;
|
|
324
|
-
type InspectorContext<C extends
|
|
327
|
+
type InspectorContext<C extends Commands = Commands> = HandlerContext<C> & {
|
|
325
328
|
flags: FallbackType<TypeFlag<NonNullable<C[keyof C]["flags"]>>["flags"], Dict<any>>;
|
|
326
329
|
};
|
|
327
|
-
type Inspector<C extends
|
|
328
|
-
type InspectorFn<C extends
|
|
329
|
-
interface InspectorObject<C extends
|
|
330
|
+
type Inspector<C extends Commands = Commands> = InspectorFn<C> | InspectorObject<C>;
|
|
331
|
+
type InspectorFn<C extends Commands = Commands> = (ctx: InspectorContext<C>, next: () => void) => (() => void) | void;
|
|
332
|
+
interface InspectorObject<C extends Commands = Commands> {
|
|
330
333
|
enforce?: "pre" | "post";
|
|
331
334
|
fn: InspectorFn<C>;
|
|
332
335
|
}
|
|
333
336
|
|
|
334
337
|
declare const Root: unique symbol;
|
|
335
338
|
type RootType = typeof Root;
|
|
336
|
-
declare class Clerc<C extends
|
|
339
|
+
declare class Clerc<C extends Commands = {}> {
|
|
337
340
|
#private;
|
|
338
341
|
i18n: I18N;
|
|
339
342
|
private constructor();
|
|
340
343
|
get _name(): string;
|
|
341
344
|
get _description(): string;
|
|
342
345
|
get _version(): string;
|
|
343
|
-
get _inspectors(): Inspector<
|
|
346
|
+
get _inspectors(): Inspector<Commands>[];
|
|
344
347
|
get _commands(): C;
|
|
345
348
|
/**
|
|
346
349
|
* Create a new cli
|
|
@@ -559,11 +562,11 @@ declare class LocaleNotCalledFirstError extends Error {
|
|
|
559
562
|
constructor(t: TranslateFn);
|
|
560
563
|
}
|
|
561
564
|
|
|
562
|
-
declare function resolveFlattenCommands(commands:
|
|
563
|
-
declare function resolveCommand(commands:
|
|
564
|
-
declare function resolveCommandStrict(commands:
|
|
565
|
-
declare function resolveSubcommandsByParent(commands:
|
|
566
|
-
declare const resolveRootCommands: (commands:
|
|
565
|
+
declare function resolveFlattenCommands(commands: Commands, t: TranslateFn): Map<string[] | typeof Root, CommandAlias<string, CommandOptions<string[], MaybeArray$1<string | typeof Root>, Flags>>>;
|
|
566
|
+
declare function resolveCommand(commands: Commands, name: CommandType | string[], t: TranslateFn): [Command<string | RootType> | undefined, string[] | RootType | undefined];
|
|
567
|
+
declare function resolveCommandStrict(commands: Commands, name: CommandType | string[], t: TranslateFn): [Command<string | RootType> | undefined, string[] | RootType | undefined];
|
|
568
|
+
declare function resolveSubcommandsByParent(commands: Commands, parent: string | string[], depth?: number): Command<string, CommandOptions<string[], MaybeArray$1<string | typeof Root>, Flags>>[];
|
|
569
|
+
declare const resolveRootCommands: (commands: Commands) => Command<string, CommandOptions<string[], MaybeArray$1<string | typeof Root>, Flags>>[];
|
|
567
570
|
declare function resolveParametersBeforeFlag(argv: string[]): string[];
|
|
568
571
|
declare const resolveArgv: () => string[];
|
|
569
572
|
declare function compose(inspectors: Inspector[]): (getCtx: () => InspectorContext) => void;
|
|
@@ -572,4 +575,4 @@ declare const withBrackets: (s: string, isOptional?: boolean) => string;
|
|
|
572
575
|
declare const formatCommandName: (name: string | string[] | RootType) => string;
|
|
573
576
|
declare const detectLocale: () => string;
|
|
574
577
|
|
|
575
|
-
export { Clerc, Command, CommandAlias, CommandCustomProperties, CommandExistsError, CommandNameConflictError, CommandOptions,
|
|
578
|
+
export { Clerc, Command, CommandAlias, CommandCustomProperties, CommandExistsError, CommandNameConflictError, CommandOptions, CommandType, CommandWithHandler, Commands, DescriptionNotSetError, FallbackType, Flag, FlagOptions, Flags, Handler, HandlerContext, HandlerInCommand, I18N, Inspector, InspectorContext, InspectorFn, InspectorObject, InvalidCommandNameError, LocaleNotCalledFirstError, Locales, MakeEventMap, NameNotSetError, NoCommandGivenError, NoSuchCommandError, ParseOptions, Plugin, Root, RootType, TranslateFn, VersionNotSetError, compose, defineCommand, defineHandler, defineInspector, definePlugin, detectLocale, formatCommandName, isValidName, resolveArgv, resolveCommand, resolveCommandStrict, resolveFlattenCommands, resolveParametersBeforeFlag, resolveRootCommands, resolveSubcommandsByParent, withBrackets };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{format as it}from"node:util";class Ot{constructor(){this.listenerMap={},this.wildcardListeners=new Set}on(e,s){return e==="*"?(this.wildcardListeners.add(s),this):(this.listenerMap[e]||(this.listenerMap[e]=new Set),this.listenerMap[e].add(s),this)}emit(e,...s){return this.listenerMap[e]&&(this.wildcardListeners.forEach(r=>r(e,...s)),this.listenerMap[e].forEach(r=>r(...s))),this}off(e,s){var r,o;return e==="**"?(this.listenerMap={},this.wildcardListeners.clear(),this):e==="*"?(s?this.wildcardListeners.delete(s):this.wildcardListeners.clear(),this):(s?(r=this.listenerMap[e])==null||r.delete(s):(o=this.listenerMap[e])==null||o.clear(),this)}}const It="known-flag",$t="unknown-flag",Rt="argument",{stringify:k}=JSON,Pt=/\B([A-Z])/g,jt=t=>t.replace(Pt,"-$1").toLowerCase(),{hasOwnProperty:Tt}=Object.prototype,L=(t,e)=>Tt.call(t,e),Gt=t=>Array.isArray(t),at=t=>typeof t=="function"?[t,!1]:Gt(t)?[t[0],!0]:at(t.type),Ht=(t,e)=>t===Boolean?e!=="false":e,qt=(t,e)=>typeof e=="boolean"?e:t===Number&&e===""?Number.NaN:t(e),Vt=/[\s.:=]/,Jt=t=>{const e=`Flag name ${k(t)}`;if(t.length===0)throw new Error(`${e} cannot be empty`);if(t.length===1)throw new Error(`${e} must be longer than a character`);const s=t.match(Vt);if(s)throw new Error(`${e} cannot contain ${k(s==null?void 0:s[0])}`)},Ut=t=>{const e={},s=(r,o)=>{if(L(e,r))throw new Error(`Duplicate flags named ${k(r)}`);e[r]=o};for(const r in t){if(!L(t,r))continue;Jt(r);const o=t[r],n=[[],...at(o),o];s(r,n);const i=jt(r);if(r!==i&&s(i,n),"alias"in o&&typeof o.alias=="string"){const{alias:c}=o,a=`Flag alias ${k(c)} for flag ${k(r)}`;if(c.length===0)throw new Error(`${a} cannot be empty`);if(c.length>1)throw new Error(`${a} must be a single character`);s(c,n)}}return e},zt=(t,e)=>{const s={};for(const r in t){if(!L(t,r))continue;const[o,,n,i]=e[r];if(o.length===0&&"default"in i){let{default:c}=i;typeof c=="function"&&(c=c()),s[r]=c}else s[r]=n?o:o.pop()}return s},P="--",Kt=/[.:=]/,Zt=/^-{1,2}\w/,Qt=t=>{if(!Zt.test(t))return;const e=!t.startsWith(P);let s=t.slice(e?1:2),r;const o=s.match(Kt);if(o){const{index:n}=o;r=s.slice(n+1),s=s.slice(0,n)}return[s,r,e]},Xt=(t,{onFlag:e,onArgument:s})=>{let r;const o=(n,i)=>{if(typeof r!="function")return!0;r(n,i),r=void 0};for(let n=0;n<t.length;n+=1){const i=t[n];if(i===P){o();const a=t.slice(n+1);s==null||s(a,[n],!0);break}const c=Qt(i);if(c){if(o(),!e)continue;const[a,u,p]=c;if(p)for(let d=0;d<a.length;d+=1){o();const C=d===a.length-1;r=e(a[d],C?u:void 0,[n,d+1,C])}else r=e(a,u,[n])}else o(i,[n])&&(s==null||s([i],[n]))}o()},Yt=(t,e)=>{for(const[s,r,o]of e.reverse()){if(r){const n=t[s];let i=n.slice(0,r);if(o||(i+=n.slice(r+1)),i!=="-"){t[s]=i;continue}}t.splice(s,1)}},te=(t,e=process.argv.slice(2),{ignore:s}={})=>{const r=[],o=Ut(t),n={},i=[];return i[P]=[],Xt(e,{onFlag(c,a,u){const p=L(o,c);if(!(s!=null&&s(p?It:$t,c,a))){if(p){const[d,C]=o[c],_=Ht(C,a),R=(ot,A)=>{r.push(u),A&&r.push(A),d.push(qt(C,ot||""))};return _===void 0?R:R(_)}L(n,c)||(n[c]=[]),n[c].push(a===void 0?!0:a),r.push(u)}},onArgument(c,a,u){s!=null&&s(Rt,e[a[0]])||(i.push(...c),u?(i[P]=c,e.splice(a[0])):r.push(a))}}),Yt(e,r),{flags:zt(t,o),unknownFlags:n,_:i}};function H(t){return t!==null&&typeof t=="object"}function q(t,e,s=".",r){if(!H(e))return q(t,{},s,r);const o=Object.assign({},e);for(const n in t){if(n==="__proto__"||n==="constructor")continue;const i=t[n];i!=null&&(r&&r(o,n,i,s)||(Array.isArray(i)&&Array.isArray(o[n])?o[n]=[...i,...o[n]]:H(i)&&H(o[n])?o[n]=q(i,o[n],(s?`${s}.`:"")+n.toString(),r):o[n]=i))}return o}function ee(t){return(...e)=>e.reduce((s,r)=>q(s,r,"",t),{})}const se=ee(),j=t=>Array.isArray(t)?t:[t],re=t=>t.replace(/[-_ ](\w)/g,(e,s)=>s.toUpperCase()),ct=(t,e)=>e.length!==t.length?!1:t.every((s,r)=>s===e[r]),lt=(t,e)=>e.length>t.length?!1:ct(t.slice(0,e.length),e),B=JSON.stringify;class ut extends Error{constructor(e,s){super(s("core.commandExists",B(e))),this.commandName=e}}class ht extends Error{constructor(e,s){super(s("core.noSuchCommand",B(e))),this.commandName=e}}class ft extends Error{constructor(e){super(e("core.noCommandGiven"))}}class dt extends Error{constructor(e,s,r){super(r("core.commandNameConflict",B(e),B(s))),this.n1=e,this.n2=s}}class pt extends Error{constructor(e){super(e("core.nameNotSet"))}}class mt extends Error{constructor(e){super(e("core.descriptionNotSet"))}}class wt extends Error{constructor(e){super(e("core.versionNotSet"))}}class gt extends Error{constructor(e,s){super(s("core.badNameFormat",B(e))),this.commandName=e}}class V extends Error{constructor(e){super(e("core.localeMustBeCalledFirst"))}}const Et=typeof Deno!="undefined",ne=typeof process!="undefined"&&!Et,oe=process.versions.electron&&!process.defaultApp;function Ct(t,e,s,r){if(s.alias){const o=j(s.alias);for(const n of o){if(n in e)throw new dt(e[n].name,s.name,r);t.set(typeof n=="symbol"?n:n.split(" "),{...s,__isAlias:!0})}}}function J(t,e){const s=new Map;t[f]&&(s.set(f,t[f]),Ct(s,t,t[f],e));for(const r of Object.values(t))Ct(s,t,r,e),s.set(r.name.split(" "),r);return s}function _t(t,e,s){if(e===f)return[t[f],f];const r=j(e),o=J(t,s);let n,i;return o.forEach((c,a)=>{if(a===f){n=t[f],i=f;return}lt(r,a)&&(!i||i===f||a.length>i.length)&&(n=c,i=a)}),[n,i]}function ie(t,e,s){if(e===f)return[t[f],f];const r=j(e),o=J(t,s);let n,i;return o.forEach((c,a)=>{a===f||i===f||ct(r,a)&&(n=c,i=a)}),[n,i]}function vt(t,e,s=1/0){const r=e===""?[]:Array.isArray(e)?e:e.split(" ");return Object.values(t).filter(o=>{const n=o.name.split(" ");return lt(n,r)&&n.length-r.length<=s})}const ae=t=>vt(t,"",1);function yt(t){const e=[];for(const s of t){if(s.startsWith("-"))break;e.push(s)}return e}const U=()=>ne?process.argv.slice(oe?1:2):Et?Deno.args:[];function Nt(t){const e={pre:[],normal:[],post:[]};for(const r of t){const o=typeof r=="object"?r:{fn:r},{enforce:n,fn:i}=o;n==="post"||n==="pre"?e[n].push(i):e.normal.push(i)}const s=[...e.pre,...e.normal,...e.post];return r=>{return o(0);function o(n){const i=s[n];return i(r(),o.bind(null,n+1))}}}const ce=/\s\s+/,Mt=t=>t===f?!0:!(t.startsWith(" ")||t.endsWith(" "))&&!ce.test(t),le=(t,e)=>e?`[${t}]`:`<${t}>`,ue="<Root>",St=t=>Array.isArray(t)?t.join(" "):typeof t=="string"?t:ue,Ft=()=>process.env.CLERC_LOCALE?process.env.CLERC_LOCALE:Intl.DateTimeFormat().resolvedOptions().locale,{stringify:S}=JSON;function z(t){const e=[];let s,r;for(const o of t){if(r)throw new Error(`Invalid parameter: Spread parameter ${S(r)} must be last`);const n=o[0],i=o[o.length-1];let c;if(n==="<"&&i===">"&&(c=!0,s))throw new Error(`Invalid parameter: Required parameter ${S(o)} cannot come after optional parameter ${S(s)}`);if(n==="["&&i==="]"&&(c=!1,s=o),c===void 0)throw new Error(`Invalid parameter: ${S(o)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=o.slice(1,-1);const u=a.slice(-3)==="...";u&&(r=o,a=a.slice(0,-3)),e.push({name:a,required:c,spread:u})}return e}function K(t,e,s){for(let r=0;r<e.length;r+=1){const{name:o,required:n,spread:i}=e[r],c=re(o);if(c in t)throw new Error(`Invalid parameter: ${S(o)} is used more than once.`);const a=i?s.slice(r):s[r];if(i&&(r=e.length),n&&(!a||i&&a.length===0))throw new Error(`Missing required parameter ${S(o)}`);t[c]=a}}const he={en:{"core.commandExists":'Command "%s" exists.',"core.noSuchCommand":"No such command: %s.","core.noCommandGiven":"No command given.","core.commandNameConflict":"Command name %s conflicts with %s. Maybe caused by alias.","core.nameNotSet":"Name not set.","core.descriptionNotSet":"Description not set.","core.versionNotSet":"Version not set.","core.badNameFormat":"Bad name format: %s.","core.localeMustBeCalledFirst":"locale() or fallbackLocale() must be called at first.","core.cliParseMustBeCalled":"cli.parse() must be called."},"zh-CN":{"core.commandExists":'\u547D\u4EE4 "%s" \u5DF2\u5B58\u5728\u3002',"core.noSuchCommand":"\u627E\u4E0D\u5230\u547D\u4EE4: %s\u3002","core.noCommandGiven":"\u6CA1\u6709\u8F93\u5165\u547D\u4EE4\u3002","core.commandNameConflict":"\u547D\u4EE4\u540D\u79F0 %s \u548C %s \u51B2\u7A81\u3002 \u53EF\u80FD\u662F\u7531\u4E8E\u522B\u540D\u5BFC\u81F4\u7684\u3002","core.nameNotSet":"\u672A\u8BBE\u7F6ECLI\u540D\u79F0\u3002","core.descriptionNotSet":"\u672A\u8BBE\u7F6ECLI\u63CF\u8FF0\u3002","core.versionNotSet":"\u672A\u8BBE\u7F6ECLI\u7248\u672C\u3002","core.badNameFormat":"\u9519\u8BEF\u7684\u547D\u4EE4\u540D\u5B57\u683C\u5F0F: %s\u3002","core.localeMustBeCalledFirst":"locale() \u6216 fallbackLocale() \u5FC5\u987B\u5728\u6700\u5F00\u59CB\u8C03\u7528\u3002","core.cliParseMustBeCalled":"cli.parse() \u5FC5\u987B\u88AB\u8C03\u7528\u3002"}};var Z=(t,e,s)=>{if(!e.has(t))throw TypeError("Cannot "+s)},l=(t,e,s)=>(Z(t,e,"read from private field"),s?s.call(t):e.get(t)),h=(t,e,s)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,s)},w=(t,e,s,r)=>(Z(t,e,"write to private field"),r?r.call(t,s):e.set(t,s),s),m=(t,e,s)=>(Z(t,e,"access private method"),s),v,y,N,W,b,T,F,x,D,O,I,$,M,Q,At,X,kt,Y,Lt,g,E,tt,Bt,et,Wt,st,bt,G,rt,nt,xt;const f=Symbol.for("Clerc.Root"),Dt=class{constructor(t,e,s){h(this,Q),h(this,X),h(this,Y),h(this,g),h(this,tt),h(this,et),h(this,st),h(this,G),h(this,nt),h(this,v,""),h(this,y,""),h(this,N,""),h(this,W,[]),h(this,b,{}),h(this,T,new Ot),h(this,F,new Set),h(this,x,void 0),h(this,D,[]),h(this,O,!1),h(this,I,"en"),h(this,$,"en"),h(this,M,{}),this.i18n={add:r=>{w(this,M,se(l(this,M),r))},t:(r,...o)=>{const n=l(this,M)[l(this,$)]||l(this,M)[l(this,I)],i=l(this,M)[l(this,I)];return n[r]?it(n[r],...o):i[r]?it(i[r],...o):void 0}},w(this,v,t||l(this,v)),w(this,y,e||l(this,y)),w(this,N,s||l(this,N)),w(this,$,Ft()),m(this,Y,Lt).call(this)}get _name(){return l(this,v)}get _description(){return l(this,y)}get _version(){return l(this,N)}get _inspectors(){return l(this,W)}get _commands(){return l(this,b)}static create(t,e,s){return new Dt(t,e,s)}name(t){return m(this,g,E).call(this),w(this,v,t),this}description(t){return m(this,g,E).call(this),w(this,y,t),this}version(t){return m(this,g,E).call(this),w(this,N,t),this}locale(t){if(l(this,O))throw new V(this.i18n.t);return w(this,$,t),this}fallbackLocale(t){if(l(this,O))throw new V(this.i18n.t);return w(this,I,t),this}errorHandler(t){return l(this,D).push(t),this}command(t,e,s={}){return m(this,G,rt).call(this,()=>m(this,tt,Bt).call(this,t,e,s)),this}on(t,e){return l(this,T).on(t,e),this}use(t){return m(this,g,E).call(this),t.setup(this)}inspector(t){return m(this,g,E).call(this),l(this,W).push(t),this}parse(t=U()){m(this,g,E).call(this);const{argv:e,run:s}=Array.isArray(t)?{argv:t,run:!0}:{argv:U(),...t};return w(this,x,e),m(this,et,Wt).call(this),s&&this.runMatchedCommand(),this}runMatchedCommand(){return m(this,G,rt).call(this,()=>m(this,nt,xt).call(this)),this}};let fe=Dt;v=new WeakMap,y=new WeakMap,N=new WeakMap,W=new WeakMap,b=new WeakMap,T=new WeakMap,F=new WeakMap,x=new WeakMap,D=new WeakMap,O=new WeakMap,I=new WeakMap,$=new WeakMap,M=new WeakMap,Q=new WeakSet,At=function(){return l(this,F).has(f)},X=new WeakSet,kt=function(){return Object.prototype.hasOwnProperty.call(this._commands,f)},Y=new WeakSet,Lt=function(){this.i18n.add(he)},g=new WeakSet,E=function(){w(this,O,!0)},tt=new WeakSet,Bt=function(t,e,s={}){m(this,g,E).call(this);const{t:r}=this.i18n,n=(d=>!(typeof d=="string"||d===f))(t),i=n?t.name:t;if(!Mt(i))throw new gt(i,r);const{handler:c=void 0,...a}=n?t:{name:i,description:e,...s},u=[a.name],p=a.alias?j(a.alias):[];a.alias&&u.push(...p);for(const d of u)if(l(this,F).has(d))throw new ut(St(d),r);return l(this,b)[i]=a,l(this,F).add(a.name),p.forEach(d=>l(this,F).add(d)),n&&c&&this.on(t.name,c),this},et=new WeakSet,Wt=function(){const{t}=this.i18n;if(!l(this,v))throw new pt(t);if(!l(this,y))throw new mt(t);if(!l(this,N))throw new wt(t)},st=new WeakSet,bt=function(t){const e=l(this,x),[s,r]=t(),o=!!s,n=te((s==null?void 0:s.flags)||{},[...e]),{_:i,flags:c,unknownFlags:a}=n;let u=!o||s.name===f?i:i.slice(s.name.split(" ").length),p=(s==null?void 0:s.parameters)||[];const d=p.indexOf("--"),C=p.slice(d+1)||[],_=Object.create(null);if(d>-1&&C.length>0){p=p.slice(0,d);const A=i["--"];u=u.slice(0,-A.length||void 0),K(_,z(p),u),K(_,z(C),A)}else K(_,z(p),u);const R={...c,...a};return{name:s==null?void 0:s.name,called:Array.isArray(r)?r.join(" "):r,resolved:o,hasRootOrAlias:l(this,Q,At),hasRoot:l(this,X,kt),raw:{...n,parameters:u,mergedFlags:R},parameters:_,flags:c,unknownFlags:a,cli:this}},G=new WeakSet,rt=function(t){try{t()}catch(e){if(l(this,D).length>0)l(this,D).forEach(s=>s(e));else throw e}},nt=new WeakSet,xt=function(){m(this,g,E).call(this);const{t}=this.i18n,e=l(this,x);if(!e)throw new Error(t("core.cliParseMustBeCalled"));const s=yt(e),r=s.join(" "),o=()=>_t(l(this,b),s,t),n=()=>m(this,st,bt).call(this,o),i={enforce:"post",fn:()=>{const[u]=o(),p=n();if(!u)throw r?new ht(r,t):new ft(t);l(this,T).emit(u.name,p)}},c=[...l(this,W),i];Nt(c)(n)};const de=t=>t,pe=(t,e,s)=>s,me=(t,e)=>e,we=(t,e)=>({...t,handler:e});export{fe as Clerc,ut as CommandExistsError,dt as CommandNameConflictError,mt as DescriptionNotSetError,gt as InvalidCommandNameError,V as LocaleNotCalledFirstError,pt as NameNotSetError,ft as NoCommandGivenError,ht as NoSuchCommandError,f as Root,wt as VersionNotSetError,Nt as compose,we as defineCommand,pe as defineHandler,me as defineInspector,de as definePlugin,Ft as detectLocale,St as formatCommandName,Mt as isValidName,U as resolveArgv,_t as resolveCommand,ie as resolveCommandStrict,J as resolveFlattenCommands,yt as resolveParametersBeforeFlag,ae as resolveRootCommands,vt as resolveSubcommandsByParent,le as withBrackets};
|
|
1
|
+
import{format as ie}from"node:util";class Ie{constructor(){this.listenerMap={},this.wildcardListeners=new Set}on(t,r){return t==="*"?(this.wildcardListeners.add(r),this):(this.listenerMap[t]||(this.listenerMap[t]=new Set),this.listenerMap[t].add(r),this)}emit(t,...r){return this.listenerMap[t]&&(this.wildcardListeners.forEach(s=>s(t,...r)),this.listenerMap[t].forEach(s=>s(...r))),this}off(t,r){var s,o;return t==="**"?(this.listenerMap={},this.wildcardListeners.clear(),this):t==="*"?(r?this.wildcardListeners.delete(r):this.wildcardListeners.clear(),this):(r?(s=this.listenerMap[t])==null||s.delete(r):(o=this.listenerMap[t])==null||o.clear(),this)}}const xe="known-flag",Re="unknown-flag",$e="argument",{stringify:S}=JSON,je=/\B([A-Z])/g,qe=e=>e.replace(je,"-$1").toLowerCase(),{hasOwnProperty:Te}=Object.prototype,k=(e,t)=>Te.call(e,t),Ge=e=>Array.isArray(e),ce=e=>typeof e=="function"?[e,!1]:Ge(e)?[e[0],!0]:ce(e.type),He=(e,t)=>e===Boolean?t!=="false":t,Ue=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),Ve=/[\s.:=]/,Je=e=>{const t=`Flag name ${S(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 r=e.match(Ve);if(r)throw new Error(`${t} cannot contain ${S(r==null?void 0:r[0])}`)},ze=e=>{const t={},r=(s,o)=>{if(k(t,s))throw new Error(`Duplicate flags named ${S(s)}`);t[s]=o};for(const s in e){if(!k(e,s))continue;Je(s);const o=e[s],n=[[],...ce(o),o];r(s,n);const a=qe(s);if(s!==a&&r(a,n),"alias"in o&&typeof o.alias=="string"){const{alias:c}=o,i=`Flag alias ${S(c)} for flag ${S(s)}`;if(c.length===0)throw new Error(`${i} cannot be empty`);if(c.length>1)throw new Error(`${i} must be a single character`);r(c,n)}}return t},Ke=(e,t)=>{const r={};for(const s in e){if(!k(e,s))continue;const[o,,n,a]=t[s];if(o.length===0&&"default"in a){let{default:c}=a;typeof c=="function"&&(c=c()),r[s]=c}else r[s]=n?o:o.pop()}return r},R="--",Ze=/[.:=]/,Qe=/^-{1,2}\w/,Xe=e=>{if(!Qe.test(e))return;const t=!e.startsWith(R);let r=e.slice(t?1:2),s;const o=r.match(Ze);if(o){const{index:n}=o;s=r.slice(n+1),r=r.slice(0,n)}return[r,s,t]},Ye=(e,{onFlag:t,onArgument:r})=>{let s;const o=(n,a)=>{if(typeof s!="function")return!0;s(n,a),s=void 0};for(let n=0;n<e.length;n+=1){const a=e[n];if(a===R){o();const i=e.slice(n+1);r==null||r(i,[n],!0);break}const c=Xe(a);if(c){if(o(),!t)continue;const[i,l,m]=c;if(m)for(let h=0;h<i.length;h+=1){o();const E=h===i.length-1;s=t(i[h],E?l:void 0,[n,h+1,E])}else s=t(i,l,[n])}else o(a,[n])&&(r==null||r([a],[n]))}o()},et=(e,t)=>{for(const[r,s,o]of t.reverse()){if(s){const n=e[r];let a=n.slice(0,s);if(o||(a+=n.slice(s+1)),a!=="-"){e[r]=a;continue}}e.splice(r,1)}},tt=(e,t=process.argv.slice(2),{ignore:r}={})=>{const s=[],o=ze(e),n={},a=[];return a[R]=[],Ye(t,{onFlag(c,i,l){const m=k(o,c);if(!(r!=null&&r(m?xe:Re,c,i))){if(m){const[h,E]=o[c],A=He(E,i),v=(T,G)=>{s.push(l),G&&s.push(G),h.push(Ue(E,T||""))};return A===void 0?v:v(A)}k(n,c)||(n[c]=[]),n[c].push(i===void 0?!0:i),s.push(l)}},onArgument(c,i,l){r!=null&&r($e,t[i[0]])||(a.push(...c),l?(a[R]=c,t.splice(i[0])):s.push(i))}}),et(t,s),{flags:Ke(e,o),unknownFlags:n,_:a}};function H(e){return e!==null&&typeof e=="object"}function U(e,t,r=".",s){if(!H(t))return U(e,{},r,s);const o=Object.assign({},t);for(const n in e){if(n==="__proto__"||n==="constructor")continue;const a=e[n];a!=null&&(s&&s(o,n,a,r)||(Array.isArray(a)&&Array.isArray(o[n])?o[n]=[...a,...o[n]]:H(a)&&H(o[n])?o[n]=U(a,o[n],(r?`${r}.`:"")+n.toString(),s):o[n]=a))}return o}function rt(e){return(...t)=>t.reduce((r,s)=>U(r,s,"",e),{})}const st=rt(),$=e=>Array.isArray(e)?e:[e],nt=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,r)=>r?r.toUpperCase():""),ue=(e,t)=>t.length!==e.length?!1:e.every((r,s)=>r===t[s]),le=(e,t)=>t.length>e.length?!1:ue(e.slice(0,t.length),t),L=JSON.stringify;class he extends Error{constructor(t,r){super(r("core.commandExists",L(t))),this.commandName=t}}class de extends Error{constructor(t,r){super(r("core.noSuchCommand",L(t))),this.commandName=t}}class fe extends Error{constructor(t){super(t("core.noCommandGiven"))}}class me extends Error{constructor(t,r,s){super(s("core.commandNameConflict",L(t),L(r))),this.n1=t,this.n2=r}}class pe extends Error{constructor(t){super(t("core.nameNotSet"))}}class Ce extends Error{constructor(t){super(t("core.descriptionNotSet"))}}class we extends Error{constructor(t){super(t("core.versionNotSet"))}}class Ee extends Error{constructor(t,r){super(r("core.badNameFormat",L(t))),this.commandName=t}}class V extends Error{constructor(t){super(t("core.localeMustBeCalledFirst"))}}const ge=typeof Deno!="undefined",ot=typeof process!="undefined"&&!ge,at=process.versions.electron&&!process.defaultApp;function _e(e,t,r,s){if(r.alias){const o=$(r.alias);for(const n of o){if(n in t)throw new me(t[n].name,r.name,s);e.set(typeof n=="symbol"?n:n.split(" "),{...r,__isAlias:!0})}}}function J(e,t){const r=new Map;e[f]&&(r.set(f,e[f]),_e(r,e,e[f],t));for(const s of Object.values(e))_e(r,e,s,t),r.set(s.name.split(" "),s);return r}function ve(e,t,r){if(t===f)return[e[f],f];const s=$(t),o=J(e,r);let n,a;return o.forEach((c,i)=>{if(i===f){n=e[f],a=f;return}le(s,i)&&(!a||a===f||i.length>a.length)&&(n=c,a=i)}),[n,a]}function it(e,t,r){if(t===f)return[e[f],f];const s=$(t),o=J(e,r);let n,a;return o.forEach((c,i)=>{i===f||a===f||ue(s,i)&&(n=c,a=i)}),[n,a]}function Me(e,t,r=1/0){const s=t===""?[]:Array.isArray(t)?t:t.split(" ");return Object.values(e).filter(o=>{const n=o.name.split(" ");return le(n,s)&&n.length-s.length<=r})}const ct=e=>Me(e,"",1);function Fe(e){const t=[];for(const r of e){if(r.startsWith("-"))break;t.push(r)}return t}const z=()=>ot?process.argv.slice(at?1:2):ge?Deno.args:[];function ye(e){const t={pre:[],normal:[],post:[]};for(const s of e){const o=typeof s=="object"?s:{fn:s},{enforce:n,fn:a}=o;n==="post"||n==="pre"?t[n].push(a):t.normal.push(a)}const r=[...t.pre,...t.normal,...t.post];return s=>{const o=[];n(0);for(let a=o.length-1;a>=0;a--)o[a]();function n(a){const c=r[a],i=c(s(),n.bind(null,a+1));i&&o.push(i)}}}const ut=/\s\s+/,Be=e=>e===f?!0:!(e.startsWith(" ")||e.endsWith(" "))&&!ut.test(e),lt=(e,t)=>t?`[${e}]`:`<${e}>`,ht="<Root>",Ne=e=>Array.isArray(e)?e.join(" "):typeof e=="string"?e:ht,Ae=()=>process.env.CLERC_LOCALE?process.env.CLERC_LOCALE:Intl.DateTimeFormat().resolvedOptions().locale,{stringify:B}=JSON;function K(e,t){const r=[];let s,o;for(const n of e){if(o)throw new Error(t("core.spreadParameterMustBeLast",B(o)));const a=n[0],c=n[n.length-1];let i;if(a==="<"&&c===">"&&(i=!0,s))throw new Error(t("core.requiredParameterMustBeBeforeOptional",B(n),B(s)));if(a==="["&&c==="]"&&(i=!1,s=n),i===void 0)throw new Error(t("core.parameterMustBeWrappedInBrackets",B(n)));let l=n.slice(1,-1);const m=l.slice(-3)==="...";m&&(o=n,l=l.slice(0,-3)),r.push({name:l,required:i,spread:m})}return r}function Z(e,t,r,s){for(let o=0;o<t.length;o+=1){const{name:n,required:a,spread:c}=t[o],i=nt(n);if(i in e)throw new Error(s("core.parameterIsUsedMoreThanOnce",B(n)));const l=c?r.slice(o):r[o];if(c&&(o=t.length),a&&(!l||c&&l.length===0))throw new Error(s("core.missingRequiredParameter",B(n)));e[i]=l}}const dt={en:{"core.commandExists":'Command "%s" exists.',"core.noSuchCommand":"No such command: %s.","core.noCommandGiven":"No command given.","core.commandNameConflict":"Command name %s conflicts with %s. Maybe caused by alias.","core.nameNotSet":"Name not set.","core.descriptionNotSet":"Description not set.","core.versionNotSet":"Version not set.","core.badNameFormat":"Bad name format: %s.","core.localeMustBeCalledFirst":"locale() or fallbackLocale() must be called at first.","core.cliParseMustBeCalled":"cli.parse() must be called.","core.spreadParameterMustBeLast":"Invalid Parameter: Spread parameter %s must be last.","core.requiredParameterCannotComeAfterOptionalParameter":"Invalid Parameter: Required parameter %s cannot come after optional parameter %s.","core.parameterMustBeWrappedInBrackets":"Invalid Parameter: Parameter %s must be wrapped in <> (required parameter) or [] (optional parameter).","core.parameterIsUsedMoreThanOnce":"Invalid Parameter: Parameter %s is used more than once.","core.missingRequiredParameter":"Missing required parameter %s."},"zh-CN":{"core.commandExists":'\u547D\u4EE4 "%s" \u5DF2\u5B58\u5728\u3002',"core.noSuchCommand":"\u627E\u4E0D\u5230\u547D\u4EE4: %s\u3002","core.noCommandGiven":"\u6CA1\u6709\u8F93\u5165\u547D\u4EE4\u3002","core.commandNameConflict":"\u547D\u4EE4\u540D\u79F0 %s \u548C %s \u51B2\u7A81\u3002 \u53EF\u80FD\u662F\u7531\u4E8E\u522B\u540D\u5BFC\u81F4\u7684\u3002","core.nameNotSet":"\u672A\u8BBE\u7F6ECLI\u540D\u79F0\u3002","core.descriptionNotSet":"\u672A\u8BBE\u7F6ECLI\u63CF\u8FF0\u3002","core.versionNotSet":"\u672A\u8BBE\u7F6ECLI\u7248\u672C\u3002","core.badNameFormat":"\u9519\u8BEF\u7684\u547D\u4EE4\u540D\u5B57\u683C\u5F0F: %s\u3002","core.localeMustBeCalledFirst":"locale() \u6216 fallbackLocale() \u5FC5\u987B\u5728\u6700\u5F00\u59CB\u8C03\u7528\u3002","core.cliParseMustBeCalled":"cli.parse() \u5FC5\u987B\u88AB\u8C03\u7528\u3002","core.spreadParameterMustBeLast":"\u4E0D\u5408\u6CD5\u7684\u53C2\u6570: \u5C55\u5F00\u53C2\u6570 %s \u5FC5\u987B\u5728\u6700\u540E\u3002","core.requiredParameterCannotComeAfterOptionalParameter":"\u4E0D\u5408\u6CD5\u7684\u53C2\u6570: \u5FC5\u586B\u53C2\u6570 %s \u4E0D\u80FD\u5728\u53EF\u9009\u53C2\u6570 %s \u4E4B\u540E\u3002","core.parameterMustBeWrappedInBrackets":"\u4E0D\u5408\u6CD5\u7684\u53C2\u6570: \u53C2\u6570 %s \u5FC5\u987B\u88AB <> (\u5FC5\u586B\u53C2\u6570) \u6216 [] (\u53EF\u9009\u53C2\u6570) \u5305\u88F9\u3002","core.parameterIsUsedMoreThanOnce":"\u4E0D\u5408\u6CD5\u7684\u53C2\u6570: \u53C2\u6570 %s \u88AB\u4F7F\u7528\u4E86\u591A\u6B21\u3002","core.missingRequiredParameter":"\u7F3A\u5C11\u5FC5\u586B\u53C2\u6570 %s\u3002"}};var Q=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},u=(e,t,r)=>(Q(e,t,"read from private field"),r?r.call(e):t.get(e)),d=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},C=(e,t,r,s)=>(Q(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),p=(e,t,r)=>(Q(e,t,"access private method"),r),_,M,F,D,W,j,N,b,P,O,I,x,y,X,Se,Y,ke,ee,Le,w,g,te,De,re,We,se,be,q,ne,oe,Pe;const f=Symbol.for("Clerc.Root"),Oe=class{constructor(e,t,r){d(this,X),d(this,Y),d(this,ee),d(this,w),d(this,te),d(this,re),d(this,se),d(this,q),d(this,oe),d(this,_,""),d(this,M,""),d(this,F,""),d(this,D,[]),d(this,W,{}),d(this,j,new Ie),d(this,N,new Set),d(this,b,void 0),d(this,P,[]),d(this,O,!1),d(this,I,"en"),d(this,x,"en"),d(this,y,{}),this.i18n={add:s=>{C(this,y,st(u(this,y),s))},t:(s,...o)=>{const n=u(this,y)[u(this,x)]||u(this,y)[u(this,I)],a=u(this,y)[u(this,I)];return n[s]?ie(n[s],...o):a[s]?ie(a[s],...o):void 0}},C(this,_,e||u(this,_)),C(this,M,t||u(this,M)),C(this,F,r||u(this,F)),C(this,x,Ae()),p(this,ee,Le).call(this)}get _name(){return u(this,_)}get _description(){return u(this,M)}get _version(){return u(this,F)}get _inspectors(){return u(this,D)}get _commands(){return u(this,W)}static create(e,t,r){return new Oe(e,t,r)}name(e){return p(this,w,g).call(this),C(this,_,e),this}description(e){return p(this,w,g).call(this),C(this,M,e),this}version(e){return p(this,w,g).call(this),C(this,F,e),this}locale(e){if(u(this,O))throw new V(this.i18n.t);return C(this,x,e),this}fallbackLocale(e){if(u(this,O))throw new V(this.i18n.t);return C(this,I,e),this}errorHandler(e){return u(this,P).push(e),this}command(e,t,r={}){return p(this,q,ne).call(this,()=>p(this,te,De).call(this,e,t,r)),this}on(e,t){return u(this,j).on(e,t),this}use(e){return p(this,w,g).call(this),e.setup(this)}inspector(e){return p(this,w,g).call(this),u(this,D).push(e),this}parse(e=z()){p(this,w,g).call(this);const{argv:t,run:r}=Array.isArray(e)?{argv:e,run:!0}:{argv:z(),...e};return C(this,b,[...t]),p(this,re,We).call(this),r&&this.runMatchedCommand(),this}runMatchedCommand(){return p(this,q,ne).call(this,()=>p(this,oe,Pe).call(this)),process.title=u(this,_),this}};let ft=Oe;_=new WeakMap,M=new WeakMap,F=new WeakMap,D=new WeakMap,W=new WeakMap,j=new WeakMap,N=new WeakMap,b=new WeakMap,P=new WeakMap,O=new WeakMap,I=new WeakMap,x=new WeakMap,y=new WeakMap,X=new WeakSet,Se=function(){return u(this,N).has(f)},Y=new WeakSet,ke=function(){return Object.prototype.hasOwnProperty.call(this._commands,f)},ee=new WeakSet,Le=function(){this.i18n.add(dt)},w=new WeakSet,g=function(){C(this,O,!0)},te=new WeakSet,De=function(e,t,r={}){p(this,w,g).call(this);const{t:s}=this.i18n,n=(h=>!(typeof h=="string"||h===f))(e),a=n?e.name:e;if(!Be(a))throw new Ee(a,s);const{handler:c=void 0,...i}=n?e:{name:a,description:t,...r},l=[i.name],m=i.alias?$(i.alias):[];i.alias&&l.push(...m);for(const h of l)if(u(this,N).has(h))throw new he(Ne(h),s);return u(this,W)[a]=i,u(this,N).add(i.name),m.forEach(h=>u(this,N).add(h)),n&&c&&this.on(e.name,c),this},re=new WeakSet,We=function(){const{t:e}=this.i18n;if(!u(this,_))throw new pe(e);if(!u(this,M))throw new Ce(e);if(!u(this,F))throw new we(e)},se=new WeakSet,be=function(e){const t=u(this,b),{t:r}=this.i18n,[s,o]=e(),n=!!s,a=tt((s==null?void 0:s.flags)||{},[...t]),{_:c,flags:i,unknownFlags:l}=a;let m=!n||s.name===f?c:c.slice(s.name.split(" ").length),h=(s==null?void 0:s.parameters)||[];const E=h.indexOf("--"),A=h.slice(E+1)||[],v=Object.create(null);if(E>-1&&A.length>0){h=h.slice(0,E);const ae=c["--"];m=m.slice(0,-ae.length||void 0),Z(v,K(h,r),m,r),Z(v,K(A,r),ae,r)}else Z(v,K(h,r),m,r);const T={...i,...l};return{name:s==null?void 0:s.name,called:Array.isArray(o)?o.join(" "):o,resolved:n,hasRootOrAlias:u(this,X,Se),hasRoot:u(this,Y,ke),raw:{...a,parameters:m,mergedFlags:T},parameters:v,flags:i,unknownFlags:l,cli:this}},q=new WeakSet,ne=function(e){try{e()}catch(t){if(u(this,P).length>0)u(this,P).forEach(r=>r(t));else throw t}},oe=new WeakSet,Pe=function(){p(this,w,g).call(this);const{t:e}=this.i18n,t=u(this,b);if(!t)throw new Error(e("core.cliParseMustBeCalled"));const r=Fe(t),s=r.join(" "),o=()=>ve(u(this,W),r,e),n=()=>p(this,se,be).call(this,o),a={enforce:"post",fn:()=>{const[l]=o(),m=n();if(!l)throw s?new de(s,e):new fe(e);u(this,j).emit(l.name,m)}},c=[...u(this,D),a];ye(c)(n)};const mt=e=>e,pt=(e,t,r)=>r,Ct=(e,t)=>t,wt=(e,t)=>({...e,handler:t});export{ft as Clerc,he as CommandExistsError,me as CommandNameConflictError,Ce as DescriptionNotSetError,Ee as InvalidCommandNameError,V as LocaleNotCalledFirstError,pe as NameNotSetError,fe as NoCommandGivenError,de as NoSuchCommandError,f as Root,we as VersionNotSetError,ye as compose,wt as defineCommand,pt as defineHandler,Ct as defineInspector,mt as definePlugin,Ae as detectLocale,Ne as formatCommandName,Be as isValidName,z as resolveArgv,ve as resolveCommand,it as resolveCommandStrict,J as resolveFlattenCommands,Fe as resolveParametersBeforeFlag,ct as resolveRootCommands,Me as resolveSubcommandsByParent,lt as withBrackets};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"author": "Ray <i@mk1.io> (https://github.com/so1ve)",
|
|
5
5
|
"description": "Clerc core",
|
|
6
6
|
"keywords": [
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"lite-emit": "^1.4.0",
|
|
53
53
|
"type-fest": "^3.5.3",
|
|
54
54
|
"type-flag": "^3.0.0",
|
|
55
|
-
"@clerc/utils": "0.
|
|
55
|
+
"@clerc/utils": "0.32.0"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "puild --minify",
|