clerc 0.27.1 → 0.28.1
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 +27 -22
- package/dist/index.js +29 -34
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -164,7 +164,7 @@ 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 CamelCase<T extends string> = T extends `${infer
|
|
167
|
+
type CamelCase<T extends string> = (T extends `${infer Prefix}-${infer Suffix}` | `${infer Prefix} ${infer Suffix}` ? `${Prefix}${Capitalize<CamelCase<Suffix>>}` : T);
|
|
168
168
|
|
|
169
169
|
declare const DOUBLE_DASH = "--";
|
|
170
170
|
type TypeFunction<ReturnType = any> = (value: any) => ReturnType;
|
|
@@ -234,6 +234,29 @@ type TypeFlag<Schemas extends Flags$1> = ParsedFlags<{
|
|
|
234
234
|
[flag in keyof Schemas]: InferFlagType<Schemas[flag]>;
|
|
235
235
|
}>;
|
|
236
236
|
|
|
237
|
+
type StripBrackets<Parameter extends string> = (Parameter extends `<${infer ParameterName}>` | `[${infer ParameterName}]` ? (ParameterName extends `${infer SpreadName}...` ? SpreadName : ParameterName) : never);
|
|
238
|
+
type ParameterType<Parameter extends string> = (Parameter extends `<${infer _ParameterName}...>` | `[${infer _ParameterName}...]` ? string[] : Parameter extends `<${infer _ParameterName}>` ? string : Parameter extends `[${infer _ParameterName}]` ? string | undefined : never);
|
|
239
|
+
type NonNullableParameters<T extends string[] | undefined> = T extends undefined ? [] : NonNullable<T>;
|
|
240
|
+
type TransformParameters<C extends Command> = {
|
|
241
|
+
[Parameter in NonNullableParameters<C["parameters"]>[number] as CamelCase<StripBrackets<Parameter>>]: ParameterType<Parameter>;
|
|
242
|
+
};
|
|
243
|
+
type MakeEventMap<T extends CommandRecord> = {
|
|
244
|
+
[K in keyof T]: [InspectorContext];
|
|
245
|
+
};
|
|
246
|
+
type FallbackFlags<C extends Command> = Equals<NonNullableFlag<C>["flags"], {}> extends true ? Dict<any> : NonNullableFlag<C>["flags"];
|
|
247
|
+
type NonNullableFlag<C extends Command> = TypeFlag<NonNullable<C["flags"]>>;
|
|
248
|
+
type ParseFlag<C extends CommandRecord, N extends keyof C> = N extends keyof C ? OmitIndexSignature<NonNullableFlag<C[N]>["flags"]> : FallbackFlags<C[N]>["flags"];
|
|
249
|
+
type ParseRaw<C extends Command> = NonNullableFlag<C> & {
|
|
250
|
+
flags: FallbackFlags<C>;
|
|
251
|
+
parameters: string[];
|
|
252
|
+
mergedFlags: FallbackFlags<C> & NonNullableFlag<C>["unknownFlags"];
|
|
253
|
+
};
|
|
254
|
+
type ParseParameters<C extends CommandRecord = CommandRecord, 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
|
+
|
|
256
|
+
interface Plugin<T extends Clerc = Clerc, U extends Clerc = Clerc> {
|
|
257
|
+
setup: (cli: T) => U;
|
|
258
|
+
}
|
|
259
|
+
|
|
237
260
|
type CommandType = RootType | string;
|
|
238
261
|
type FlagOptions = FlagSchema & {
|
|
239
262
|
description?: string;
|
|
@@ -268,25 +291,7 @@ interface ParseOptions {
|
|
|
268
291
|
argv?: string[];
|
|
269
292
|
run?: boolean;
|
|
270
293
|
}
|
|
271
|
-
type StripBrackets<Parameter extends string> = (Parameter extends `<${infer ParameterName}>` | `[${infer ParameterName}]` ? (ParameterName extends `${infer SpreadName}...` ? SpreadName : ParameterName) : never);
|
|
272
|
-
type ParameterType<Parameter extends string> = (Parameter extends `<${infer _ParameterName}...>` | `[${infer _ParameterName}...]` ? string[] : Parameter extends `<${infer _ParameterName}>` ? string : Parameter extends `[${infer _ParameterName}]` ? string | undefined : never);
|
|
273
|
-
type MakeEventMap<T extends CommandRecord> = {
|
|
274
|
-
[K in keyof T]: [InspectorContext];
|
|
275
|
-
};
|
|
276
294
|
type PossibleInputKind = string | number | boolean | Dict<any>;
|
|
277
|
-
type NonNullableParameters<T extends string[] | undefined> = T extends undefined ? [] : NonNullable<T>;
|
|
278
|
-
type TransformParameters<C extends Command> = {
|
|
279
|
-
[Parameter in NonNullableParameters<C["parameters"]>[number] as CamelCase<StripBrackets<Parameter>>]: ParameterType<Parameter>;
|
|
280
|
-
};
|
|
281
|
-
type FallbackFlags<C extends Command> = Equals<NonNullableFlag<C>["flags"], {}> extends true ? Dict<any> : NonNullableFlag<C>["flags"];
|
|
282
|
-
type NonNullableFlag<C extends Command> = TypeFlag<NonNullable<C["flags"]>>;
|
|
283
|
-
type ParseFlag<C extends CommandRecord, N extends keyof C> = N extends keyof C ? OmitIndexSignature<NonNullableFlag<C[N]>["flags"]> : FallbackFlags<C[N]>["flags"];
|
|
284
|
-
type ParseRaw<C extends Command> = NonNullableFlag<C> & {
|
|
285
|
-
flags: FallbackFlags<C>;
|
|
286
|
-
parameters: string[];
|
|
287
|
-
mergedFlags: FallbackFlags<C> & NonNullableFlag<C>["unknownFlags"];
|
|
288
|
-
};
|
|
289
|
-
type ParseParameters<C extends CommandRecord = CommandRecord, 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]>;
|
|
290
295
|
interface HandlerContext<C extends CommandRecord = CommandRecord, N extends keyof C = keyof C> {
|
|
291
296
|
name?: LiteralUnion<N, string>;
|
|
292
297
|
called?: string | RootType;
|
|
@@ -319,8 +324,8 @@ interface InspectorObject<C extends CommandRecord = CommandRecord> {
|
|
|
319
324
|
enforce?: "pre" | "post";
|
|
320
325
|
fn: InspectorFn<C>;
|
|
321
326
|
}
|
|
322
|
-
interface
|
|
323
|
-
|
|
327
|
+
interface I18N {
|
|
328
|
+
add: () => void;
|
|
324
329
|
}
|
|
325
330
|
|
|
326
331
|
declare const Root: unique symbol;
|
|
@@ -556,4 +561,4 @@ declare const versionPlugin: ({ alias, command, }?: VersionPluginOptions) => Plu
|
|
|
556
561
|
|
|
557
562
|
declare const friendlyErrorPlugin: () => Plugin<Clerc<{}>, Clerc<{}>>;
|
|
558
563
|
|
|
559
|
-
export { Clerc, Command, CommandAlias, CommandCustomProperties, CommandExistsError, CommandNameConflictError, CommandOptions, CommandRecord, CommandType, CommandWithHandler, CompletionsPluginOptions, DescriptionNotSetError, FallbackType, Flag, FlagOptions, Flags, Handler, HandlerContext, HandlerInCommand, HelpPluginOptions, 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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
${
|
|
3
|
-
cmd+="__${
|
|
4
|
-
;;`,
|
|
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=>`
|
|
2
|
+
${e})
|
|
3
|
+
cmd+="__${e}"
|
|
4
|
+
;;`,Vt=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]}"
|
|
@@ -13,27 +13,27 @@ import fu from"tty";import ct from"util";import ht from"os";class pt{constructor
|
|
|
13
13
|
do
|
|
14
14
|
case "\${i}" in
|
|
15
15
|
"$1")
|
|
16
|
-
cmd="${
|
|
16
|
+
cmd="${n}"
|
|
17
17
|
;;
|
|
18
|
-
${Object.keys(
|
|
18
|
+
${Object.keys(r).map(Yt).join("")}
|
|
19
19
|
*)
|
|
20
20
|
;;
|
|
21
21
|
esac
|
|
22
22
|
done
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
complete -F _${
|
|
26
|
-
`},
|
|
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(`
|
|
27
27
|
`)}).join(`
|
|
28
|
-
`),
|
|
28
|
+
`),Zt=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
|
-
Register-ArgumentCompleter -Native -CommandName '${
|
|
31
|
+
Register-ArgumentCompleter -Native -CommandName '${n}' -ScriptBlock {
|
|
32
32
|
param($wordToComplete, $commandAst, $cursorPosition)
|
|
33
33
|
|
|
34
34
|
$commandElements = $commandAst.CommandElements
|
|
35
35
|
$command = @(
|
|
36
|
-
'${
|
|
36
|
+
'${n}'
|
|
37
37
|
for ($i = 1; $i -lt $commandElements.Count; $i++) {
|
|
38
38
|
$element = $commandElements[$i]
|
|
39
39
|
if ($element -isnot [StringConstantExpressionAst] -or
|
|
@@ -46,13 +46,13 @@ Register-ArgumentCompleter -Native -CommandName '${t}' -ScriptBlock {
|
|
|
46
46
|
}) -join ';'
|
|
47
47
|
|
|
48
48
|
$completions = @(switch ($command) {
|
|
49
|
-
'${
|
|
50
|
-
${Object.entries(
|
|
49
|
+
'${n}' {
|
|
50
|
+
${Object.entries(r).map(([o,s])=>Gt(s)).join(`
|
|
51
51
|
`)}
|
|
52
52
|
break
|
|
53
53
|
}
|
|
54
|
-
${Object.entries(
|
|
55
|
-
${
|
|
54
|
+
${Object.entries(r).map(([o,s])=>`'${n};${o.split(" ").join(";")}' {
|
|
55
|
+
${qt(s)}
|
|
56
56
|
break
|
|
57
57
|
}`).join(`
|
|
58
58
|
`)}
|
|
@@ -60,23 +60,18 @@ Register-ArgumentCompleter -Native -CommandName '${t}' -ScriptBlock {
|
|
|
60
60
|
|
|
61
61
|
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
|
|
62
62
|
Sort-Object -Property ListItemText
|
|
63
|
-
}`},ie={bash:zt,pwsh:qt},Zt=(u={})=>H({setup:e=>{const{command:t=!0}=u;return t&&(e=e.command("completions","Print shell completions to stdout",{flags:{shell:{description:"Shell type",type:String,default:""}},parameters:["[shell]"]}).on("completions",D=>{if(!e._name)throw new Error("CLI name is not defined!");const n=String(D.parameters.shell||D.flags.shell);if(!n)throw new Error("Missing shell name");if(n in ie)process.stdout.write(ie[n](D));else throw new Error(`No such shell: ${n}`)})),e}}),Jt=u=>Array.isArray(u)?u:[u],Kt=u=>u.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`),ae=u=>u.length<=1?`-${u}`:`--${Kt(u)}`;function Qt(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}var $={exports:{}};let Xt=fu,uD=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||process.platform==="win32"||Xt.isatty(1)&&process.env.TERM!=="dumb"||"CI"in process.env),x=(u,e,t=u)=>D=>{let n=""+D,r=n.indexOf(e,u.length);return~r?u+le(n,e,t,r)+e:u+n+e},le=(u,e,t,D)=>{let n=u.substring(0,D)+t,r=u.substring(D+e.length),o=r.indexOf(e);return~o?n+le(r,e,t,o):n+r},ce=(u=uD)=>({isColorSupported:u,reset:u?e=>`\x1B[0m${e}\x1B[0m`:String,bold:u?x("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"):String,dim:u?x("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"):String,italic:u?x("\x1B[3m","\x1B[23m"):String,underline:u?x("\x1B[4m","\x1B[24m"):String,inverse:u?x("\x1B[7m","\x1B[27m"):String,hidden:u?x("\x1B[8m","\x1B[28m"):String,strikethrough:u?x("\x1B[9m","\x1B[29m"):String,black:u?x("\x1B[30m","\x1B[39m"):String,red:u?x("\x1B[31m","\x1B[39m"):String,green:u?x("\x1B[32m","\x1B[39m"):String,yellow:u?x("\x1B[33m","\x1B[39m"):String,blue:u?x("\x1B[34m","\x1B[39m"):String,magenta:u?x("\x1B[35m","\x1B[39m"):String,cyan:u?x("\x1B[36m","\x1B[39m"):String,white:u?x("\x1B[37m","\x1B[39m"):String,gray:u?x("\x1B[90m","\x1B[39m"):String,bgBlack:u?x("\x1B[40m","\x1B[49m"):String,bgRed:u?x("\x1B[41m","\x1B[49m"):String,bgGreen:u?x("\x1B[42m","\x1B[49m"):String,bgYellow:u?x("\x1B[43m","\x1B[49m"):String,bgBlue:u?x("\x1B[44m","\x1B[49m"):String,bgMagenta:u?x("\x1B[45m","\x1B[49m"):String,bgCyan:u?x("\x1B[46m","\x1B[49m"):String,bgWhite:u?x("\x1B[47m","\x1B[49m"):String});$.exports=ce(),$.exports.createColors=ce;var eD=Function.prototype.toString,tD=/\s*function(?:\s|\s*\/\*[^(?:*\/)]+\*\/\s*)*([^\s\(\/]+)/;function DD(u){if(typeof u!="function")return null;var e="";if(typeof Function.prototype.name=="undefined"&&typeof u.name=="undefined"){var t=eD.call(u).match(tD);t&&(e=t[1])}else e=u.name;return e}var he=DD,pe={exports:{}};let yu=[],me=0;const S=(u,e)=>{me>=e&&yu.push(u)};S.WARN=1,S.INFO=2,S.DEBUG=3,S.reset=()=>{yu=[]},S.setDebugLevel=u=>{me=u},S.warn=u=>S(u,S.WARN),S.info=u=>S(u,S.INFO),S.debug=u=>S(u,S.DEBUG),S.debugMessages=()=>yu;var wu=S,Su={exports:{}},nD=({onlyFirst:u=!1}={})=>{const e=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(e,u?void 0:"g")};const rD=nD;var oD=u=>typeof u=="string"?u.replace(rD(),""):u,$u={exports:{}};const fe=u=>Number.isNaN(u)?!1:u>=4352&&(u<=4447||u===9001||u===9002||11904<=u&&u<=12871&&u!==12351||12880<=u&&u<=19903||19968<=u&&u<=42182||43360<=u&&u<=43388||44032<=u&&u<=55203||63744<=u&&u<=64255||65040<=u&&u<=65049||65072<=u&&u<=65131||65281<=u&&u<=65376||65504<=u&&u<=65510||110592<=u&&u<=110593||127488<=u&&u<=127569||131072<=u&&u<=262141);$u.exports=fe,$u.exports.default=fe;var sD=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g};const iD=oD,aD=$u.exports,lD=sD,de=u=>{if(typeof u!="string"||u.length===0||(u=iD(u),u.length===0))return 0;u=u.replace(lD()," ");let e=0;for(let t=0;t<u.length;t++){const D=u.codePointAt(t);D<=31||D>=127&&D<=159||D>=768&&D<=879||(D>65535&&t++,e+=aD(D)?2:1)}return e};Su.exports=de,Su.exports.default=de;const Fe=Su.exports;function lu(u){return u?/\u001b\[((?:\d*;){0,5}\d*)m/g:/\u001b\[(?:\d*;){0,5}\d*m/g}function M(u){let e=lu();return(""+u).replace(e,"").split(`
|
|
64
|
-
`)
|
|
65
|
-
`)
|
|
66
|
-
`)
|
|
67
|
-
`)
|
|
68
|
-
`)}
|
|
69
|
-
`)[0].length}}Ve.reset=()=>_.reset();function ku(u,e,t){let D=[];u.forEach(function(r){D.push(r.draw(e))});let n=D.join("");n.length&&t.push(n)}var GD=Ve;(function(u){u.exports=GD})(pe);var YD=Qt(pe.exports);const Lu=(...u)=>{const e=new YD({chars:{top:"","top-mid":"","top-left":"","top-right":"",bottom:"","bottom-mid":"","bottom-left":"","bottom-right":"",left:"","left-mid":"",mid:"","mid-mid":"",right:"","right-mid":"",middle:" "},style:{"padding-left":0,"padding-right":0}});return e.push(...u),e},Iu=(...u)=>Lu(...u).toString().split(`
|
|
70
|
-
`),zD=u=>Array.isArray(u)?`Array<${he(u[0])}>`:he(u),UD=u=>{const e=[];for(const t of u){if(t.type==="block"||!t.type){const D=" ",n=t.body.map(o=>D+o);n.unshift("");const r=n.join(`
|
|
71
|
-
`);e.push(Lu([$.exports.bold(`${t.title}:`)],[r]).toString())}else if(t.type==="inline"){const D=t.items.map(r=>[$.exports.bold(`${r.title}:`),r.body]),n=Lu(...D);e.push(n.toString())}e.push("")}return e.join(`
|
|
72
|
-
`)},ju=$.exports.yellow("-"),VD="(No description)",qD="Name",ZD="Version",JD="Subcommand",KD="Commands",QD="Flags",XD="Description",qe="Usage",un="Examples",Ze="Notes",Je=u=>{process.stdout.write(u)},Ke=(u,e,t)=>{const D=[{title:qD,body:$.exports.red(e._name)},{title:ZD,body:$.exports.yellow(e._version)}];t&&D.push({title:JD,body:$.exports.green(`${e._name} ${G(t.name)}`)}),u.push({type:"inline",items:D}),u.push({title:XD,body:[(t==null?void 0:t.description)||e._description]})},Qe=(u,e)=>{const t=e.map(([D,n])=>[D,ju,n]);u.push({title:un,body:Iu(...t)})},hu=(u,e,t,D)=>{const{cli:n}=e,r=[];Ke(r,n),r.push({title:qe,body:[$.exports.magenta(`$ ${n._name} ${ue("command",e.hasRootOrAlias)} [flags]`)]});const o=[...e.hasRoot?[n._commands[w]]:[],...Object.values(n._commands)].map(l=>{const a=[typeof l.name=="symbol"?"":l.name,...Jt(l.alias||[])].sort((s,d)=>s===w?-1:d===w?1:s.length-d.length).map(s=>s===""||typeof s=="symbol"?`${n._name}`:`${n._name} ${s}`).join(", ");return[$.exports.cyan(a),ju,l.description]});return r.push({title:KD,body:Iu(...o)}),t&&r.push({title:Ze,body:t}),D&&Qe(r,D),u(r)},Xe=(u,e,t)=>{var D;const{cli:n}=e,r=Fu(n._commands,t);if(!r)throw new ou(G(t));const o=[];Ke(o,n,{...r,name:G(t)});const l=((D=r.parameters)==null?void 0:D.join(" "))||void 0,a=` ${G(t)}`,s=l?` ${l}`:"",d=r.flags?" [flags]":"";return o.push({title:qe,body:[$.exports.magenta(`$ ${n._name}${a}${s}${d}`)]}),r.flags&&o.push({title:QD,body:Iu(...Object.entries(r.flags).map(([C,m])=>{const h=[ae(C)];m.alias&&h.push(ae(m.alias));const i=[$.exports.blue(h.join(", "))];if(i.push(ju,m.description||VD),m.type){const c=zD(m.type);i.push($.exports.gray(`(${c})`))}return i}))}),r.notes&&o.push({title:Ze,body:r.notes}),r.examples&&Qe(o,r.examples),u(o)},en=({command:u=!0,showHelpWhenNoCommand:e=!0,notes:t,examples:D,banner:n,renderer:r="cliffy"}={})=>H({setup:o=>{const l=r==="cliffy"?UD:()=>"",a=s=>{n&&Je(`${n}
|
|
73
|
-
`),Je(s)};return u&&(o=o.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:[[`$ ${o._name} help`,"Show help"],[`$ ${o._name} help <command>`,"Show help for a specific command"],[`$ ${o._name} <command> --help`,"Show help for a specific command"]]}).on("help",s=>{s.parameters.command.length?a(Xe(l,s,s.parameters.command)):a(hu(l,s,t,D))})),o.inspector((s,d)=>{const C=s.raw.mergedFlags.h||s.raw.mergedFlags.help;if(!s.hasRootOrAlias&&!s.raw._.length&&e&&!C){let m=`No command given.
|
|
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.
|
|
74
69
|
|
|
75
|
-
`;
|
|
76
|
-
`,a(
|
|
77
|
-
`),process.exit(2)}}})}),
|
|
78
|
-
`).splice(1).map(
|
|
79
|
-
${
|
|
80
|
-
`)}`}function
|
|
81
|
-
${
|
|
82
|
-
`)}}
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clerc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.1",
|
|
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/
|
|
51
|
-
"@clerc/
|
|
52
|
-
"@clerc/plugin-
|
|
53
|
-
"@clerc/plugin-
|
|
54
|
-
"@clerc/plugin-
|
|
55
|
-
"@clerc/plugin-strict-flags": "0.
|
|
56
|
-
"@clerc/plugin-
|
|
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"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "puild --minify",
|