clerc 0.28.1 → 0.29.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 CHANGED
@@ -257,6 +257,13 @@ interface Plugin<T extends Clerc = Clerc, U extends Clerc = Clerc> {
257
257
  setup: (cli: T) => U;
258
258
  }
259
259
 
260
+ type Locales = Dict<Dict<string>>;
261
+ type TranslateFn = (name: string, ...args: string[]) => string | undefined;
262
+ interface I18N {
263
+ add: (locales: Locales) => void;
264
+ t: TranslateFn;
265
+ }
266
+
260
267
  type CommandType = RootType | string;
261
268
  type FlagOptions = FlagSchema & {
262
269
  description?: string;
@@ -323,15 +330,13 @@ type InspectorFn<C extends CommandRecord = CommandRecord> = (ctx: InspectorConte
323
330
  interface InspectorObject<C extends CommandRecord = CommandRecord> {
324
331
  enforce?: "pre" | "post";
325
332
  fn: InspectorFn<C>;
326
- }
327
- interface I18N {
328
- add: () => void;
329
333
  }
330
334
 
331
335
  declare const Root: unique symbol;
332
336
  type RootType = typeof Root;
333
337
  declare class Clerc<C extends CommandRecord = {}> {
334
338
  #private;
339
+ i18n: I18N;
335
340
  private constructor();
336
341
  get _name(): string;
337
342
  get _description(): string;
@@ -365,7 +370,8 @@ declare class Clerc<C extends CommandRecord = {}> {
365
370
  * @example
366
371
  * ```ts
367
372
  * Clerc.create()
368
- * .description("test cli")
373
+ * .description("test cli")
374
+ * ```
369
375
  */
370
376
  description(description: string): this;
371
377
  /**
@@ -375,9 +381,36 @@ declare class Clerc<C extends CommandRecord = {}> {
375
381
  * @example
376
382
  * ```ts
377
383
  * Clerc.create()
378
- * .version("1.0.0")
384
+ * .version("1.0.0")
385
+ * ```
379
386
  */
380
387
  version(version: string): this;
388
+ /**
389
+ * Set the Locale
390
+ * It's recommended to call this method once after you created the Clerc instance.
391
+ * @param locale
392
+ * @returns
393
+ * @example
394
+ * ```ts
395
+ * Clerc.create()
396
+ * .locale("en")
397
+ * .command(...)
398
+ * ```
399
+ */
400
+ locale(locale: string): this;
401
+ /**
402
+ * Set the fallback Locale
403
+ * It's recommended to call this method once after you created the Clerc instance.
404
+ * @param fallbackLocale
405
+ * @returns
406
+ * @example
407
+ * ```ts
408
+ * Clerc.create()
409
+ * .fallbackLocale("en")
410
+ * .command(...)
411
+ * ```
412
+ */
413
+ fallbackLocale(fallbackLocale: string): this;
381
414
  /**
382
415
  * Register a command
383
416
  * @param name
@@ -426,7 +459,7 @@ declare class Clerc<C extends CommandRecord = {}> {
426
459
  * })
427
460
  * ```
428
461
  */
429
- on<K extends LiteralUnion<keyof CM, string>, CM extends this["_commands"] = this["_commands"]>(name: K, handler: Handler<CM, K>): this;
462
+ on<K extends LiteralUnion<keyof CM, string | RootType>, CM extends this["_commands"] = this["_commands"]>(name: K, handler: Handler<CM, K>): this;
430
463
  /**
431
464
  * Use a plugin
432
465
  * @param plugin
@@ -463,6 +496,16 @@ declare class Clerc<C extends CommandRecord = {}> {
463
496
  * ```
464
497
  */
465
498
  parse(optionsOrArgv?: string[] | ParseOptions): this;
499
+ /**
500
+ * Run matched command
501
+ * @returns
502
+ * @example
503
+ * ```ts
504
+ * Clerc.create()
505
+ * .parse({ run: false })
506
+ * .runMatchedCommand()
507
+ * ```
508
+ */
466
509
  runMatchedCommand(): this;
467
510
  }
468
511
 
@@ -475,36 +518,40 @@ declare const defineCommand: <N extends string | typeof Root, O extends CommandO
475
518
 
476
519
  declare class CommandExistsError extends Error {
477
520
  commandName: string;
478
- constructor(commandName: string);
521
+ constructor(commandName: string, t: TranslateFn);
479
522
  }
480
523
  declare class NoSuchCommandError extends Error {
481
524
  commandName: string;
482
- constructor(commandName: string);
525
+ constructor(commandName: string, t: TranslateFn);
483
526
  }
484
527
  declare class NoCommandGivenError extends Error {
485
- constructor();
528
+ constructor(t: TranslateFn);
486
529
  }
487
530
  declare class CommandNameConflictError extends Error {
488
531
  n1: string;
489
532
  n2: string;
490
- constructor(n1: string, n2: string);
533
+ constructor(n1: string, n2: string, t: TranslateFn);
491
534
  }
492
535
  declare class NameNotSetError extends Error {
493
- constructor();
536
+ constructor(t: TranslateFn);
494
537
  }
495
538
  declare class DescriptionNotSetError extends Error {
496
- constructor();
539
+ constructor(t: TranslateFn);
497
540
  }
498
541
  declare class VersionNotSetError extends Error {
499
- constructor();
542
+ constructor(t: TranslateFn);
500
543
  }
501
544
  declare class InvalidCommandNameError extends Error {
502
545
  commandName: string;
503
- constructor(commandName: string);
546
+ constructor(commandName: string, t: TranslateFn);
547
+ }
548
+ declare class LocaleNotCalledFirstError extends Error {
549
+ constructor(t: TranslateFn);
504
550
  }
505
551
 
506
- declare function resolveFlattenCommands(commands: CommandRecord): Map<string[] | typeof Root, CommandAlias<string, CommandOptions<string[], MaybeArray$1<string | typeof Root>, Flags>>>;
507
- declare function resolveCommand(commands: CommandRecord, name: string | string[] | RootType): Command<string | RootType> | undefined;
552
+ declare function resolveFlattenCommands(commands: CommandRecord, t: TranslateFn): Map<string[] | typeof Root, CommandAlias<string, CommandOptions<string[], MaybeArray$1<string | typeof Root>, Flags>>>;
553
+ declare function resolveCommand(commands: CommandRecord, name: CommandType | string[], t: TranslateFn): [Command<string | RootType> | undefined, string[] | RootType | undefined];
554
+ declare function resolveCommandStrict(commands: CommandRecord, name: CommandType | string[], t: TranslateFn): [Command<string | RootType> | undefined, string[] | RootType | undefined];
508
555
  declare function resolveSubcommandsByParent(commands: CommandRecord, parent: string | string[], depth?: number): Command<string, CommandOptions<string[], MaybeArray$1<string | typeof Root>, Flags>>[];
509
556
  declare const resolveRootCommands: (commands: CommandRecord) => Command<string, CommandOptions<string[], MaybeArray$1<string | typeof Root>, Flags>>[];
510
557
  declare function resolveParametersBeforeFlag(argv: string[]): string[];
@@ -512,7 +559,8 @@ declare const resolveArgv: () => string[];
512
559
  declare function compose(inspectors: Inspector[]): (getCtx: () => InspectorContext) => void;
513
560
  declare const isInvalidName: (name: CommandType) => boolean;
514
561
  declare const withBrackets: (s: string, isOptional?: boolean) => string;
515
- declare const formatCommandName: (name: string | string[] | RootType) => string;
562
+ declare const formatCommandName: (name: string | string[] | RootType) => string;
563
+ declare const detectLocale: () => string;
516
564
 
517
565
  interface CompletionsPluginOptions {
518
566
  command?: boolean;
@@ -561,4 +609,4 @@ declare const versionPlugin: ({ alias, command, }?: VersionPluginOptions) => Plu
561
609
 
562
610
  declare const friendlyErrorPlugin: () => Plugin<Clerc<{}>, Clerc<{}>>;
563
611
 
564
- export { Clerc, Command, CommandAlias, CommandCustomProperties, CommandExistsError, CommandNameConflictError, CommandOptions, CommandRecord, CommandType, CommandWithHandler, CompletionsPluginOptions, DescriptionNotSetError, FallbackType, Flag, FlagOptions, Flags, Handler, HandlerContext, HandlerInCommand, HelpPluginOptions, I18N, Inspector, InspectorContext, InspectorFn, InspectorObject, InvalidCommandNameError, MakeEventMap, NameNotSetError, NoCommandGivenError, NoSuchCommandError, ParseOptions, Plugin, PossibleInputKind, Root, RootType, VersionNotSetError, completionsPlugin, compose, defineCommand, defineHandler, defineInspector, definePlugin, formatCommandName, friendlyErrorPlugin, helpPlugin, isInvalidName, notFoundPlugin, resolveArgv, resolveCommand, resolveFlattenCommands, resolveParametersBeforeFlag, resolveRootCommands, resolveSubcommandsByParent, strictFlagsPlugin, versionPlugin, withBrackets };
612
+ export { Clerc, Command, CommandAlias, CommandCustomProperties, CommandExistsError, CommandNameConflictError, CommandOptions, CommandRecord, CommandType, CommandWithHandler, CompletionsPluginOptions, DescriptionNotSetError, FallbackType, Flag, FlagOptions, Flags, Handler, HandlerContext, HandlerInCommand, HelpPluginOptions, I18N, Inspector, InspectorContext, InspectorFn, InspectorObject, InvalidCommandNameError, LocaleNotCalledFirstError, Locales, MakeEventMap, NameNotSetError, NoCommandGivenError, NoSuchCommandError, ParseOptions, Plugin, PossibleInputKind, Root, RootType, TranslateFn, VersionNotSetError, completionsPlugin, compose, defineCommand, defineHandler, defineInspector, definePlugin, detectLocale, formatCommandName, friendlyErrorPlugin, helpPlugin, isInvalidName, notFoundPlugin, resolveArgv, resolveCommand, resolveCommandStrict, resolveFlattenCommands, resolveParametersBeforeFlag, resolveRootCommands, resolveSubcommandsByParent, strictFlagsPlugin, versionPlugin, withBrackets };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- 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=>`
1
+ import{format as Te}from"node:util";import pe from"tty";class At{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,s;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):(s=this.listenerMap[t])==null||s.clear(),this)}}const Dt="known-flag",Ot="unknown-flag",_t="argument",{stringify:V}=JSON,Tt=/\B([A-Z])/g,Mt=e=>e.replace(Tt,"-$1").toLowerCase(),{hasOwnProperty:Nt}=Object.prototype,Z=(e,t)=>Nt.call(e,t),Lt=e=>Array.isArray(e),Me=e=>typeof e=="function"?[e,!1]:Lt(e)?[e[0],!0]:Me(e.type),It=(e,t)=>e===Boolean?t!=="false":t,kt=(e,t)=>typeof t=="boolean"?t:e===Number&&t===""?Number.NaN:e(t),Rt=/[\s.:=]/,jt=e=>{const t=`Flag name ${V(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(Rt);if(n)throw new Error(`${t} cannot contain ${V(n==null?void 0:n[0])}`)},Wt=e=>{const t={},n=(r,s)=>{if(Z(t,r))throw new Error(`Duplicate flags named ${V(r)}`);t[r]=s};for(const r in e){if(!Z(e,r))continue;jt(r);const s=e[r],o=[[],...Me(s),s];n(r,o);const i=Mt(r);if(r!==i&&n(i,o),"alias"in s&&typeof s.alias=="string"){const{alias:u}=s,a=`Flag alias ${V(u)} for flag ${V(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,o)}}return t},Pt=(e,t)=>{const n={};for(const r in e){if(!Z(e,r))continue;const[s,,o,i]=t[r];if(s.length===0&&"default"in i){let{default:u}=i;typeof u=="function"&&(u=u()),n[r]=u}else n[r]=o?s:s.pop()}return n},ne="--",Ht=/[.:=]/,Ut=/^-{1,2}\w/,Yt=e=>{if(!Ut.test(e))return;const t=!e.startsWith(ne);let n=e.slice(t?1:2),r;const s=n.match(Ht);if(s){const{index:o}=s;r=n.slice(o+1),n=n.slice(0,o)}return[n,r,t]},Gt=(e,{onFlag:t,onArgument:n})=>{let r;const s=(o,i)=>{if(typeof r!="function")return!0;r(o,i),r=void 0};for(let o=0;o<e.length;o+=1){const i=e[o];if(i===ne){s();const a=e.slice(o+1);n==null||n(a,[o],!0);break}const u=Yt(i);if(u){if(s(),!t)continue;const[a,l,m]=u;if(m)for(let c=0;c<a.length;c+=1){s();const h=c===a.length-1;r=t(a[c],h?l:void 0,[o,c+1,h])}else r=t(a,l,[o])}else s(i,[o])&&(n==null||n([i],[o]))}s()},zt=(e,t)=>{for(const[n,r,s]of t.reverse()){if(r){const o=e[n];let i=o.slice(0,r);if(s||(i+=o.slice(r+1)),i!=="-"){e[n]=i;continue}}e.splice(n,1)}},Vt=(e,t=process.argv.slice(2),{ignore:n}={})=>{const r=[],s=Wt(e),o={},i=[];return i[ne]=[],Gt(t,{onFlag(u,a,l){const m=Z(s,u);if(!(n!=null&&n(m?Dt:Ot,u,a))){if(m){const[c,h]=s[u],d=It(h,a),p=(g,x)=>{r.push(l),x&&r.push(x),c.push(kt(h,g||""))};return d===void 0?p:p(d)}Z(o,u)||(o[u]=[]),o[u].push(a===void 0?!0:a),r.push(l)}},onArgument(u,a,l){n!=null&&n(_t,t[a[0]])||(i.push(...u),l?(i[ne]=u,t.splice(a[0])):r.push(a))}}),zt(t,r),{flags:Pt(e,s),unknownFlags:o,_:i}};function de(e){return e!==null&&typeof e=="object"}function ge(e,t,n=".",r){if(!de(t))return ge(e,{},n,r);const s=Object.assign({},t);for(const o in e){if(o==="__proto__"||o==="constructor")continue;const i=e[o];i!=null&&(r&&r(s,o,i,n)||(Array.isArray(i)&&Array.isArray(s[o])?s[o]=[...i,...s[o]]:de(i)&&de(s[o])?s[o]=ge(i,s[o],(n?`${n}.`:"")+o.toString(),r):s[o]=i))}return s}function Zt(e){return(...t)=>t.reduce((n,r)=>ge(n,r,"",e),{})}const qt=Zt(),re=e=>Array.isArray(e)?e:[e],Jt=e=>e.replace(/[-_ ](\w)/g,(t,n)=>n.toUpperCase()),Ne=(e,t)=>t.length!==e.length?!1:e.every((n,r)=>n===t[r]),Le=(e,t)=>t.length>e.length?!1:Ne(e.slice(0,t.length),t);class Ie extends Error{constructor(t,n){super(n("core.commandExists",t)),this.commandName=t}}class oe extends Error{constructor(t,n){super(n("core.noSuchCommand",t)),this.commandName=t}}class se extends Error{constructor(t){super(t("core.noCommandGiven"))}}class ke extends Error{constructor(t,n,r){super(r("core.commandNameConflict",t,n)),this.n1=t,this.n2=n}}class Re extends Error{constructor(t){super(t("core.nameNotSet"))}}class je extends Error{constructor(t){super(t("core.descriptionNotSet"))}}class We extends Error{constructor(t){super(t("core.versionNotSet"))}}class Pe extends Error{constructor(t,n){super(n("core.badNameFormat",t)),this.commandName=t}}class fe extends Error{constructor(t){super(t("core.localeMustBeCalledFirst"))}}const He=typeof Deno!="undefined",Kt=typeof process!="undefined"&&!He,Qt=process.versions.electron&&!process.defaultApp;function Ue(e,t,n,r){if(n.alias){const s=re(n.alias);for(const o of s){if(o in t)throw new ke(t[o].name,n.name,r);e.set(typeof o=="symbol"?o:o.split(" "),{...n,__isAlias:!0})}}}function xe(e,t){const n=new Map;e[C]&&(n.set(C,e[C]),Ue(n,e,e[C],t));for(const r of Object.values(e))Ue(n,e,r,t),n.set(r.name.split(" "),r);return n}function Ye(e,t,n){if(t===C)return[e[C],C];const r=re(t),s=xe(e,n);let o,i;return s.forEach((u,a)=>{if(a===C){o=e[C],i=C;return}Le(r,a)&&(!i||i===C||a.length>i.length)&&(o=u,i=a)}),[o,i]}function Ge(e,t,n){if(t===C)return[e[C],C];const r=re(t),s=xe(e,n);let o,i;return s.forEach((u,a)=>{a===C||i===C||Ne(r,a)&&(o=u,i=a)}),[o,i]}function ze(e,t,n=1/0){const r=t===""?[]:Array.isArray(t)?t:t.split(" ");return Object.values(e).filter(s=>{const o=s.name.split(" ");return Le(o,r)&&o.length-r.length<=n})}const Xt=e=>ze(e,"",1);function Ve(e){const t=[];for(const n of e){if(n.startsWith("-"))break;t.push(n)}return t}const Ce=()=>Kt?process.argv.slice(Qt?1:2):He?Deno.args:[];function Ze(e){const t={pre:[],normal:[],post:[]};for(const r of e){const s=typeof r=="object"?r:{fn:r},{enforce:o,fn:i}=s;o==="post"||o==="pre"?t[o].push(i):t.normal.push(i)}const n=[...t.pre,...t.normal,...t.post];return r=>{return s(0);function s(o){const i=n[o];return i(r(),s.bind(null,o+1))}}}const qe=e=>typeof e=="string"&&(e.startsWith(" ")||e.endsWith(" ")),Je=(e,t)=>t?`[${e}]`:`<${e}>`,en="<Root>",H=e=>Array.isArray(e)?e.join(" "):typeof e=="string"?e:en,Ke=()=>process.env.CLERC_LOCALE?process.env.CLERC_LOCALE:Intl.DateTimeFormat().resolvedOptions().locale,{stringify:U}=JSON;function Be(e){const t=[];let n,r;for(const s of e){if(r)throw new Error(`Invalid parameter: Spread parameter ${U(r)} must be last`);const o=s[0],i=s[s.length-1];let u;if(o==="<"&&i===">"&&(u=!0,n))throw new Error(`Invalid parameter: Required parameter ${U(s)} cannot come after optional parameter ${U(n)}`);if(o==="["&&i==="]"&&(u=!1,n=s),u===void 0)throw new Error(`Invalid parameter: ${U(s)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=s.slice(1,-1);const l=a.slice(-3)==="...";l&&(r=s,a=a.slice(0,-3)),t.push({name:a,required:u,spread:l})}return t}function $e(e,t,n){for(let r=0;r<t.length;r+=1){const{name:s,required:o,spread:i}=t[r],u=Jt(s);if(u in e)return new Error(`Invalid parameter: ${U(s)} is used more than once.`);const a=i?n.slice(r):n[r];if(i&&(r=t.length),o&&(!a||i&&a.length===0))return new Error(`Error: Missing required parameter ${U(s)}`);e[u]=a}}const tn={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."},"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"}};var Ee=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},f=(e,t,n)=>(Ee(e,t,"read from private field"),n?n.call(e):t.get(e)),w=(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)},D=(e,t,n,r)=>(Ee(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),_=(e,t,n)=>(Ee(e,t,"access private method"),n),k,R,j,q,J,ie,Y,ae,K,Q,X,W,Se,Qe,we,Xe,ye,et,T,N,be,tt;const C=Symbol("Root"),nt=class{constructor(e,t,n){w(this,Se),w(this,we),w(this,ye),w(this,T),w(this,be),w(this,k,""),w(this,R,""),w(this,j,""),w(this,q,[]),w(this,J,{}),w(this,ie,new At),w(this,Y,new Set),w(this,ae,void 0),w(this,K,!1),w(this,Q,"en"),w(this,X,"en"),w(this,W,{}),this.i18n={add:r=>{D(this,W,qt(f(this,W),r))},t:(r,...s)=>{const o=f(this,W)[f(this,X)]||f(this,W)[f(this,Q)],i=f(this,W)[f(this,Q)];return o[r]?Te(o[r],...s):i[r]?Te(i[r],...s):void 0}},D(this,k,e||f(this,k)),D(this,R,t||f(this,R)),D(this,j,n||f(this,j)),D(this,X,Ke()),_(this,ye,et).call(this)}get _name(){return f(this,k)}get _description(){return f(this,R)}get _version(){return f(this,j)}get _inspectors(){return f(this,q)}get _commands(){return f(this,J)}static create(e,t,n){return new nt(e,t,n)}name(e){return _(this,T,N).call(this),D(this,k,e),this}description(e){return _(this,T,N).call(this),D(this,R,e),this}version(e){return _(this,T,N).call(this),D(this,j,e),this}locale(e){if(f(this,K))throw new fe(this.i18n.t);return D(this,X,e),this}fallbackLocale(e){if(f(this,K))throw new fe(this.i18n.t);return D(this,Q,e),this}command(e,t,n={}){_(this,T,N).call(this);const{t:r}=this.i18n,s=(m=>!(typeof m=="string"||m===C))(e),o=s?e.name:e;if(qe(o))throw new Pe(o,r);const{handler:i=void 0,...u}=s?e:{name:o,description:t,...n},a=[u.name],l=u.alias?re(u.alias):[];u.alias&&a.push(...l);for(const m of a)if(f(this,Y).has(m))throw new Ie(H(m),r);return f(this,J)[o]=u,f(this,Y).add(u.name),l.forEach(m=>f(this,Y).add(m)),s&&i&&this.on(e.name,i),this}on(e,t){return f(this,ie).on(e,t),this}use(e){return _(this,T,N).call(this),e.setup(this)}inspector(e){return _(this,T,N).call(this),f(this,q).push(e),this}parse(e=Ce()){_(this,T,N).call(this);const{argv:t,run:n}=Array.isArray(e)?{argv:e,run:!0}:{argv:Ce(),...e};return D(this,ae,t),_(this,be,tt).call(this),n&&this.runMatchedCommand(),this}runMatchedCommand(){_(this,T,N).call(this);const{t:e}=this.i18n,t=f(this,ae);if(!t)throw new Error("cli.parse() must be called.");const n=Ve(t),r=n.join(" "),s=()=>Ye(f(this,J),n,e),o=[],i=()=>{o.length=0;const[l,m]=s(),c=!!l,h=Vt((l==null?void 0:l.flags)||{},[...t]),{_:d,flags:p,unknownFlags:g}=h;let x=!c||l.name===C?d:d.slice(l.name.split(" ").length),y=(l==null?void 0:l.parameters)||[];const B=y.indexOf("--"),M=y.slice(B+1)||[],b=Object.create(null);if(B>-1&&M.length>0){y=y.slice(0,B);const G=d["--"];x=x.slice(0,-G.length||void 0),o.push($e(b,Be(y),x)),o.push($e(b,Be(M),G))}else o.push($e(b,Be(y),x));const A={...p,...g};return{name:l==null?void 0:l.name,called:Array.isArray(m)?m.join(" "):m,resolved:c,hasRootOrAlias:f(this,Se,Qe),hasRoot:f(this,we,Xe),raw:{...h,parameters:x,mergedFlags:A},parameters:b,flags:p,unknownFlags:g,cli:this}},u={enforce:"post",fn:()=>{const[l]=s(),m=i(),c=o.filter(Boolean);if(c.length>0)throw c[0];if(!l)throw r?new oe(r,e):new se(e);f(this,ie).emit(l.name,m)}},a=[...f(this,q),u];return Ze(a)(i),this}};let nn=nt;k=new WeakMap,R=new WeakMap,j=new WeakMap,q=new WeakMap,J=new WeakMap,ie=new WeakMap,Y=new WeakMap,ae=new WeakMap,K=new WeakMap,Q=new WeakMap,X=new WeakMap,W=new WeakMap,Se=new WeakSet,Qe=function(){return f(this,Y).has(C)},we=new WeakSet,Xe=function(){return Object.prototype.hasOwnProperty.call(this._commands,C)},ye=new WeakSet,et=function(){this.i18n.add(tn)},T=new WeakSet,N=function(){D(this,K,!0)},be=new WeakSet,tt=function(){const{t:e}=this.i18n;if(!f(this,k))throw new Re(e);if(!f(this,R))throw new je(e);if(!f(this,j))throw new We(e)};const P=e=>e,rn=(e,t,n)=>n,on=(e,t)=>t,sn=(e,t)=>({...e,handler:t}),an=e=>`
2
2
  ${e})
3
3
  cmd+="__${e}"
4
- ;;`,Vt=e=>{const{cli:t}=e,{_name:n,_commands:r}=t;return`_${n}() {
4
+ ;;`,un=e=>{const{cli:t}=e,{_name:n,_commands:r}=t;return`_${n}() {
5
5
  local i cur prev opts cmds
6
6
  COMPREPLY=()
7
7
  cur="\${COMP_WORDS[COMP_CWORD]}"
@@ -15,7 +15,7 @@ import oe from"tty";class pt{constructor(){this.listenerMap={},this.wildcardList
15
15
  "$1")
16
16
  cmd="${n}"
17
17
  ;;
18
- ${Object.keys(r).map(Yt).join("")}
18
+ ${Object.keys(r).map(an).join("")}
19
19
  *)
20
20
  ;;
21
21
  esac
@@ -23,9 +23,9 @@ ${Object.keys(r).map(Yt).join("")}
23
23
  }
24
24
 
25
25
  complete -F _${n} -o bashdefault -o default ${n}
26
- `},Ne=e=>e.replace(/([A-Z])/g,(t,n)=>`-${n.toLowerCase()}`),We=e=>e.length<=1?`-${e}`:`--${Ne(e)}`,Pe="(No Description)",Gt=e=>`[CompletionResult]::new('${e.name}', '${e.name}', [CompletionResultType]::ParameterValue, '${e.description}')`,qt=e=>Object.entries(e.flags||{}).map(([t,n])=>{const r=[`[CompletionResult]::new('${We(t)}', '${Ne(t)}', [CompletionResultType]::ParameterName, '${e.flags[t].description||Pe}')`];return n!=null&&n.alias&&r.push(`[CompletionResult]::new('${We(n.alias)}', '${n.alias}', [CompletionResultType]::ParameterName, '${e.flags[t].description||Pe}')`),r.join(`
26
+ `},rt=e=>e.replace(/([A-Z])/g,(t,n)=>`-${n.toLowerCase()}`),ot=e=>e.length<=1?`-${e}`:`--${rt(e)}`,st="(No Description)",ln=e=>`[CompletionResult]::new('${e.name}', '${e.name}', [CompletionResultType]::ParameterValue, '${e.description}')`,cn=e=>Object.entries(e.flags||{}).map(([t,n])=>{const r=[`[CompletionResult]::new('${ot(t)}', '${rt(t)}', [CompletionResultType]::ParameterName, '${e.flags[t].description||st}')`];return n!=null&&n.alias&&r.push(`[CompletionResult]::new('${ot(n.alias)}', '${n.alias}', [CompletionResultType]::ParameterName, '${e.flags[t].description||st}')`),r.join(`
27
27
  `)}).join(`
28
- `),Zt=e=>{const{cli:t}=e,{_name:n,_commands:r}=t;return`using namespace System.Management.Automation
28
+ `),mn=e=>{const{cli:t}=e,{_name:n,_commands:r}=t;return`using namespace System.Management.Automation
29
29
  using namespace System.Management.Automation.Language
30
30
 
31
31
  Register-ArgumentCompleter -Native -CommandName '${n}' -ScriptBlock {
@@ -47,12 +47,12 @@ Register-ArgumentCompleter -Native -CommandName '${n}' -ScriptBlock {
47
47
 
48
48
  $completions = @(switch ($command) {
49
49
  '${n}' {
50
- ${Object.entries(r).map(([o,s])=>Gt(s)).join(`
50
+ ${Object.entries(r).map(([s,o])=>ln(o)).join(`
51
51
  `)}
52
52
  break
53
53
  }
54
- ${Object.entries(r).map(([o,s])=>`'${n};${o.split(" ").join(";")}' {
55
- ${qt(s)}
54
+ ${Object.entries(r).map(([s,o])=>`'${n};${s.split(" ").join(";")}' {
55
+ ${cn(o)}
56
56
  break
57
57
  }`).join(`
58
58
  `)}
@@ -60,18 +60,18 @@ Register-ArgumentCompleter -Native -CommandName '${n}' -ScriptBlock {
60
60
 
61
61
  $completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
62
62
  Sort-Object -Property ListItemText
63
- }`},He={bash:Vt,pwsh:Zt},Jt=(e={})=>D({setup:t=>{const{command:n=!0}=e;return n&&(t=t.command("completions","Print shell completions to stdout",{flags:{shell:{description:"Shell type",type:String,default:""}},parameters:["[shell]"]}).on("completions",r=>{if(!t._name)throw new Error("CLI name is not defined!");const o=String(r.parameters.shell||r.flags.shell);if(!o)throw new Error("Missing shell name");if(o in He)process.stdout.write(He[o](r));else throw new Error(`No such shell: ${o}`)})),t}}),zt=e=>Array.isArray(e)?e:[e],Kt=e=>e.replace(/([A-Z])/g,(t,n)=>`-${n.toLowerCase()}`),Ue=e=>e.length<=1?`-${e}`:`--${Kt(e)}`;var C={exports:{}};let Qt=oe,Xt=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||process.platform==="win32"||Qt.isatty(1)&&process.env.TERM!=="dumb"||"CI"in process.env),B=(e,t,n=e)=>r=>{let o=""+r,s=o.indexOf(t,e.length);return~s?e+Ye(o,t,n,s)+t:e+o+t},Ye=(e,t,n,r)=>{let o=e.substring(0,r)+n,s=e.substring(r+t.length),i=s.indexOf(t);return~i?o+Ye(s,t,n,i):o+s},Ve=(e=Xt)=>({isColorSupported:e,reset:e?t=>`\x1B[0m${t}\x1B[0m`:String,bold:e?B("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"):String,dim:e?B("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"):String,italic:e?B("\x1B[3m","\x1B[23m"):String,underline:e?B("\x1B[4m","\x1B[24m"):String,inverse:e?B("\x1B[7m","\x1B[27m"):String,hidden:e?B("\x1B[8m","\x1B[28m"):String,strikethrough:e?B("\x1B[9m","\x1B[29m"):String,black:e?B("\x1B[30m","\x1B[39m"):String,red:e?B("\x1B[31m","\x1B[39m"):String,green:e?B("\x1B[32m","\x1B[39m"):String,yellow:e?B("\x1B[33m","\x1B[39m"):String,blue:e?B("\x1B[34m","\x1B[39m"):String,magenta:e?B("\x1B[35m","\x1B[39m"):String,cyan:e?B("\x1B[36m","\x1B[39m"):String,white:e?B("\x1B[37m","\x1B[39m"):String,gray:e?B("\x1B[90m","\x1B[39m"):String,bgBlack:e?B("\x1B[40m","\x1B[49m"):String,bgRed:e?B("\x1B[41m","\x1B[49m"):String,bgGreen:e?B("\x1B[42m","\x1B[49m"):String,bgYellow:e?B("\x1B[43m","\x1B[49m"):String,bgBlue:e?B("\x1B[44m","\x1B[49m"):String,bgMagenta:e?B("\x1B[45m","\x1B[49m"):String,bgCyan:e?B("\x1B[46m","\x1B[49m"):String,bgWhite:e?B("\x1B[47m","\x1B[49m"):String});C.exports=Ve(),C.exports.createColors=Ve;var en=Function.prototype.toString,tn=/\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/;function nn(e){if(typeof e!="function")return null;var t="";if(typeof Function.prototype.name=="undefined"&&typeof e.name=="undefined"){var n=en.call(e).match(tn);n&&(t=n[1])}else t=e.name;return t}var Ge=nn,rn=function(e,t){t||(t={});var n=t.hsep===void 0?" ":t.hsep,r=t.align||[],o=t.stringLength||function(a){return String(a).length},s=Ze(e,function(a,l){return Je(l,function(p,g){var c=qe(p);(!a[g]||c>a[g])&&(a[g]=c)}),a},[]),i=ee(e,function(a){return ee(a,function(l,p){var g=String(l);if(r[p]==="."){var c=qe(g),h=s[p]+(/\./.test(g)?1:2)-(o(g)-c);return g+Array(h).join(" ")}else return g})}),u=Ze(i,function(a,l){return Je(l,function(p,g){var c=o(p);(!a[g]||c>a[g])&&(a[g]=c)}),a},[]);return ee(i,function(a){return ee(a,function(l,p){var g=u[p]-o(l)||0,c=Array(Math.max(g+1,1)).join(" ");return r[p]==="r"||r[p]==="."?c+l:r[p]==="c"?Array(Math.ceil(g/2+1)).join(" ")+l+Array(Math.floor(g/2+1)).join(" "):l+c}).join(n).replace(/\s+$/,"")}).join(`
64
- `)};function qe(e){var t=/\.[^.]*$/.exec(e);return t?t.index+1:e.length}function Ze(e,t,n){if(e.reduce)return e.reduce(t,n);for(var r=0,o=arguments.length>=3?n:e[r++];r<e.length;r++)t(o,e[r],r);return o}function Je(e,t){if(e.forEach)return e.forEach(t);for(var n=0;n<e.length;n++)t.call(e,e[n],n)}function ee(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t.call(e,e[r],r));return n}const ge=(...e)=>rn(e),de=(...e)=>ge(...e).toString().split(`
65
- `),on=e=>Array.isArray(e)?`Array<${Ge(e[0])}>`:Ge(e),sn=e=>{const t=[];for(const n of e){if(n.type==="block"||!n.type){const r=" ",o=n.body.map(i=>r+i);o.unshift("");const s=o.join(`
66
- `);t.push(ge([C.exports.bold(`${n.title}:`)],[s]).toString())}else if(n.type==="inline"){const r=n.items.map(s=>[C.exports.bold(`${s.title}:`),s.body]),o=ge(...r);t.push(o.toString())}t.push("")}return t.join(`
67
- `)},fe=C.exports.yellow("-"),an="(No description)",ln="Name",un="Version",cn="Subcommand",mn="Commands",hn="Flags",pn="Description",ze="Usage",gn="Examples",Ke="Notes",Qe=e=>{process.stdout.write(e)},Xe=(e,t,n)=>{const r=[{title:ln,body:C.exports.red(t._name)},{title:un,body:C.exports.yellow(t._version)}];n&&r.push({title:cn,body:C.exports.green(`${t._name} ${j(n.name)}`)}),e.push({type:"inline",items:r}),e.push({title:pn,body:[(n==null?void 0:n.description)||t._description]})},et=(e,t)=>{const n=t.map(([r,o])=>[r,fe,o]);e.push({title:gn,body:de(...n)})},te=(e,t,n,r)=>{const{cli:o}=t,s=[];Xe(s,o),s.push({title:ze,body:[C.exports.magenta(`$ ${o._name} ${Fe("command",t.hasRootOrAlias)} [flags]`)]});const i=[...t.hasRoot?[o._commands[y]]:[],...Object.values(o._commands)].map(u=>{const a=[typeof u.name=="symbol"?"":u.name,...zt(u.alias||[])].sort((l,p)=>l===y?-1:p===y?1:l.length-p.length).map(l=>l===""||typeof l=="symbol"?`${o._name}`:`${o._name} ${l}`).join(", ");return[C.exports.cyan(a),fe,u.description]});return s.push({title:mn,body:de(...i)}),n&&s.push({title:Ke,body:n}),r&&et(s,r),e(s)},tt=(e,t,n)=>{var r;const{cli:o}=t,s=ie(o._commands,n);if(!s)throw new z(j(n));const i=[];Xe(i,o,{...s,name:j(n)});const u=((r=s.parameters)==null?void 0:r.join(" "))||void 0,a=` ${j(n)}`,l=u?` ${u}`:"",p=s.flags?" [flags]":"";return i.push({title:ze,body:[C.exports.magenta(`$ ${o._name}${a}${l}${p}`)]}),s.flags&&i.push({title:hn,body:de(...Object.entries(s.flags).map(([g,c])=>{const h=[Ue(g)];c.alias&&h.push(Ue(c.alias));const m=[C.exports.blue(h.join(", "))];if(m.push(fe,c.description||an),c.type){const d=on(c.type);m.push(C.exports.gray(`(${d})`))}return m}))}),s.notes&&i.push({title:Ke,body:s.notes}),s.examples&&et(i,s.examples),e(i)},dn=({command:e=!0,showHelpWhenNoCommand:t=!0,notes:n,examples:r,banner:o,renderer:s="cliffy"}={})=>D({setup:i=>{const u=s==="cliffy"?sn:()=>"",a=l=>{o&&Qe(`${o}
68
- `),Qe(l)};return e&&(i=i.command("help","Show help",{parameters:["[command...]"],notes:["If no command is specified, show help for the CLI.","If a command is specified, show help for the command.","-h is an alias for --help."],examples:[[`$ ${i._name} help`,"Show help"],[`$ ${i._name} help <command>`,"Show help for a specific command"],[`$ ${i._name} <command> --help`,"Show help for a specific command"]]}).on("help",l=>{l.parameters.command.length?a(tt(u,l,l.parameters.command)):a(te(u,l,n,r))})),i.inspector((l,p)=>{const g=l.raw.mergedFlags.h||l.raw.mergedFlags.help;if(!l.hasRootOrAlias&&!l.raw._.length&&t&&!g){let c=`No command given.
63
+ }`},it={bash:un,pwsh:mn},hn=(e={})=>P({setup:t=>{const{command:n=!0}=e;return n&&(t=t.command("completions","Print shell completions to stdout",{flags:{shell:{description:"Shell type",type:String,default:""}},parameters:["[shell]"]}).on("completions",r=>{if(!t._name)throw new Error("CLI name is not defined!");const s=String(r.parameters.shell||r.flags.shell);if(!s)throw new Error("Missing shell name");if(s in it)process.stdout.write(it[s](r));else throw new Error(`No such shell: ${s}`)})),t}}),pn=e=>Array.isArray(e)?e:[e],dn=e=>e.replace(/([A-Z])/g,(t,n)=>`-${n.toLowerCase()}`),at=e=>e.length<=1?`-${e}`:`--${dn(e)}`;var F={exports:{}};let gn=pe,fn=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||process.platform==="win32"||gn.isatty(1)&&process.env.TERM!=="dumb"||"CI"in process.env),$=(e,t,n=e)=>r=>{let s=""+r,o=s.indexOf(t,e.length);return~o?e+ut(s,t,n,o)+t:e+s+t},ut=(e,t,n,r)=>{let s=e.substring(0,r)+n,o=e.substring(r+t.length),i=o.indexOf(t);return~i?s+ut(o,t,n,i):s+o},lt=(e=fn)=>({isColorSupported:e,reset:e?t=>`\x1B[0m${t}\x1B[0m`:String,bold:e?$("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"):String,dim:e?$("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"):String,italic:e?$("\x1B[3m","\x1B[23m"):String,underline:e?$("\x1B[4m","\x1B[24m"):String,inverse:e?$("\x1B[7m","\x1B[27m"):String,hidden:e?$("\x1B[8m","\x1B[28m"):String,strikethrough:e?$("\x1B[9m","\x1B[29m"):String,black:e?$("\x1B[30m","\x1B[39m"):String,red:e?$("\x1B[31m","\x1B[39m"):String,green:e?$("\x1B[32m","\x1B[39m"):String,yellow:e?$("\x1B[33m","\x1B[39m"):String,blue:e?$("\x1B[34m","\x1B[39m"):String,magenta:e?$("\x1B[35m","\x1B[39m"):String,cyan:e?$("\x1B[36m","\x1B[39m"):String,white:e?$("\x1B[37m","\x1B[39m"):String,gray:e?$("\x1B[90m","\x1B[39m"):String,bgBlack:e?$("\x1B[40m","\x1B[49m"):String,bgRed:e?$("\x1B[41m","\x1B[49m"):String,bgGreen:e?$("\x1B[42m","\x1B[49m"):String,bgYellow:e?$("\x1B[43m","\x1B[49m"):String,bgBlue:e?$("\x1B[44m","\x1B[49m"):String,bgMagenta:e?$("\x1B[45m","\x1B[49m"):String,bgCyan:e?$("\x1B[46m","\x1B[49m"):String,bgWhite:e?$("\x1B[47m","\x1B[49m"):String});F.exports=lt(),F.exports.createColors=lt;var xn=Function.prototype.toString,Cn=/\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/;function Bn(e){if(typeof e!="function")return null;var t="";if(typeof Function.prototype.name=="undefined"&&typeof e.name=="undefined"){var n=xn.call(e).match(Cn);n&&(t=n[1])}else t=e.name;return t}var ct=Bn,$n=function(e,t){t||(t={});var n=t.hsep===void 0?" ":t.hsep,r=t.align||[],s=t.stringLength||function(a){return String(a).length},o=ht(e,function(a,l){return pt(l,function(m,c){var h=mt(m);(!a[c]||h>a[c])&&(a[c]=h)}),a},[]),i=ue(e,function(a){return ue(a,function(l,m){var c=String(l);if(r[m]==="."){var h=mt(c),d=o[m]+(/\./.test(c)?1:2)-(s(c)-h);return c+Array(d).join(" ")}else return c})}),u=ht(i,function(a,l){return pt(l,function(m,c){var h=s(m);(!a[c]||h>a[c])&&(a[c]=h)}),a},[]);return ue(i,function(a){return ue(a,function(l,m){var c=u[m]-s(l)||0,h=Array(Math.max(c+1,1)).join(" ");return r[m]==="r"||r[m]==="."?h+l:r[m]==="c"?Array(Math.ceil(c/2+1)).join(" ")+l+Array(Math.floor(c/2+1)).join(" "):l+h}).join(n).replace(/\s+$/,"")}).join(`
64
+ `)};function mt(e){var t=/\.[^.]*$/.exec(e);return t?t.index+1:e.length}function ht(e,t,n){if(e.reduce)return e.reduce(t,n);for(var r=0,s=arguments.length>=3?n:e[r++];r<e.length;r++)t(s,e[r],r);return s}function pt(e,t){if(e.forEach)return e.forEach(t);for(var n=0;n<e.length;n++)t.call(e,e[n],n)}function ue(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t.call(e,e[r],r));return n}const Fe=(...e)=>$n(e),ve=(...e)=>Fe(...e).toString().split(`
65
+ `),En=e=>Array.isArray(e)?`Array<${ct(e[0])}>`:ct(e),Sn=e=>{const t=[];for(const n of e){if(n.type==="block"||!n.type){const r=" ",s=n.body.map(i=>r+i);s.unshift("");const o=s.join(`
66
+ `);t.push(Fe([F.exports.bold(`${n.title}:`)],[o]).toString())}else if(n.type==="inline"){const r=n.items.map(o=>[F.exports.bold(`${o.title}:`),o.body]),s=Fe(...r);t.push(s.toString())}t.push("")}return t.join(`
67
+ `)},wn={en:{"help.name":"Name","help.version":"Version","help.subcommand":"Subcommand","help.commands":"Commands","help.flags":"Flags","help.description":"Description","help.usage":"Usage","help.examples":"Examples","help.notes":"Notes","help.noDescription":"(No description)","help.notes.1":"If no command is specified, show help for the CLI.","help.notes.2":"If a command is specified, show help for the command.","help.notes.3":"-h is an alias for --help.","help.examples.1":"Show help","help.examples.2":"Show help for a specific command","help.commandDescription":"Show help"},"zh-CN":{"help.name":"\u540D\u79F0","help.version":"\u7248\u672C","help.subcommand":"\u5B50\u547D\u4EE4","help.commands":"\u547D\u4EE4","help.flags":"\u6807\u5FD7","help.description":"\u63CF\u8FF0","help.usage":"\u4F7F\u7528","help.examples":"\u793A\u4F8B","help.notes":"\u5907\u6CE8","help.noDescription":"(\u65E0\u63CF\u8FF0)","help.notes.1":"\u5982\u679C\u6CA1\u6709\u6307\u5B9A\u5C55\u793A\u54EA\u4E2A\u547D\u4EE4\u7684\u5E2E\u52A9\u4FE1\u606F\uFF0C\u9ED8\u8BA4\u5C55\u793ACLI\u7684\u3002","help.notes.2":"\u5982\u679C\u6307\u5B9A\u4E86\u5219\u5C55\u793A\u8BE5\u547D\u4EE4\u5E2E\u52A9\u4FE1\u606F\u3002","help.notes.3":"-h \u662F --help \u7684\u4E00\u4E2A\u522B\u540D\u3002","help.examples.1":"\u5C55\u793A CLI \u7684\u5E2E\u52A9\u4FE1\u606F","help.examples.2":"\u5C55\u793A\u6307\u5B9A\u547D\u4EE4\u7684\u5E2E\u52A9\u4FE1\u606F","help.commandDescription":"\u5C55\u793A\u5E2E\u52A9\u4FE1\u606F"}},Ae=F.exports.yellow("-"),dt=e=>{process.stdout.write(e)},De=(e,t,n)=>{const{t:r}=t.i18n,s=[{title:r("help.name"),body:F.exports.red(t._name)},{title:r("help.version"),body:F.exports.yellow(t._version)}];n&&s.push({title:r("help.subcommand"),body:F.exports.green(`${t._name} ${H(n.name)}`)}),e.push({type:"inline",items:s}),e.push({title:r("help.description"),body:[(n==null?void 0:n.description)||t._description]})},gt=(e,t,n)=>{const r=t.map(([s,o])=>[s,Ae,o]);e.push({title:n("help.examples"),body:ve(...r)})},le=(e,t,n,r)=>{const{cli:s}=t,{t:o}=s.i18n,i=[];De(i,s),i.push({title:o("help.usage"),body:[F.exports.magenta(`$ ${s._name} ${Je("command",t.hasRootOrAlias)} [flags]`)]});const u=[...t.hasRoot?[s._commands[C]]:[],...Object.values(s._commands)].map(a=>{const l=[typeof a.name=="symbol"?"":a.name,...pn(a.alias||[])].sort((m,c)=>m===C?-1:c===C?1:m.length-c.length).map(m=>m===""||typeof m=="symbol"?`${s._name}`:`${s._name} ${m}`).join(", ");return[F.exports.cyan(l),Ae,a.description]});return i.push({title:o("help.commands"),body:ve(...u)}),n&&i.push({title:o("help.notes"),body:n}),r&&gt(i,r,o),e(i)},Oe=(e,t,n)=>{var r;const{cli:s}=t,{t:o}=s.i18n,[i]=Ge(s._commands,n,o);if(!i)throw new oe(H(n),o);const u=[];n===C?De(u,s):De(u,s,{...i,name:H(n)});const a=((r=i.parameters)==null?void 0:r.join(" "))||void 0,l=n===C?"":` ${H(n)}`,m=a?` ${a}`:"",c=i.flags?" [flags]":"";return u.push({title:o("help.usage"),body:[F.exports.magenta(`$ ${s._name}${l}${m}${c}`)]}),i.flags&&u.push({title:o("help.flags"),body:ve(...Object.entries(i.flags).map(([h,d])=>{const p=[at(h)];d.alias&&p.push(at(d.alias));const g=[F.exports.blue(p.join(", "))];if(g.push(Ae,d.description||o("help.noDescription")),d.type){const x=En(d.type);g.push(F.exports.gray(`(${x})`))}return g}))}),i.notes&&u.push({title:o("help.notes"),body:i.notes}),i.examples&&gt(u,i.examples,o),e(u)},yn=({command:e=!0,showHelpWhenNoCommand:t=!0,notes:n,examples:r,banner:s,renderer:o="cliffy"}={})=>P({setup:i=>{const{add:u,t:a}=i.i18n;u(wn);const l=o==="cliffy"?Sn:()=>"",m=c=>{s&&dt(`${s}
68
+ `),dt(c)};return e&&(i=i.command("help",a("help.commandDescription"),{parameters:["[command...]"],notes:[a("help.notes.1"),a("help.notes.2"),a("help.notes.3")],examples:[[`$ ${i._name} help`,a("help.examples.1")],[`$ ${i._name} help <command>`,a("help.examples.2")],[`$ ${i._name} <command> --help`,a("help.examples.2")]]}).on("help",c=>{c.parameters.command.length?m(Oe(l,c,c.parameters.command)):m(le(l,c,n,r))})),i.inspector((c,h)=>{const d=c.raw.mergedFlags.h||c.raw.mergedFlags.help;if(!c.hasRootOrAlias&&!c.raw._.length&&t&&!d){let p=`${a("core.noCommandGiven")}
69
69
 
70
- `;c+=te(u,l,n,r),c+=`
71
- `,a(c),process.exit(1)}else g?l.raw._.length?l.called!==y&&l.name===y?a(te(u,l,n,r)):a(tt(u,l,l.raw._)):a(te(u,l,n,r)):p()}),i}}),T=new Uint32Array(65536),fn=(e,t)=>{const n=e.length,r=t.length,o=1<<n-1;let s=-1,i=0,u=n,a=n;for(;a--;)T[e.charCodeAt(a)]|=1<<a;for(a=0;a<r;a++){let l=T[t.charCodeAt(a)];const p=l|i;l|=(l&s)+s^s,i|=~(l|s),s&=l,i&o&&u++,s&o&&u--,i=i<<1|1,s=s<<1|~(p|i),i&=p}for(a=n;a--;)T[e.charCodeAt(a)]=0;return u},xn=(e,t)=>{const n=t.length,r=e.length,o=[],s=[],i=Math.ceil(n/32),u=Math.ceil(r/32);for(let m=0;m<i;m++)s[m]=-1,o[m]=0;let a=0;for(;a<u-1;a++){let m=0,d=-1;const x=a*32,O=Math.min(32,r)+x;for(let f=x;f<O;f++)T[e.charCodeAt(f)]|=1<<f;for(let f=0;f<n;f++){const I=T[t.charCodeAt(f)],E=s[f/32|0]>>>f&1,_=o[f/32|0]>>>f&1,xe=I|m,$e=((I|_)&d)+d^d|I|_;let H=m|~($e|d),Z=d&$e;H>>>31^E&&(s[f/32|0]^=1<<f),Z>>>31^_&&(o[f/32|0]^=1<<f),H=H<<1|E,Z=Z<<1|_,d=Z|~(xe|H),m=H&xe}for(let f=x;f<O;f++)T[e.charCodeAt(f)]=0}let l=0,p=-1;const g=a*32,c=Math.min(32,r-g)+g;for(let m=g;m<c;m++)T[e.charCodeAt(m)]|=1<<m;let h=r;for(let m=0;m<n;m++){const d=T[t.charCodeAt(m)],x=s[m/32|0]>>>m&1,O=o[m/32|0]>>>m&1,f=d|l,I=((d|O)&p)+p^p|d|O;let E=l|~(I|p),_=p&I;h+=E>>>r-1&1,h-=_>>>r-1&1,E>>>31^x&&(s[m/32|0]^=1<<m),_>>>31^O&&(o[m/32|0]^=1<<m),E=E<<1|x,_=_<<1|O,p=_|~(f|E),l=E&f}for(let m=g;m<c;m++)T[e.charCodeAt(m)]=0;return h},nt=(e,t)=>{if(e.length<t.length){const n=t;t=e,e=n}return t.length===0?e.length:e.length<=32?fn(e,t):xn(e,t)};var ne=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},$n=1/0,Bn="[object Symbol]",Sn=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,wn="\\u0300-\\u036f\\ufe20-\\ufe23",yn="\\u20d0-\\u20f0",Cn="["+wn+yn+"]",bn=RegExp(Cn,"g"),En={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"ss"},vn=typeof ne=="object"&&ne&&ne.Object===Object&&ne,An=typeof self=="object"&&self&&self.Object===Object&&self,On=vn||An||Function("return this")();function _n(e){return function(t){return e==null?void 0:e[t]}}var Tn=_n(En),Mn=Object.prototype,In=Mn.toString,rt=On.Symbol,ot=rt?rt.prototype:void 0,st=ot?ot.toString:void 0;function kn(e){if(typeof e=="string")return e;if(Ln(e))return st?st.call(e):"";var t=e+"";return t=="0"&&1/e==-$n?"-0":t}function Fn(e){return!!e&&typeof e=="object"}function Ln(e){return typeof e=="symbol"||Fn(e)&&In.call(e)==Bn}function Rn(e){return e==null?"":kn(e)}function Dn(e){return e=Rn(e),e&&e.replace(Sn,Tn).replace(bn,"")}var jn=Dn;let b,A;(function(e){e.ALL_CLOSEST_MATCHES="all-closest-matches",e.ALL_MATCHES="all-matches",e.ALL_SORTED_MATCHES="all-sorted-matches",e.FIRST_CLOSEST_MATCH="first-closest-match",e.FIRST_MATCH="first-match"})(b||(b={})),function(e){e.EDIT_DISTANCE="edit-distance",e.SIMILARITY="similarity"}(A||(A={}));const it=new Error("unknown returnType"),re=new Error("unknown thresholdType"),at=(e,t)=>{let n=e;return t.trimSpaces&&(n=n.trim().replace(/\s+/g," ")),t.deburr&&(n=jn(n)),t.caseSensitive||(n=n.toLowerCase()),n},lt=(e,t)=>{const{matchPath:n}=t,r=((o,s)=>{const i=s.length>0?s.reduce((u,a)=>u==null?void 0:u[a],o):o;return typeof i!="string"?"":i})(e,n);return at(r,t)};function Nn(e,t,n){const r=(c=>{const h={caseSensitive:!1,deburr:!0,matchPath:[],returnType:b.FIRST_CLOSEST_MATCH,thresholdType:A.SIMILARITY,trimSpaces:!0,...c};switch(h.thresholdType){case A.EDIT_DISTANCE:return{threshold:20,...h};case A.SIMILARITY:return{threshold:.4,...h};default:throw re}})(n),{returnType:o,threshold:s,thresholdType:i}=r,u=at(e,r);let a,l;switch(i){case A.EDIT_DISTANCE:a=c=>c<=s,l=c=>nt(u,lt(c,r));break;case A.SIMILARITY:a=c=>c>=s,l=c=>((h,m)=>{if(!h||!m)return 0;if(h===m)return 1;const d=nt(h,m),x=Math.max(h.length,m.length);return(x-d)/x})(u,lt(c,r));break;default:throw re}const p=[],g=t.length;switch(o){case b.ALL_CLOSEST_MATCHES:case b.FIRST_CLOSEST_MATCH:{const c=[];let h;switch(i){case A.EDIT_DISTANCE:h=1/0;for(let d=0;d<g;d+=1){const x=l(t[d]);h>x&&(h=x),c.push(x)}break;case A.SIMILARITY:h=0;for(let d=0;d<g;d+=1){const x=l(t[d]);h<x&&(h=x),c.push(x)}break;default:throw re}const m=c.length;for(let d=0;d<m;d+=1){const x=c[d];a(x)&&x===h&&p.push(d)}break}case b.ALL_MATCHES:for(let c=0;c<g;c+=1)a(l(t[c]))&&p.push(c);break;case b.ALL_SORTED_MATCHES:{const c=[];for(let h=0;h<g;h+=1){const m=l(t[h]);a(m)&&c.push({score:m,index:h})}switch(i){case A.EDIT_DISTANCE:c.sort((h,m)=>h.score-m.score);break;case A.SIMILARITY:c.sort((h,m)=>m.score-h.score);break;default:throw re}for(const h of c)p.push(h.index);break}case b.FIRST_MATCH:for(let c=0;c<g;c+=1)if(a(l(t[c]))){p.push(c);break}break;default:throw it}return((c,h,m)=>{switch(m){case b.ALL_CLOSEST_MATCHES:case b.ALL_MATCHES:case b.ALL_SORTED_MATCHES:return h.map(d=>c[d]);case b.FIRST_CLOSEST_MATCH:case b.FIRST_MATCH:return h.length?c[h[0]]:null;default:throw it}})(t,p,o)}var P={exports:{}};let Wn=oe,Pn=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||process.platform==="win32"||Wn.isatty(1)&&process.env.TERM!=="dumb"||"CI"in process.env),S=(e,t,n=e)=>r=>{let o=""+r,s=o.indexOf(t,e.length);return~s?e+ut(o,t,n,s)+t:e+o+t},ut=(e,t,n,r)=>{let o=e.substring(0,r)+n,s=e.substring(r+t.length),i=s.indexOf(t);return~i?o+ut(s,t,n,i):o+s},ct=(e=Pn)=>({isColorSupported:e,reset:e?t=>`\x1B[0m${t}\x1B[0m`:String,bold:e?S("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"):String,dim:e?S("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"):String,italic:e?S("\x1B[3m","\x1B[23m"):String,underline:e?S("\x1B[4m","\x1B[24m"):String,inverse:e?S("\x1B[7m","\x1B[27m"):String,hidden:e?S("\x1B[8m","\x1B[28m"):String,strikethrough:e?S("\x1B[9m","\x1B[29m"):String,black:e?S("\x1B[30m","\x1B[39m"):String,red:e?S("\x1B[31m","\x1B[39m"):String,green:e?S("\x1B[32m","\x1B[39m"):String,yellow:e?S("\x1B[33m","\x1B[39m"):String,blue:e?S("\x1B[34m","\x1B[39m"):String,magenta:e?S("\x1B[35m","\x1B[39m"):String,cyan:e?S("\x1B[36m","\x1B[39m"):String,white:e?S("\x1B[37m","\x1B[39m"):String,gray:e?S("\x1B[90m","\x1B[39m"):String,bgBlack:e?S("\x1B[40m","\x1B[49m"):String,bgRed:e?S("\x1B[41m","\x1B[49m"):String,bgGreen:e?S("\x1B[42m","\x1B[49m"):String,bgYellow:e?S("\x1B[43m","\x1B[49m"):String,bgBlue:e?S("\x1B[44m","\x1B[49m"):String,bgMagenta:e?S("\x1B[45m","\x1B[49m"):String,bgCyan:e?S("\x1B[46m","\x1B[49m"):String,bgWhite:e?S("\x1B[47m","\x1B[49m"):String});P.exports=ct(),P.exports.createColors=ct;const Hn=e=>e.length<=1?e[0]:`${e.slice(0,-1).map(P.exports.bold).join(", ")} and ${P.exports.bold(e[e.length-1])}`,Un=()=>D({setup:e=>e.inspector({enforce:"pre",fn:(t,n)=>{const r=Object.keys(e._commands),o=!!r.length;try{n()}catch(s){if(!(s instanceof z||s instanceof K))throw s;if(t.raw._.length===0||s instanceof K){console.error("No command given."),o&&console.error(`Possible commands: ${Hn(r)}.`);return}const i=s.commandName,u=Nn(i,r);console.error(`Command "${P.exports.strikethrough(i)}" not found.`),o&&u?console.error(`Did you mean "${P.exports.bold(u)}"?`):o||console.error("NOTE: You haven't register any command yet."),process.stderr.write(`
72
- `),process.exit(2)}}})}),Yn=e=>e.length<=1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`,Vn=()=>D({setup:e=>e.inspector((t,n)=>{const r=Object.keys(t.unknownFlags);if(!t.resolved||r.length===0)n();else throw new Error(`Unexpected flag${r.length>1?"s":""}: ${Yn(r)}`)})}),Gn=e=>e.length===0?"":e.startsWith("v")?e:`v${e}`,qn=({alias:e=["V"],command:t=!0}={})=>D({setup:n=>{const r=Gn(n._version);return t&&(n=n.command("version","Show version",{notes:['The version string begins with a "v".']}).on("version",()=>{process.stdout.write(r)})),n.inspector({enforce:"pre",fn:(o,s)=>{let i=!1;const u=["version",...e];for(const a of Object.keys(o.raw.mergedFlags))if(u.includes(a)){i=!0;break}i?process.stdout.write(r):s()}})}});var M={exports:{}};let Zn=oe,Jn=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||process.platform==="win32"||Zn.isatty(1)&&process.env.TERM!=="dumb"||"CI"in process.env),w=(e,t,n=e)=>r=>{let o=""+r,s=o.indexOf(t,e.length);return~s?e+mt(o,t,n,s)+t:e+o+t},mt=(e,t,n,r)=>{let o=e.substring(0,r)+n,s=e.substring(r+t.length),i=s.indexOf(t);return~i?o+mt(s,t,n,i):o+s},ht=(e=Jn)=>({isColorSupported:e,reset:e?t=>`\x1B[0m${t}\x1B[0m`:String,bold:e?w("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"):String,dim:e?w("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"):String,italic:e?w("\x1B[3m","\x1B[23m"):String,underline:e?w("\x1B[4m","\x1B[24m"):String,inverse:e?w("\x1B[7m","\x1B[27m"):String,hidden:e?w("\x1B[8m","\x1B[28m"):String,strikethrough:e?w("\x1B[9m","\x1B[29m"):String,black:e?w("\x1B[30m","\x1B[39m"):String,red:e?w("\x1B[31m","\x1B[39m"):String,green:e?w("\x1B[32m","\x1B[39m"):String,yellow:e?w("\x1B[33m","\x1B[39m"):String,blue:e?w("\x1B[34m","\x1B[39m"):String,magenta:e?w("\x1B[35m","\x1B[39m"):String,cyan:e?w("\x1B[36m","\x1B[39m"):String,white:e?w("\x1B[37m","\x1B[39m"):String,gray:e?w("\x1B[90m","\x1B[39m"):String,bgBlack:e?w("\x1B[40m","\x1B[49m"):String,bgRed:e?w("\x1B[41m","\x1B[49m"):String,bgGreen:e?w("\x1B[42m","\x1B[49m"):String,bgYellow:e?w("\x1B[43m","\x1B[49m"):String,bgBlue:e?w("\x1B[44m","\x1B[49m"):String,bgMagenta:e?w("\x1B[45m","\x1B[49m"):String,bgCyan:e?w("\x1B[46m","\x1B[49m"):String,bgWhite:e?w("\x1B[47m","\x1B[49m"):String});M.exports=ht(),M.exports.createColors=ht;function zn(e){return e.split(`
73
- `).splice(1).map(t=>t.trim().replace("file://",""))}function Kn(e){return`
74
- ${zn(e).map(t=>` ${t.replace(/^at ([\s\S]+) \((.+)\)/,(n,r,o)=>M.exports.gray(`at ${r} (${M.exports.cyan(o)})`))}`).join(`
75
- `)}`}function Qn(e){return e.map(t=>typeof(t==null?void 0:t.stack)=="string"?`${t.message}
76
- ${Kn(t.stack)}`:t)}function Xn(e,t){const n=e.toUpperCase(),r=M.exports[t];return M.exports.bold(M.exports.inverse(r(` ${n} `)))}function q(e,t,n){const r=M.exports[t],o=n!=null&&n.textColor?M.exports[n.textColor]:r,s=(n==null?void 0:n.target)||console.log;return(...i)=>{const u=Qn(i);s(`${Xn(e,t)} ${o(u.join(" "))}
77
- `)}}q("log","gray"),q("info","blue",{target:console.info}),q("warn","yellow",{target:console.warn}),q("success","green");const er=q("error","red",{target:console.error}),tr=()=>D({setup:e=>e.inspector({enforce:"pre",fn:(t,n)=>{try{n()}catch(r){er(r.message),process.exit(1)}}})});export{Wt as Clerc,we as CommandExistsError,ye as CommandNameConflictError,be as DescriptionNotSetError,ve as InvalidCommandNameError,Ce as NameNotSetError,K as NoCommandGivenError,z as NoSuchCommandError,y as Root,Ee as VersionNotSetError,Jt as completionsPlugin,Ie as compose,Ut as defineCommand,Pt as defineHandler,Ht as defineInspector,D as definePlugin,j as formatCommandName,tr as friendlyErrorPlugin,dn as helpPlugin,ke as isInvalidName,Un as notFoundPlugin,ae as resolveArgv,ie as resolveCommand,_e as resolveFlattenCommands,Me as resolveParametersBeforeFlag,Dt as resolveRootCommands,Te as resolveSubcommandsByParent,Vn as strictFlagsPlugin,qn as versionPlugin,Fe as withBrackets};
70
+ `;p+=le(l,c,n,r),p+=`
71
+ `,m(p),process.exit(1)}else d?c.raw._.length?c.called!==C&&c.name===C?m(le(l,c,n,r)):m(Oe(l,c,c.raw._)):c.hasRootOrAlias?m(Oe(l,c,C)):m(le(l,c,n,r)):h()}),i}}),bn={en:{"utils.and":"%s and %s"},"zh-CN":{"utils.and":"%s \u548C %s"}},Fn=(e,{add:t,t:n})=>(t(bn),e.length<=1?e[0]:n("utils.and",e.slice(0,-1).join(", "),e[e.length-1])),L=new Uint32Array(65536),vn=(e,t)=>{const n=e.length,r=t.length,s=1<<n-1;let o=-1,i=0,u=n,a=n;for(;a--;)L[e.charCodeAt(a)]|=1<<a;for(a=0;a<r;a++){let l=L[t.charCodeAt(a)];const m=l|i;l|=(l&o)+o^o,i|=~(l|o),o&=l,i&s&&u++,o&s&&u--,i=i<<1|1,o=o<<1|~(m|i),i&=m}for(a=n;a--;)L[e.charCodeAt(a)]=0;return u},An=(e,t)=>{const n=t.length,r=e.length,s=[],o=[],i=Math.ceil(n/32),u=Math.ceil(r/32);for(let p=0;p<i;p++)o[p]=-1,s[p]=0;let a=0;for(;a<u-1;a++){let p=0,g=-1;const x=a*32,y=Math.min(32,r)+x;for(let B=x;B<y;B++)L[e.charCodeAt(B)]|=1<<B;for(let B=0;B<n;B++){const M=L[t.charCodeAt(B)],b=o[B/32|0]>>>B&1,A=s[B/32|0]>>>B&1,G=M|p,_e=((M|A)&g)+g^g|M|A;let z=p|~(_e|g),te=g&_e;z>>>31^b&&(o[B/32|0]^=1<<B),te>>>31^A&&(s[B/32|0]^=1<<B),z=z<<1|b,te=te<<1|A,g=te|~(G|z),p=z&G}for(let B=x;B<y;B++)L[e.charCodeAt(B)]=0}let l=0,m=-1;const c=a*32,h=Math.min(32,r-c)+c;for(let p=c;p<h;p++)L[e.charCodeAt(p)]|=1<<p;let d=r;for(let p=0;p<n;p++){const g=L[t.charCodeAt(p)],x=o[p/32|0]>>>p&1,y=s[p/32|0]>>>p&1,B=g|l,M=((g|y)&m)+m^m|g|y;let b=l|~(M|m),A=m&M;d+=b>>>r-1&1,d-=A>>>r-1&1,b>>>31^x&&(o[p/32|0]^=1<<p),A>>>31^y&&(s[p/32|0]^=1<<p),b=b<<1|x,A=A<<1|y,m=A|~(B|b),l=b&B}for(let p=c;p<h;p++)L[e.charCodeAt(p)]=0;return d},ft=(e,t)=>{if(e.length<t.length){const n=t;t=e,e=n}return t.length===0?e.length:e.length<=32?vn(e,t):An(e,t)};var ce=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},Dn=1/0,On="[object Symbol]",_n=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Tn="\\u0300-\\u036f\\ufe20-\\ufe23",Mn="\\u20d0-\\u20f0",Nn="["+Tn+Mn+"]",Ln=RegExp(Nn,"g"),In={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"ss"},kn=typeof ce=="object"&&ce&&ce.Object===Object&&ce,Rn=typeof self=="object"&&self&&self.Object===Object&&self,jn=kn||Rn||Function("return this")();function Wn(e){return function(t){return e==null?void 0:e[t]}}var Pn=Wn(In),Hn=Object.prototype,Un=Hn.toString,xt=jn.Symbol,Ct=xt?xt.prototype:void 0,Bt=Ct?Ct.toString:void 0;function Yn(e){if(typeof e=="string")return e;if(zn(e))return Bt?Bt.call(e):"";var t=e+"";return t=="0"&&1/e==-Dn?"-0":t}function Gn(e){return!!e&&typeof e=="object"}function zn(e){return typeof e=="symbol"||Gn(e)&&Un.call(e)==On}function Vn(e){return e==null?"":Yn(e)}function Zn(e){return e=Vn(e),e&&e.replace(_n,Pn).replace(Ln,"")}var qn=Zn;let v,O;(function(e){e.ALL_CLOSEST_MATCHES="all-closest-matches",e.ALL_MATCHES="all-matches",e.ALL_SORTED_MATCHES="all-sorted-matches",e.FIRST_CLOSEST_MATCH="first-closest-match",e.FIRST_MATCH="first-match"})(v||(v={})),function(e){e.EDIT_DISTANCE="edit-distance",e.SIMILARITY="similarity"}(O||(O={}));const $t=new Error("unknown returnType"),me=new Error("unknown thresholdType"),Et=(e,t)=>{let n=e;return t.trimSpaces&&(n=n.trim().replace(/\s+/g," ")),t.deburr&&(n=qn(n)),t.caseSensitive||(n=n.toLowerCase()),n},St=(e,t)=>{const{matchPath:n}=t,r=((s,o)=>{const i=o.length>0?o.reduce((u,a)=>u==null?void 0:u[a],s):s;return typeof i!="string"?"":i})(e,n);return Et(r,t)};function Jn(e,t,n){const r=(h=>{const d={caseSensitive:!1,deburr:!0,matchPath:[],returnType:v.FIRST_CLOSEST_MATCH,thresholdType:O.SIMILARITY,trimSpaces:!0,...h};switch(d.thresholdType){case O.EDIT_DISTANCE:return{threshold:20,...d};case O.SIMILARITY:return{threshold:.4,...d};default:throw me}})(n),{returnType:s,threshold:o,thresholdType:i}=r,u=Et(e,r);let a,l;switch(i){case O.EDIT_DISTANCE:a=h=>h<=o,l=h=>ft(u,St(h,r));break;case O.SIMILARITY:a=h=>h>=o,l=h=>((d,p)=>{if(!d||!p)return 0;if(d===p)return 1;const g=ft(d,p),x=Math.max(d.length,p.length);return(x-g)/x})(u,St(h,r));break;default:throw me}const m=[],c=t.length;switch(s){case v.ALL_CLOSEST_MATCHES:case v.FIRST_CLOSEST_MATCH:{const h=[];let d;switch(i){case O.EDIT_DISTANCE:d=1/0;for(let g=0;g<c;g+=1){const x=l(t[g]);d>x&&(d=x),h.push(x)}break;case O.SIMILARITY:d=0;for(let g=0;g<c;g+=1){const x=l(t[g]);d<x&&(d=x),h.push(x)}break;default:throw me}const p=h.length;for(let g=0;g<p;g+=1){const x=h[g];a(x)&&x===d&&m.push(g)}break}case v.ALL_MATCHES:for(let h=0;h<c;h+=1)a(l(t[h]))&&m.push(h);break;case v.ALL_SORTED_MATCHES:{const h=[];for(let d=0;d<c;d+=1){const p=l(t[d]);a(p)&&h.push({score:p,index:d})}switch(i){case O.EDIT_DISTANCE:h.sort((d,p)=>d.score-p.score);break;case O.SIMILARITY:h.sort((d,p)=>p.score-d.score);break;default:throw me}for(const d of h)m.push(d.index);break}case v.FIRST_MATCH:for(let h=0;h<c;h+=1)if(a(l(t[h]))){m.push(h);break}break;default:throw $t}return((h,d,p)=>{switch(p){case v.ALL_CLOSEST_MATCHES:case v.ALL_MATCHES:case v.ALL_SORTED_MATCHES:return d.map(g=>h[g]);case v.FIRST_CLOSEST_MATCH:case v.FIRST_MATCH:return d.length?h[d[0]]:null;default:throw $t}})(t,m,s)}var he={exports:{}};let Kn=pe,Qn=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||process.platform==="win32"||Kn.isatty(1)&&process.env.TERM!=="dumb"||"CI"in process.env),E=(e,t,n=e)=>r=>{let s=""+r,o=s.indexOf(t,e.length);return~o?e+wt(s,t,n,o)+t:e+s+t},wt=(e,t,n,r)=>{let s=e.substring(0,r)+n,o=e.substring(r+t.length),i=o.indexOf(t);return~i?s+wt(o,t,n,i):s+o},yt=(e=Qn)=>({isColorSupported:e,reset:e?t=>`\x1B[0m${t}\x1B[0m`:String,bold:e?E("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"):String,dim:e?E("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"):String,italic:e?E("\x1B[3m","\x1B[23m"):String,underline:e?E("\x1B[4m","\x1B[24m"):String,inverse:e?E("\x1B[7m","\x1B[27m"):String,hidden:e?E("\x1B[8m","\x1B[28m"):String,strikethrough:e?E("\x1B[9m","\x1B[29m"):String,black:e?E("\x1B[30m","\x1B[39m"):String,red:e?E("\x1B[31m","\x1B[39m"):String,green:e?E("\x1B[32m","\x1B[39m"):String,yellow:e?E("\x1B[33m","\x1B[39m"):String,blue:e?E("\x1B[34m","\x1B[39m"):String,magenta:e?E("\x1B[35m","\x1B[39m"):String,cyan:e?E("\x1B[36m","\x1B[39m"):String,white:e?E("\x1B[37m","\x1B[39m"):String,gray:e?E("\x1B[90m","\x1B[39m"):String,bgBlack:e?E("\x1B[40m","\x1B[49m"):String,bgRed:e?E("\x1B[41m","\x1B[49m"):String,bgGreen:e?E("\x1B[42m","\x1B[49m"):String,bgYellow:e?E("\x1B[43m","\x1B[49m"):String,bgBlue:e?E("\x1B[44m","\x1B[49m"):String,bgMagenta:e?E("\x1B[45m","\x1B[49m"):String,bgCyan:e?E("\x1B[46m","\x1B[49m"):String,bgWhite:e?E("\x1B[47m","\x1B[49m"):String});he.exports=yt(),he.exports.createColors=yt;const Xn={en:{"notFound.possibleCommands":"Possible commands: %s.","notFound.commandNotFound":'Command "%s" not found.',"notFound.didyoumean":'Did you mean "%s"?',"notFound.commandNotRegisteredNote":"NOTE: You haven't register any command yet."},"zh-CN":{"notFound.possibleCommands":"\u53EF\u80FD\u7684\u547D\u4EE4: %s\u3002","notFound.commandNotFound":'\u672A\u627E\u5230\u547D\u4EE4 "%s"\u3002',"notFound.didyoumean":'\u4F60\u662F\u4E0D\u662F\u6307 "%s"\uFF1F',"notFound.commandNotRegisteredNote":"\u63D0\u793A: \u4F60\u8FD8\u6CA1\u6709\u6CE8\u518C\u4EFB\u4F55\u547D\u4EE4\u3002"}},er=()=>P({setup:e=>{const{t,add:n}=e.i18n;return n(Xn),e.inspector({enforce:"pre",fn:(r,s)=>{const o=Object.keys(e._commands),i=!!o.length;try{s()}catch(u){if(!(u instanceof oe||u instanceof se))throw u;if(r.raw._.length===0||u instanceof se){console.error(t("core.noCommandGiven")),i&&console.error(t("notFound.possibleCommands",Fn(o,e.i18n)));return}const a=u.commandName,l=Jn(a,o);console.error(t("notFound.commandNotFound",he.exports.strikethrough(a))),i&&l?console.error(t("notFound.didyoumean",he.exports.bold(l))):i||console.error(t("notFound.commandNotRegisteredNote")),process.stderr.write(`
72
+ `),process.exit(2)}}})}}),tr={en:{"utils.and":"%s and %s"},"zh-CN":{"utils.and":"%s \u548C %s"}},bt=(e,{add:t,t:n})=>(t(tr),e.length<=1?e[0]:n("utils.and",e.slice(0,-1).join(", "),e[e.length-1])),nr={en:{"strictFlags.unexpectedSingle":"Unexpected flag: %s.","strictFlags.unexpectedMore":"Unexpected flags: %s.","strictFlags.and":"%s and %s"},"zh-CN":{"strictFlags.unexpectedSingle":"\u9884\u671F\u4E4B\u5916\u7684\u6807\u5FD7: %s\u3002","strictFlags.unexpectedMore":"\u9884\u671F\u4E4B\u5916\u7684\u6807\u5FD7: %s\u3002","strictFlags.and":"%s \u548C %s"}},rr=()=>P({setup:e=>{const{add:t,t:n}=e.i18n;return t(nr),e.inspector((r,s)=>{const o=Object.keys(r.unknownFlags);if(!r.resolved||o.length===0)s();else throw o.length>1?new Error(n("strictFlags.unexpectedMore",bt(o,e.i18n))):new Error(n("strictFlags.unexpectedSingle",bt(o,e.i18n)))})}}),or=e=>e.length===0?"":e.startsWith("v")?e:`v${e}`,sr={en:{"version.commandDescription":"Show CLI version","version.notes.1":'The version string begins with a "v".'},"zh-CN":{"version.commandDescription":"\u5C55\u793A CLI \u7248\u672C","version.notes.1":'\u7248\u672C\u53F7\u5F00\u5934\u5E26\u6709 "v"\u3002'}},ir=({alias:e=["V"],command:t=!0}={})=>P({setup:n=>{const{add:r,t:s}=n.i18n;r(sr);const o=or(n._version);return t&&(n=n.command("version",s("version.commandDescription"),{notes:[s("version.notes.1")]}).on("version",()=>{process.stdout.write(o)})),n.inspector({enforce:"pre",fn:(i,u)=>{let a=!1;const l=["version",...e];for(const m of Object.keys(i.raw.mergedFlags))if(l.includes(m)){a=!0;break}a?process.stdout.write(o):u()}})}});var I={exports:{}};let ar=pe,ur=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||process.platform==="win32"||ar.isatty(1)&&process.env.TERM!=="dumb"||"CI"in process.env),S=(e,t,n=e)=>r=>{let s=""+r,o=s.indexOf(t,e.length);return~o?e+Ft(s,t,n,o)+t:e+s+t},Ft=(e,t,n,r)=>{let s=e.substring(0,r)+n,o=e.substring(r+t.length),i=o.indexOf(t);return~i?s+Ft(o,t,n,i):s+o},vt=(e=ur)=>({isColorSupported:e,reset:e?t=>`\x1B[0m${t}\x1B[0m`:String,bold:e?S("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"):String,dim:e?S("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"):String,italic:e?S("\x1B[3m","\x1B[23m"):String,underline:e?S("\x1B[4m","\x1B[24m"):String,inverse:e?S("\x1B[7m","\x1B[27m"):String,hidden:e?S("\x1B[8m","\x1B[28m"):String,strikethrough:e?S("\x1B[9m","\x1B[29m"):String,black:e?S("\x1B[30m","\x1B[39m"):String,red:e?S("\x1B[31m","\x1B[39m"):String,green:e?S("\x1B[32m","\x1B[39m"):String,yellow:e?S("\x1B[33m","\x1B[39m"):String,blue:e?S("\x1B[34m","\x1B[39m"):String,magenta:e?S("\x1B[35m","\x1B[39m"):String,cyan:e?S("\x1B[36m","\x1B[39m"):String,white:e?S("\x1B[37m","\x1B[39m"):String,gray:e?S("\x1B[90m","\x1B[39m"):String,bgBlack:e?S("\x1B[40m","\x1B[49m"):String,bgRed:e?S("\x1B[41m","\x1B[49m"):String,bgGreen:e?S("\x1B[42m","\x1B[49m"):String,bgYellow:e?S("\x1B[43m","\x1B[49m"):String,bgBlue:e?S("\x1B[44m","\x1B[49m"):String,bgMagenta:e?S("\x1B[45m","\x1B[49m"):String,bgCyan:e?S("\x1B[46m","\x1B[49m"):String,bgWhite:e?S("\x1B[47m","\x1B[49m"):String});I.exports=vt(),I.exports.createColors=vt;function lr(e){return e.split(`
73
+ `).splice(1).map(t=>t.trim().replace("file://",""))}function cr(e){return`
74
+ ${lr(e).map(t=>` ${t.replace(/^at ([\s\S]+) \((.+)\)/,(n,r,s)=>I.exports.gray(`at ${r} (${I.exports.cyan(s)})`))}`).join(`
75
+ `)}`}function mr(e){return e.map(t=>typeof(t==null?void 0:t.stack)=="string"?`${t.message}
76
+ ${cr(t.stack)}`:t)}function hr(e,t){const n=e.toUpperCase(),r=I.exports[t];return I.exports.bold(I.exports.inverse(r(` ${n} `)))}function ee(e,t,n){const r=I.exports[t],s=n!=null&&n.textColor?I.exports[n.textColor]:r,o=(n==null?void 0:n.target)||console.log;return(...i)=>{const u=mr(i);o(`${hr(e,t)} ${s(u.join(" "))}
77
+ `)}}ee("log","gray"),ee("info","blue",{target:console.info}),ee("warn","yellow",{target:console.warn}),ee("success","green");const pr=ee("error","red",{target:console.error}),dr=()=>P({setup:e=>e.inspector({enforce:"pre",fn:(t,n)=>{try{n()}catch(r){pr(r.message),process.exit(1)}}})});export{nn as Clerc,Ie as CommandExistsError,ke as CommandNameConflictError,je as DescriptionNotSetError,Pe as InvalidCommandNameError,fe as LocaleNotCalledFirstError,Re as NameNotSetError,se as NoCommandGivenError,oe as NoSuchCommandError,C as Root,We as VersionNotSetError,hn as completionsPlugin,Ze as compose,sn as defineCommand,rn as defineHandler,on as defineInspector,P as definePlugin,Ke as detectLocale,H as formatCommandName,dr as friendlyErrorPlugin,yn as helpPlugin,qe as isInvalidName,er as notFoundPlugin,Ce as resolveArgv,Ye as resolveCommand,Ge as resolveCommandStrict,xe as resolveFlattenCommands,Ve as resolveParametersBeforeFlag,Xt as resolveRootCommands,ze as resolveSubcommandsByParent,rr as strictFlagsPlugin,ir as versionPlugin,Je as withBrackets};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clerc",
3
- "version": "0.28.1",
3
+ "version": "0.29.0",
4
4
  "author": "Ray <nn_201312@163.com> (https://github.com/so1ve)",
5
5
  "description": "Clerc: The full-featured cli framework.",
6
6
  "keywords": [
@@ -47,13 +47,13 @@
47
47
  "access": "public"
48
48
  },
49
49
  "devDependencies": {
50
- "@clerc/core": "0.28.1",
51
- "@clerc/plugin-friendly-error": "0.28.1",
52
- "@clerc/plugin-help": "0.28.1",
53
- "@clerc/plugin-not-found": "0.28.1",
54
- "@clerc/plugin-completions": "0.28.1",
55
- "@clerc/plugin-strict-flags": "0.28.1",
56
- "@clerc/plugin-version": "0.28.1"
50
+ "@clerc/core": "0.29.0",
51
+ "@clerc/plugin-help": "0.29.0",
52
+ "@clerc/plugin-friendly-error": "0.29.0",
53
+ "@clerc/plugin-completions": "0.29.0",
54
+ "@clerc/plugin-strict-flags": "0.29.0",
55
+ "@clerc/plugin-version": "0.29.0",
56
+ "@clerc/plugin-not-found": "0.29.0"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "puild --minify",