clerc 0.25.1 → 0.27.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 +559 -7
- package/dist/index.js +82 -7
- package/package.json +12 -17
- package/dist/index.mjs +0 -7
- package/dist/toolkit.d.ts +0 -1
- package/dist/toolkit.js +0 -1
- package/dist/toolkit.mjs +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,559 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
3
|
+
|
|
4
|
+
@category Type
|
|
5
|
+
*/
|
|
6
|
+
type Primitive =
|
|
7
|
+
| null
|
|
8
|
+
| undefined
|
|
9
|
+
| string
|
|
10
|
+
| number
|
|
11
|
+
| boolean
|
|
12
|
+
| symbol
|
|
13
|
+
| bigint;
|
|
14
|
+
|
|
15
|
+
declare global {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
|
|
17
|
+
interface SymbolConstructor {
|
|
18
|
+
readonly observable: symbol;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
24
|
+
|
|
25
|
+
This is the counterpart of `PickIndexSignature`.
|
|
26
|
+
|
|
27
|
+
Use-cases:
|
|
28
|
+
- Remove overly permissive signatures from third-party types.
|
|
29
|
+
|
|
30
|
+
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
31
|
+
|
|
32
|
+
It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
|
33
|
+
|
|
34
|
+
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
const indexed: Record<string, unknown> = {}; // Allowed
|
|
38
|
+
|
|
39
|
+
const keyed: Record<'foo', unknown> = {}; // Error
|
|
40
|
+
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
type Indexed = {} extends Record<string, unknown>
|
|
47
|
+
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
48
|
+
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
49
|
+
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
50
|
+
|
|
51
|
+
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
52
|
+
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
53
|
+
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
54
|
+
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
import type {OmitIndexSignature} from 'type-fest';
|
|
61
|
+
|
|
62
|
+
type OmitIndexSignature<ObjectType> = {
|
|
63
|
+
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
64
|
+
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
65
|
+
};
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
import type {OmitIndexSignature} from 'type-fest';
|
|
72
|
+
|
|
73
|
+
type OmitIndexSignature<ObjectType> = {
|
|
74
|
+
[KeyType in keyof ObjectType
|
|
75
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
76
|
+
as {} extends Record<KeyType, unknown>
|
|
77
|
+
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
78
|
+
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
79
|
+
]: ObjectType[KeyType];
|
|
80
|
+
};
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
import type {OmitIndexSignature} from 'type-fest';
|
|
87
|
+
|
|
88
|
+
type OmitIndexSignature<ObjectType> = {
|
|
89
|
+
[KeyType in keyof ObjectType
|
|
90
|
+
as {} extends Record<KeyType, unknown>
|
|
91
|
+
? never // => Remove this `KeyType`.
|
|
92
|
+
: KeyType // => Keep this `KeyType` as it is.
|
|
93
|
+
]: ObjectType[KeyType];
|
|
94
|
+
};
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
@example
|
|
98
|
+
```
|
|
99
|
+
import type {OmitIndexSignature} from 'type-fest';
|
|
100
|
+
|
|
101
|
+
interface Example {
|
|
102
|
+
// These index signatures will be removed.
|
|
103
|
+
[x: string]: any
|
|
104
|
+
[x: number]: any
|
|
105
|
+
[x: symbol]: any
|
|
106
|
+
[x: `head-${string}`]: string
|
|
107
|
+
[x: `${string}-tail`]: string
|
|
108
|
+
[x: `head-${string}-tail`]: string
|
|
109
|
+
[x: `${bigint}`]: string
|
|
110
|
+
[x: `embedded-${number}`]: string
|
|
111
|
+
|
|
112
|
+
// These explicitly defined keys will remain.
|
|
113
|
+
foo: 'bar';
|
|
114
|
+
qux?: 'baz';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
118
|
+
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
@see PickIndexSignature
|
|
122
|
+
@category Object
|
|
123
|
+
*/
|
|
124
|
+
type OmitIndexSignature<ObjectType> = {
|
|
125
|
+
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
126
|
+
? never
|
|
127
|
+
: KeyType]: ObjectType[KeyType];
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
|
|
132
|
+
|
|
133
|
+
Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
|
|
134
|
+
|
|
135
|
+
This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
|
|
136
|
+
|
|
137
|
+
@example
|
|
138
|
+
```
|
|
139
|
+
import type {LiteralUnion} from 'type-fest';
|
|
140
|
+
|
|
141
|
+
// Before
|
|
142
|
+
|
|
143
|
+
type Pet = 'dog' | 'cat' | string;
|
|
144
|
+
|
|
145
|
+
const pet: Pet = '';
|
|
146
|
+
// Start typing in your TypeScript-enabled IDE.
|
|
147
|
+
// You **will not** get auto-completion for `dog` and `cat` literals.
|
|
148
|
+
|
|
149
|
+
// After
|
|
150
|
+
|
|
151
|
+
type Pet2 = LiteralUnion<'dog' | 'cat', string>;
|
|
152
|
+
|
|
153
|
+
const pet: Pet2 = '';
|
|
154
|
+
// You **will** get auto-completion for `dog` and `cat` literals.
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
@category Type
|
|
158
|
+
*/
|
|
159
|
+
type LiteralUnion<
|
|
160
|
+
LiteralType,
|
|
161
|
+
BaseType extends Primitive,
|
|
162
|
+
> = LiteralType | (BaseType & Record<never, never>);
|
|
163
|
+
|
|
164
|
+
type Equals<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
165
|
+
type Dict<T> = Record<string, T>;
|
|
166
|
+
type MaybeArray$1<T> = T | T[];
|
|
167
|
+
type CamelCase<T extends string> = T extends `${infer A}-${infer B}${infer C}` ? `${A}${Capitalize<B>}${CamelCase<C>}` : T;
|
|
168
|
+
|
|
169
|
+
declare const DOUBLE_DASH = "--";
|
|
170
|
+
type TypeFunction<ReturnType = any> = (value: any) => ReturnType;
|
|
171
|
+
type TypeFunctionArray<ReturnType> = readonly [TypeFunction<ReturnType>];
|
|
172
|
+
type FlagType<ReturnType = any> = TypeFunction<ReturnType> | TypeFunctionArray<ReturnType>;
|
|
173
|
+
type FlagSchemaBase<TF> = {
|
|
174
|
+
/**
|
|
175
|
+
Type of the flag as a function that parses the argv string and returns the parsed value.
|
|
176
|
+
|
|
177
|
+
@example
|
|
178
|
+
```
|
|
179
|
+
type: String
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
@example Wrap in an array to accept multiple values.
|
|
183
|
+
```
|
|
184
|
+
type: [Boolean]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
@example Custom function type that uses moment.js to parse string as date.
|
|
188
|
+
```
|
|
189
|
+
type: function CustomDate(value: string) {
|
|
190
|
+
return moment(value).toDate();
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
*/
|
|
194
|
+
type: TF;
|
|
195
|
+
/**
|
|
196
|
+
A single-character alias for the flag.
|
|
197
|
+
|
|
198
|
+
@example
|
|
199
|
+
```
|
|
200
|
+
alias: 's'
|
|
201
|
+
```
|
|
202
|
+
*/
|
|
203
|
+
alias?: string;
|
|
204
|
+
} & Record<PropertyKey, unknown>;
|
|
205
|
+
type FlagSchemaDefault<TF, DefaultType = any> = FlagSchemaBase<TF> & {
|
|
206
|
+
/**
|
|
207
|
+
Default value of the flag. Also accepts a function that returns the default value.
|
|
208
|
+
[Default: undefined]
|
|
209
|
+
|
|
210
|
+
@example
|
|
211
|
+
```
|
|
212
|
+
default: 'hello'
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
@example
|
|
216
|
+
```
|
|
217
|
+
default: () => [1, 2, 3]
|
|
218
|
+
```
|
|
219
|
+
*/
|
|
220
|
+
default: DefaultType | (() => DefaultType);
|
|
221
|
+
};
|
|
222
|
+
type FlagSchema<TF = FlagType> = (FlagSchemaBase<TF> | FlagSchemaDefault<TF>);
|
|
223
|
+
type FlagTypeOrSchema<ExtraOptions = Record<string, unknown>> = FlagType | (FlagSchema & ExtraOptions);
|
|
224
|
+
type Flags$1<ExtraOptions = Record<string, unknown>> = Record<string, FlagTypeOrSchema<ExtraOptions>>;
|
|
225
|
+
type InferFlagType<Flag extends FlagTypeOrSchema> = (Flag extends (TypeFunctionArray<infer T> | FlagSchema<TypeFunctionArray<infer T>>) ? (Flag extends FlagSchemaDefault<TypeFunctionArray<T>, infer D> ? T[] | D : T[]) : (Flag extends TypeFunction<infer T> | FlagSchema<TypeFunction<infer T>> ? (Flag extends FlagSchemaDefault<TypeFunction<T>, infer D> ? T | D : T | undefined) : never));
|
|
226
|
+
interface ParsedFlags<Schemas = Record<string, unknown>> {
|
|
227
|
+
flags: Schemas;
|
|
228
|
+
unknownFlags: Record<string, (string | boolean)[]>;
|
|
229
|
+
_: string[] & {
|
|
230
|
+
[DOUBLE_DASH]: string[];
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
type TypeFlag<Schemas extends Flags$1> = ParsedFlags<{
|
|
234
|
+
[flag in keyof Schemas]: InferFlagType<Schemas[flag]>;
|
|
235
|
+
}>;
|
|
236
|
+
|
|
237
|
+
type CommandType = RootType | string;
|
|
238
|
+
type FlagOptions = FlagSchema & {
|
|
239
|
+
description?: string;
|
|
240
|
+
};
|
|
241
|
+
type Flag = FlagOptions & {
|
|
242
|
+
name: string;
|
|
243
|
+
};
|
|
244
|
+
type Flags = Dict<FlagOptions>;
|
|
245
|
+
declare interface CommandCustomProperties {
|
|
246
|
+
}
|
|
247
|
+
interface CommandOptions<P extends string[] = string[], A extends MaybeArray$1<string | RootType> = MaybeArray$1<string | RootType>, F extends Flags = Flags> extends CommandCustomProperties {
|
|
248
|
+
alias?: A;
|
|
249
|
+
parameters?: P;
|
|
250
|
+
flags?: F;
|
|
251
|
+
examples?: [string, string][];
|
|
252
|
+
notes?: string[];
|
|
253
|
+
}
|
|
254
|
+
type Command<N extends string | RootType = string, O extends CommandOptions = CommandOptions> = O & {
|
|
255
|
+
name: N;
|
|
256
|
+
description: string;
|
|
257
|
+
};
|
|
258
|
+
type CommandAlias<N extends string | RootType = string, O extends CommandOptions = CommandOptions> = Command<N, O> & {
|
|
259
|
+
__isAlias?: true;
|
|
260
|
+
};
|
|
261
|
+
type CommandWithHandler<N extends string | RootType = string, O extends CommandOptions = CommandOptions> = Command<N, O> & {
|
|
262
|
+
handler?: HandlerInCommand<HandlerContext<Record<N, Command<N, O>> & Record<never, never>, N>>;
|
|
263
|
+
};
|
|
264
|
+
type CommandRecord = Dict<Command> & {
|
|
265
|
+
[Root]?: Command;
|
|
266
|
+
};
|
|
267
|
+
interface ParseOptions {
|
|
268
|
+
argv?: string[];
|
|
269
|
+
run?: boolean;
|
|
270
|
+
}
|
|
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
|
+
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
|
+
interface HandlerContext<C extends CommandRecord = CommandRecord, N extends keyof C = keyof C> {
|
|
291
|
+
name?: LiteralUnion<N, string>;
|
|
292
|
+
called?: string | RootType;
|
|
293
|
+
resolved: boolean;
|
|
294
|
+
hasRootOrAlias: boolean;
|
|
295
|
+
hasRoot: boolean;
|
|
296
|
+
raw: {
|
|
297
|
+
[K in keyof ParseRaw<C[N]>]: ParseRaw<C[N]>[K];
|
|
298
|
+
};
|
|
299
|
+
parameters: {
|
|
300
|
+
[K in keyof ParseParameters<C, N>]: ParseParameters<C, N>[K];
|
|
301
|
+
};
|
|
302
|
+
unknownFlags: ParsedFlags["unknownFlags"];
|
|
303
|
+
flags: {
|
|
304
|
+
[K in keyof ParseFlag<C, N>]: ParseFlag<C, N>[K];
|
|
305
|
+
};
|
|
306
|
+
cli: Clerc<C>;
|
|
307
|
+
}
|
|
308
|
+
type Handler<C extends CommandRecord = CommandRecord, K extends keyof C = keyof C> = (ctx: HandlerContext<C, K>) => void;
|
|
309
|
+
type HandlerInCommand<C extends HandlerContext> = (ctx: {
|
|
310
|
+
[K in keyof C]: C[K];
|
|
311
|
+
}) => void;
|
|
312
|
+
type FallbackType<T, U> = {} extends T ? U : T;
|
|
313
|
+
type InspectorContext<C extends CommandRecord = CommandRecord> = HandlerContext<C> & {
|
|
314
|
+
flags: FallbackType<TypeFlag<NonNullable<C[keyof C]["flags"]>>["flags"], Dict<any>>;
|
|
315
|
+
};
|
|
316
|
+
type Inspector<C extends CommandRecord = CommandRecord> = InspectorFn<C> | InspectorObject<C>;
|
|
317
|
+
type InspectorFn<C extends CommandRecord = CommandRecord> = (ctx: InspectorContext<C>, next: () => void) => void;
|
|
318
|
+
interface InspectorObject<C extends CommandRecord = CommandRecord> {
|
|
319
|
+
enforce?: "pre" | "post";
|
|
320
|
+
fn: InspectorFn<C>;
|
|
321
|
+
}
|
|
322
|
+
interface Plugin<T extends Clerc = Clerc, U extends Clerc = Clerc> {
|
|
323
|
+
setup: (cli: T) => U;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
declare const Root: unique symbol;
|
|
327
|
+
type RootType = typeof Root;
|
|
328
|
+
declare class Clerc<C extends CommandRecord = {}> {
|
|
329
|
+
#private;
|
|
330
|
+
private constructor();
|
|
331
|
+
get _name(): string;
|
|
332
|
+
get _description(): string;
|
|
333
|
+
get _version(): string;
|
|
334
|
+
get _inspectors(): Inspector<CommandRecord>[];
|
|
335
|
+
get _commands(): C;
|
|
336
|
+
/**
|
|
337
|
+
* Create a new cli
|
|
338
|
+
* @returns
|
|
339
|
+
* @example
|
|
340
|
+
* ```ts
|
|
341
|
+
* const cli = Clerc.create()
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
static create(name?: string, description?: string, version?: string): Clerc<{}>;
|
|
345
|
+
/**
|
|
346
|
+
* Set the name of the cli
|
|
347
|
+
* @param name
|
|
348
|
+
* @returns
|
|
349
|
+
* @example
|
|
350
|
+
* ```ts
|
|
351
|
+
* Clerc.create()
|
|
352
|
+
* .name("test")
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
name(name: string): this;
|
|
356
|
+
/**
|
|
357
|
+
* Set the description of the cli
|
|
358
|
+
* @param description
|
|
359
|
+
* @returns
|
|
360
|
+
* @example
|
|
361
|
+
* ```ts
|
|
362
|
+
* Clerc.create()
|
|
363
|
+
* .description("test cli")
|
|
364
|
+
*/
|
|
365
|
+
description(description: string): this;
|
|
366
|
+
/**
|
|
367
|
+
* Set the version of the cli
|
|
368
|
+
* @param version
|
|
369
|
+
* @returns
|
|
370
|
+
* @example
|
|
371
|
+
* ```ts
|
|
372
|
+
* Clerc.create()
|
|
373
|
+
* .version("1.0.0")
|
|
374
|
+
*/
|
|
375
|
+
version(version: string): this;
|
|
376
|
+
/**
|
|
377
|
+
* Register a command
|
|
378
|
+
* @param name
|
|
379
|
+
* @param description
|
|
380
|
+
* @param options
|
|
381
|
+
* @returns
|
|
382
|
+
* @example
|
|
383
|
+
* ```ts
|
|
384
|
+
* Clerc.create()
|
|
385
|
+
* .command("test", "test command", {
|
|
386
|
+
* alias: "t",
|
|
387
|
+
* flags: {
|
|
388
|
+
* foo: {
|
|
389
|
+
* alias: "f",
|
|
390
|
+
* description: "foo flag",
|
|
391
|
+
* }
|
|
392
|
+
* }
|
|
393
|
+
* })
|
|
394
|
+
* ```
|
|
395
|
+
* @example
|
|
396
|
+
* ```ts
|
|
397
|
+
* Clerc.create()
|
|
398
|
+
* .command("", "root", {
|
|
399
|
+
* flags: {
|
|
400
|
+
* foo: {
|
|
401
|
+
* alias: "f",
|
|
402
|
+
* description: "foo flag",
|
|
403
|
+
* }
|
|
404
|
+
* }
|
|
405
|
+
* })
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
command<N extends string | RootType, O extends CommandOptions<[...P], A, F>, P extends string[] = string[], A extends MaybeArray$1<string | RootType> = MaybeArray$1<string | RootType>, F extends Flags = Flags>(c: CommandWithHandler<N, O & CommandOptions<[...P], A, F>>): this & Clerc<C & Record<N, Command<N, O>>>;
|
|
409
|
+
command<N extends string | RootType, O extends CommandOptions<[...P], A, F>, P extends string[] = string[], A extends MaybeArray$1<string | RootType> = MaybeArray$1<string | RootType>, F extends Flags = Flags>(name: N, description: string, options?: O & CommandOptions<[...P], A, F>): this & Clerc<C & Record<N, Command<N, O>>>;
|
|
410
|
+
/**
|
|
411
|
+
* Register a handler
|
|
412
|
+
* @param name
|
|
413
|
+
* @param handler
|
|
414
|
+
* @returns
|
|
415
|
+
* @example
|
|
416
|
+
* ```ts
|
|
417
|
+
* Clerc.create()
|
|
418
|
+
* .command("test", "test command")
|
|
419
|
+
* .on("test", (ctx) => {
|
|
420
|
+
* console.log(ctx);
|
|
421
|
+
* })
|
|
422
|
+
* ```
|
|
423
|
+
*/
|
|
424
|
+
on<K extends LiteralUnion<keyof CM, string>, CM extends this["_commands"] = this["_commands"]>(name: K, handler: Handler<CM, K>): this;
|
|
425
|
+
/**
|
|
426
|
+
* Use a plugin
|
|
427
|
+
* @param plugin
|
|
428
|
+
* @returns
|
|
429
|
+
* @example
|
|
430
|
+
* ```ts
|
|
431
|
+
* Clerc.create()
|
|
432
|
+
* .use(plugin)
|
|
433
|
+
* ```
|
|
434
|
+
*/
|
|
435
|
+
use<T extends Clerc, U extends Clerc>(plugin: Plugin<T, U>): this & Clerc<C & U["_commands"]> & U;
|
|
436
|
+
/**
|
|
437
|
+
* Register a inspector
|
|
438
|
+
* @param inspector
|
|
439
|
+
* @returns
|
|
440
|
+
* @example
|
|
441
|
+
* ```ts
|
|
442
|
+
* Clerc.create()
|
|
443
|
+
* .inspector((ctx, next) => {
|
|
444
|
+
* console.log(ctx);
|
|
445
|
+
* next();
|
|
446
|
+
* })
|
|
447
|
+
* ```
|
|
448
|
+
*/
|
|
449
|
+
inspector(inspector: Inspector): this;
|
|
450
|
+
/**
|
|
451
|
+
* Parse the command line arguments
|
|
452
|
+
* @param args
|
|
453
|
+
* @returns
|
|
454
|
+
* @example
|
|
455
|
+
* ```ts
|
|
456
|
+
* Clerc.create()
|
|
457
|
+
* .parse(process.argv.slice(2)) // Optional
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
460
|
+
parse(optionsOrArgv?: string[] | ParseOptions): this;
|
|
461
|
+
runMatchedCommand(): this;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
type MaybeArray<T> = T | T[];
|
|
465
|
+
|
|
466
|
+
declare const definePlugin: <T extends Clerc<{}>, U extends Clerc<{}>>(p: Plugin<T, U>) => Plugin<T, U>;
|
|
467
|
+
declare const defineHandler: <C extends Clerc<{}>, K extends keyof C["_commands"]>(_cli: C, _key: K, handler: Handler<C["_commands"], K>) => Handler<C["_commands"], K>;
|
|
468
|
+
declare const defineInspector: <C extends Clerc<{}>>(_cli: C, inspector: Inspector<C["_commands"]>) => Inspector<C["_commands"]>;
|
|
469
|
+
declare const defineCommand: <N extends string | typeof Root, O extends CommandOptions<[...P], MaybeArray<string | typeof Root>, Flags>, P extends string[]>(command: Command<N, O & CommandOptions<[...P], MaybeArray<string | typeof Root>, Flags>>, handler?: HandlerInCommand<HandlerContext<Record<N, Command<N, O>> & Record<never, never>, N>> | undefined) => CommandWithHandler<N, O & CommandOptions<[...P], MaybeArray<string | typeof Root>, Flags>>;
|
|
470
|
+
|
|
471
|
+
declare class CommandExistsError extends Error {
|
|
472
|
+
commandName: string;
|
|
473
|
+
constructor(commandName: string);
|
|
474
|
+
}
|
|
475
|
+
declare class NoSuchCommandError extends Error {
|
|
476
|
+
commandName: string;
|
|
477
|
+
constructor(commandName: string);
|
|
478
|
+
}
|
|
479
|
+
declare class NoCommandGivenError extends Error {
|
|
480
|
+
constructor();
|
|
481
|
+
}
|
|
482
|
+
declare class CommandNameConflictError extends Error {
|
|
483
|
+
n1: string;
|
|
484
|
+
n2: string;
|
|
485
|
+
constructor(n1: string, n2: string);
|
|
486
|
+
}
|
|
487
|
+
declare class NameNotSetError extends Error {
|
|
488
|
+
constructor();
|
|
489
|
+
}
|
|
490
|
+
declare class DescriptionNotSetError extends Error {
|
|
491
|
+
constructor();
|
|
492
|
+
}
|
|
493
|
+
declare class VersionNotSetError extends Error {
|
|
494
|
+
constructor();
|
|
495
|
+
}
|
|
496
|
+
declare class InvalidCommandNameError extends Error {
|
|
497
|
+
commandName: string;
|
|
498
|
+
constructor(commandName: string);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
declare function resolveFlattenCommands(commands: CommandRecord): Map<string[] | typeof Root, CommandAlias<string, CommandOptions<string[], MaybeArray$1<string | typeof Root>, Flags>>>;
|
|
502
|
+
declare function resolveCommand(commands: CommandRecord, name: string | string[] | RootType): Command<string | RootType> | undefined;
|
|
503
|
+
declare function resolveSubcommandsByParent(commands: CommandRecord, parent: string | string[], depth?: number): Command<string, CommandOptions<string[], MaybeArray$1<string | typeof Root>, Flags>>[];
|
|
504
|
+
declare const resolveRootCommands: (commands: CommandRecord) => Command<string, CommandOptions<string[], MaybeArray$1<string | typeof Root>, Flags>>[];
|
|
505
|
+
declare function resolveParametersBeforeFlag(argv: string[]): string[];
|
|
506
|
+
declare const resolveArgv: () => string[];
|
|
507
|
+
declare function compose(inspectors: Inspector[]): (getCtx: () => InspectorContext) => void;
|
|
508
|
+
declare const isInvalidName: (name: CommandType) => boolean;
|
|
509
|
+
declare const withBrackets: (s: string, isOptional?: boolean) => string;
|
|
510
|
+
declare const formatCommandName: (name: string | string[] | RootType) => string;
|
|
511
|
+
|
|
512
|
+
interface CompletionsPluginOptions {
|
|
513
|
+
command?: boolean;
|
|
514
|
+
}
|
|
515
|
+
declare const completionsPlugin: (options?: CompletionsPluginOptions) => Plugin<Clerc<{}>, Clerc<{}>>;
|
|
516
|
+
|
|
517
|
+
interface HelpPluginOptions {
|
|
518
|
+
/**
|
|
519
|
+
* Whether to registr the help command.
|
|
520
|
+
* @default true
|
|
521
|
+
*/
|
|
522
|
+
command?: boolean;
|
|
523
|
+
/**
|
|
524
|
+
* Whether to show help when no command is specified.
|
|
525
|
+
* @default true
|
|
526
|
+
*/
|
|
527
|
+
showHelpWhenNoCommand?: boolean;
|
|
528
|
+
/**
|
|
529
|
+
* Global notes.
|
|
530
|
+
*/
|
|
531
|
+
notes?: string[];
|
|
532
|
+
/**
|
|
533
|
+
* Global examples.
|
|
534
|
+
*/
|
|
535
|
+
examples?: [string, string][];
|
|
536
|
+
/**
|
|
537
|
+
* Banner
|
|
538
|
+
*/
|
|
539
|
+
banner?: string;
|
|
540
|
+
/**
|
|
541
|
+
* Render type
|
|
542
|
+
*/
|
|
543
|
+
renderer?: "cliffy";
|
|
544
|
+
}
|
|
545
|
+
declare const helpPlugin: ({ command, showHelpWhenNoCommand, notes, examples, banner, renderer, }?: HelpPluginOptions) => Plugin<Clerc<{}>, Clerc<{}>>;
|
|
546
|
+
|
|
547
|
+
declare const notFoundPlugin: () => Plugin<Clerc<{}>, Clerc<{}>>;
|
|
548
|
+
|
|
549
|
+
declare const strictFlagsPlugin: () => Plugin<Clerc<{}>, Clerc<{}>>;
|
|
550
|
+
|
|
551
|
+
interface VersionPluginOptions {
|
|
552
|
+
alias?: string[];
|
|
553
|
+
command?: boolean;
|
|
554
|
+
}
|
|
555
|
+
declare const versionPlugin: ({ alias, command, }?: VersionPluginOptions) => Plugin<Clerc<{}>, Clerc<{}>>;
|
|
556
|
+
|
|
557
|
+
declare const friendlyErrorPlugin: () => Plugin<Clerc<{}>, Clerc<{}>>;
|
|
558
|
+
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import fu from"tty";import ct from"util";import ht from"os";class pt{constructor(){this.listenerMap={},this.wildcardListeners=new Set}on(e,t){return e==="*"?(this.wildcardListeners.add(t),this):(this.listenerMap[e]||(this.listenerMap[e]=new Set),this.listenerMap[e].add(t),this)}emit(e,...t){return this.listenerMap[e]&&(this.wildcardListeners.forEach(D=>D(e,...t)),this.listenerMap[e].forEach(D=>D(...t))),this}off(e,t){var D,n;return e==="**"?(this.listenerMap={},this.wildcardListeners.clear(),this):e==="*"?(t?this.wildcardListeners.delete(t):this.wildcardListeners.clear(),this):(t?(D=this.listenerMap[e])==null||D.delete(t):(n=this.listenerMap[e])==null||n.clear(),this)}}const mt="known-flag",ft="unknown-flag",dt="argument",{stringify:q}=JSON,Ft=/\B([A-Z])/g,Ct=u=>u.replace(Ft,"-$1").toLowerCase(),{hasOwnProperty:gt}=Object.prototype,Z=(u,e)=>gt.call(u,e),Et=u=>Array.isArray(u),Wu=u=>typeof u=="function"?[u,!1]:Et(u)?[u[0],!0]:Wu(u.type),Bt=(u,e)=>u===Boolean?e!=="false":e,xt=(u,e)=>typeof e=="boolean"?e:u===Number&&e===""?Number.NaN:u(e),bt=/[\s.:=]/,At=u=>{const e=`Flag name ${q(u)}`;if(u.length===0)throw new Error(`${e} cannot be empty`);if(u.length===1)throw new Error(`${e} must be longer than a character`);const t=u.match(bt);if(t)throw new Error(`${e} cannot contain ${q(t==null?void 0:t[0])}`)},yt=u=>{const e={},t=(D,n)=>{if(Z(e,D))throw new Error(`Duplicate flags named ${q(D)}`);e[D]=n};for(const D in u){if(!Z(u,D))continue;At(D);const n=u[D],r=[[],...Wu(n),n];t(D,r);const o=Ct(D);if(D!==o&&t(o,r),"alias"in n&&typeof n.alias=="string"){const{alias:l}=n,a=`Flag alias ${q(l)} for flag ${q(D)}`;if(l.length===0)throw new Error(`${a} cannot be empty`);if(l.length>1)throw new Error(`${a} must be a single character`);t(l,r)}}return e},wt=(u,e)=>{const t={};for(const D in u){if(!Z(u,D))continue;const[n,,r,o]=e[D];if(n.length===0&&"default"in o){let{default:l}=o;typeof l=="function"&&(l=l()),t[D]=l}else t[D]=r?n:n.pop()}return t},ru="--",St=/[.:=]/,$t=/^-{1,2}\w/,vt=u=>{if(!$t.test(u))return;const e=!u.startsWith(ru);let t=u.slice(e?1:2),D;const n=t.match(St);if(n){const{index:r}=n;D=t.slice(r+1),t=t.slice(0,r)}return[t,D,e]},Ot=(u,{onFlag:e,onArgument:t})=>{let D;const n=(r,o)=>{if(typeof D!="function")return!0;D(r,o),D=void 0};for(let r=0;r<u.length;r+=1){const o=u[r];if(o===ru){n();const a=u.slice(r+1);t==null||t(a,[r],!0);break}const l=vt(o);if(l){if(n(),!e)continue;const[a,s,d]=l;if(d)for(let C=0;C<a.length;C+=1){n();const m=C===a.length-1;D=e(a[C],m?s:void 0,[r,C+1,m])}else D=e(a,s,[r])}else n(o,[r])&&(t==null||t([o],[r]))}n()},Tt=(u,e)=>{for(const[t,D,n]of e.reverse()){if(D){const r=u[t];let o=r.slice(0,D);if(n||(o+=r.slice(D+1)),o!=="-"){u[t]=o;continue}}u.splice(t,1)}},Rt=(u,e=process.argv.slice(2),{ignore:t}={})=>{const D=[],n=yt(u),r={},o=[];return o[ru]=[],Ot(e,{onFlag(l,a,s){const d=Z(n,l);if(!(t!=null&&t(d?mt:ft,l,a))){if(d){const[C,m]=n[l],h=Bt(m,a),i=(c,p)=>{D.push(s),p&&D.push(p),C.push(xt(m,c||""))};return h===void 0?i:i(h)}Z(r,l)||(r[l]=[]),r[l].push(a===void 0?!0:a),D.push(s)}},onArgument(l,a,s){t!=null&&t(dt,e[a[0]])||(o.push(...l),s?(o[ru]=l,e.splice(a[0])):D.push(a))}}),Tt(e,D),{flags:wt(u,n),unknownFlags:r,_:o}},du=u=>Array.isArray(u)?u:[u],Mt=u=>u.replace(/-([a-z])/g,(e,t)=>t.toUpperCase()),_t=(u,e)=>e.length!==u.length?!1:u.every((t,D)=>t===e[D]),Nu=(u,e)=>e.length>u.length?!1:_t(u.slice(0,e.length),e);class Pu extends Error{constructor(e){super(`Command "${e}" exists.`),this.commandName=e}}class ou extends Error{constructor(e){super(`No such command: ${e}`),this.commandName=e}}class su extends Error{constructor(){super("No command given.")}}class Hu extends Error{constructor(e,t){super(`Command name ${e} conflicts with ${t}. Maybe caused by alias.`),this.n1=e,this.n2=t}}class Gu extends Error{constructor(){super("Name not set.")}}class Yu extends Error{constructor(){super("Description not set.")}}class zu extends Error{constructor(){super("Version not set.")}}class Uu extends Error{constructor(e){super(`Bad name format: ${e}`),this.commandName=e}}const Vu=typeof Deno!="undefined",kt=typeof process!="undefined"&&!Vu,Lt=process.versions.electron&&!process.defaultApp;function qu(u,e,t){if(t.alias){const D=du(t.alias);for(const n of D){if(n in e)throw new Hu(e[n].name,t.name);u.set(typeof n=="symbol"?n:n.split(" "),{...t,__isAlias:!0})}}}function Zu(u){const e=new Map;u[w]&&(e.set(w,u[w]),qu(e,u,u[w]));for(const t of Object.values(u))qu(e,u,t),e.set(t.name.split(" "),t);return e}function Fu(u,e){if(e===w)return u[w];const t=du(e),D=Zu(u);let n,r;return D.forEach((o,l)=>{if(l===w){n=D.get(w),r=w;return}Nu(t,l)&&(!r||r===w||l.length>r.length)&&(n=o,r=l)}),n}function Ju(u,e,t=1/0){const D=e===""?[]:Array.isArray(e)?e:e.split(" ");return Object.values(u).filter(n=>{const r=n.name.split(" ");return Nu(r,D)&&r.length-D.length<=t})}const It=u=>Ju(u,"",1);function Ku(u){const e=[];for(const t of u){if(t.startsWith("-"))break;e.push(t)}return e}const Cu=()=>kt?process.argv.slice(Lt?1:2):Vu?Deno.args:[];function Qu(u){const e={pre:[],normal:[],post:[]};for(const D of u){const n=typeof D=="object"?D:{fn:D},{enforce:r,fn:o}=n;r==="post"||r==="pre"?e[r].push(o):e.normal.push(o)}const t=[...e.pre,...e.normal,...e.post];return D=>{return n(0);function n(r){const o=t[r];return o(D(),n.bind(null,r+1))}}}const Xu=u=>typeof u=="string"&&(u.startsWith(" ")||u.endsWith(" ")),ue=(u,e)=>e?`[${u}]`:`<${u}>`,jt="<Root>",G=u=>Array.isArray(u)?u.join(" "):typeof u=="string"?u:jt,{stringify:Y}=JSON;function gu(u){const e=[];let t,D;for(const n of u){if(D)throw new Error(`Invalid parameter: Spread parameter ${Y(D)} must be last`);const r=n[0],o=n[n.length-1];let l;if(r==="<"&&o===">"&&(l=!0,t))throw new Error(`Invalid parameter: Required parameter ${Y(n)} cannot come after optional parameter ${Y(t)}`);if(r==="["&&o==="]"&&(l=!1,t=n),l===void 0)throw new Error(`Invalid parameter: ${Y(n)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=n.slice(1,-1);const s=a.slice(-3)==="...";s&&(D=n,a=a.slice(0,-3)),e.push({name:a,required:l,spread:s})}return e}function Eu(u,e,t){for(let D=0;D<e.length;D+=1){const{name:n,required:r,spread:o}=e[D],l=Mt(n);if(l in u)return new Error(`Invalid parameter: ${Y(n)} is used more than once.`);const a=o?t.slice(D):t[D];if(o&&(D=e.length),r&&(!a||o&&a.length===0))return new Error(`Error: Missing required parameter ${Y(n)}`);u[l]=a}}var Bu=(u,e,t)=>{if(!e.has(u))throw TypeError("Cannot "+t)},B=(u,e,t)=>(Bu(u,e,"read from private field"),t?t.call(u):e.get(u)),T=(u,e,t)=>{if(e.has(u))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(u):e.set(u,t)},j=(u,e,t,D)=>(Bu(u,e,"write to private field"),D?D.call(u,t):e.set(u,t),t),Wt=(u,e,t)=>(Bu(u,e,"access private method"),t),W,N,P,J,K,iu,z,au,xu,ee,bu,te,Au,De;const w=Symbol("Root"),ne=class{constructor(u,e,t){T(this,xu),T(this,bu),T(this,Au),T(this,W,""),T(this,N,""),T(this,P,""),T(this,J,[]),T(this,K,{}),T(this,iu,new pt),T(this,z,new Set),T(this,au,void 0),j(this,W,u||B(this,W)),j(this,N,e||B(this,N)),j(this,P,t||B(this,P))}get _name(){return B(this,W)}get _description(){return B(this,N)}get _version(){return B(this,P)}get _inspectors(){return B(this,J)}get _commands(){return B(this,K)}static create(u,e,t){return new ne(u,e,t)}name(u){return j(this,W,u),this}description(u){return j(this,N,u),this}version(u){return j(this,P,u),this}command(u,e,t={}){const D=(s=>!(typeof s=="string"||s===w))(u),n=D?u.name:u;if(Xu(n))throw new Uu(n);const{handler:r=void 0,...o}=D?u:{name:n,description:e,...t},l=[o.name],a=o.alias?du(o.alias):[];o.alias&&l.push(...a);for(const s of l)if(B(this,z).has(s))throw new Pu(G(s));return B(this,K)[n]=o,B(this,z).add(o.name),a.forEach(s=>B(this,z).add(s)),D&&r&&this.on(u.name,r),this}on(u,e){return B(this,iu).on(u,e),this}use(u){return u.setup(this)}inspector(u){return B(this,J).push(u),this}parse(u=Cu()){const{argv:e,run:t}=Array.isArray(u)?{argv:u,run:!0}:{argv:Cu(),...u};return j(this,au,e),Wt(this,Au,De).call(this),t&&this.runMatchedCommand(),this}runMatchedCommand(){const u=B(this,au);if(!u)throw new Error("cli.parse() must be called.");const e=Ku(u),t=e.join(" "),D=()=>Fu(B(this,K),e),n=[],r=()=>{n.length=0;const a=D(),s=!!a,d=Rt((a==null?void 0:a.flags)||{},[...u]),{_:C,flags:m,unknownFlags:h}=d;let i=!s||a.name===w?C:C.slice(a.name.split(" ").length),c=(a==null?void 0:a.parameters)||[];const p=c.indexOf("--"),F=c.slice(p+1)||[],f=Object.create(null);if(p>-1&&F.length>0){c=c.slice(0,p);const g=C["--"];i=i.slice(0,-g.length||void 0),n.push(Eu(f,gu(c),i)),n.push(Eu(f,gu(F),g))}else n.push(Eu(f,gu(c),i));const E={...m,...h};return{name:a==null?void 0:a.name,called:e.length===0&&(a==null?void 0:a.name)?w:t,resolved:s,hasRootOrAlias:B(this,xu,ee),hasRoot:B(this,bu,te),raw:{...d,parameters:i,mergedFlags:E},parameters:f,flags:m,unknownFlags:h,cli:this}},o={enforce:"post",fn:()=>{const a=D(),s=r(),d=n.filter(Boolean);if(d.length>0)throw d[0];if(!a)throw t?new ou(t):new su;B(this,iu).emit(a.name,s)}},l=[...B(this,J),o];return Qu(l)(r),this}};let Nt=ne;W=new WeakMap,N=new WeakMap,P=new WeakMap,J=new WeakMap,K=new WeakMap,iu=new WeakMap,z=new WeakMap,au=new WeakMap,xu=new WeakSet,ee=function(){return B(this,z).has(w)},bu=new WeakSet,te=function(){return Object.prototype.hasOwnProperty.call(this._commands,w)},Au=new WeakSet,De=function(){if(!B(this,W))throw new Gu;if(!B(this,N))throw new Yu;if(!B(this,P))throw new zu};const H=u=>u,Pt=(u,e,t)=>t,Ht=(u,e)=>e,Gt=(u,e)=>({...u,handler:e}),Yt=u=>`
|
|
2
|
+
${u})
|
|
3
|
+
cmd+="__${u}"
|
|
4
|
+
;;`,zt=u=>{const{cli:e}=u,{_name:t,_commands:D}=e;return`_${t}() {
|
|
5
|
+
local i cur prev opts cmds
|
|
6
|
+
COMPREPLY=()
|
|
7
|
+
cur="\${COMP_WORDS[COMP_CWORD]}"
|
|
8
|
+
prev="\${COMP_WORDS[COMP_CWORD-1]}"
|
|
9
|
+
cmd=""
|
|
10
|
+
opts=""
|
|
11
|
+
|
|
12
|
+
for i in \${COMP_WORDS[@]}
|
|
13
|
+
do
|
|
14
|
+
case "\${i}" in
|
|
15
|
+
"$1")
|
|
16
|
+
cmd="${t}"
|
|
17
|
+
;;
|
|
18
|
+
${Object.keys(D).map(Yt).join("")}
|
|
19
|
+
*)
|
|
20
|
+
;;
|
|
21
|
+
esac
|
|
22
|
+
done
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
complete -F _${t} -o bashdefault -o default ${t}
|
|
26
|
+
`},re=u=>u.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`),oe=u=>u.length<=1?`-${u}`:`--${re(u)}`,se="(No Description)",Ut=u=>`[CompletionResult]::new('${u.name}', '${u.name}', [CompletionResultType]::ParameterValue, '${u.description}')`,Vt=u=>Object.entries(u.flags||{}).map(([e,t])=>{const D=[`[CompletionResult]::new('${oe(e)}', '${re(e)}', [CompletionResultType]::ParameterName, '${u.flags[e].description||se}')`];return t!=null&&t.alias&&D.push(`[CompletionResult]::new('${oe(t.alias)}', '${t.alias}', [CompletionResultType]::ParameterName, '${u.flags[e].description||se}')`),D.join(`
|
|
27
|
+
`)}).join(`
|
|
28
|
+
`),qt=u=>{const{cli:e}=u,{_name:t,_commands:D}=e;return`using namespace System.Management.Automation
|
|
29
|
+
using namespace System.Management.Automation.Language
|
|
30
|
+
|
|
31
|
+
Register-ArgumentCompleter -Native -CommandName '${t}' -ScriptBlock {
|
|
32
|
+
param($wordToComplete, $commandAst, $cursorPosition)
|
|
33
|
+
|
|
34
|
+
$commandElements = $commandAst.CommandElements
|
|
35
|
+
$command = @(
|
|
36
|
+
'${t}'
|
|
37
|
+
for ($i = 1; $i -lt $commandElements.Count; $i++) {
|
|
38
|
+
$element = $commandElements[$i]
|
|
39
|
+
if ($element -isnot [StringConstantExpressionAst] -or
|
|
40
|
+
$element.StringConstantType -ne [StringConstantType]::BareWord -or
|
|
41
|
+
$element.Value.StartsWith('-') -or
|
|
42
|
+
$element.Value -eq $wordToComplete) {
|
|
43
|
+
break
|
|
44
|
+
}
|
|
45
|
+
$element.Value
|
|
46
|
+
}) -join ';'
|
|
47
|
+
|
|
48
|
+
$completions = @(switch ($command) {
|
|
49
|
+
'${t}' {
|
|
50
|
+
${Object.entries(D).map(([n,r])=>Ut(r)).join(`
|
|
51
|
+
`)}
|
|
52
|
+
break
|
|
53
|
+
}
|
|
54
|
+
${Object.entries(D).map(([n,r])=>`'${t};${n.split(" ").join(";")}' {
|
|
55
|
+
${Vt(r)}
|
|
56
|
+
break
|
|
57
|
+
}`).join(`
|
|
58
|
+
`)}
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
|
|
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
|
+
`).reduce(function(t,D){return Fe(D)>t?Fe(D):t},0)}function Q(u,e){return Array(e+1).join(u)}function cD(u,e,t,D){let n=M(u);if(e+1>=n){let r=e-n;switch(D){case"right":{u=Q(t,r)+u;break}case"center":{let o=Math.ceil(r/2),l=r-o;u=Q(t,l)+u+Q(t,o);break}default:{u=u+Q(t,r);break}}}return u}let U={};function X(u,e,t){e="\x1B["+e+"m",t="\x1B["+t+"m",U[e]={set:u,to:!0},U[t]={set:u,to:!1},U[u]={on:e,off:t}}X("bold",1,22),X("italics",3,23),X("underline",4,24),X("inverse",7,27),X("strikethrough",9,29);function Ce(u,e){let t=e[1]?parseInt(e[1].split(";")[0]):0;if(t>=30&&t<=39||t>=90&&t<=97){u.lastForegroundAdded=e[0];return}if(t>=40&&t<=49||t>=100&&t<=107){u.lastBackgroundAdded=e[0];return}if(t===0){for(let n in u)Object.prototype.hasOwnProperty.call(u,n)&&delete u[n];return}let D=U[e[0]];D&&(u[D.set]=D.to)}function hD(u){let e=lu(!0),t=e.exec(u),D={};for(;t!==null;)Ce(D,t),t=e.exec(u);return D}function ge(u,e){let t=u.lastBackgroundAdded,D=u.lastForegroundAdded;return delete u.lastBackgroundAdded,delete u.lastForegroundAdded,Object.keys(u).forEach(function(n){u[n]&&(e+=U[n].off)}),t&&t!="\x1B[49m"&&(e+="\x1B[49m"),D&&D!="\x1B[39m"&&(e+="\x1B[39m"),e}function pD(u,e){let t=u.lastBackgroundAdded,D=u.lastForegroundAdded;return delete u.lastBackgroundAdded,delete u.lastForegroundAdded,Object.keys(u).forEach(function(n){u[n]&&(e=U[n].on+e)}),t&&t!="\x1B[49m"&&(e=t+e),D&&D!="\x1B[39m"&&(e=D+e),e}function mD(u,e){if(u.length===M(u))return u.substr(0,e);for(;M(u)>e;)u=u.slice(0,-1);return u}function fD(u,e){let t=lu(!0),D=u.split(lu()),n=0,r=0,o="",l,a={};for(;r<e;){l=t.exec(u);let s=D[n];if(n++,r+M(s)>e&&(s=mD(s,e-r)),o+=s,r+=M(s),r<e){if(!l)break;o+=l[0],Ce(a,l)}}return ge(a,o)}function dD(u,e,t){return t=t||"\u2026",M(u)<=e?u:(e-=M(t),fD(u,e)+t)}function FD(){return{chars:{top:"\u2500","top-mid":"\u252C","top-left":"\u250C","top-right":"\u2510",bottom:"\u2500","bottom-mid":"\u2534","bottom-left":"\u2514","bottom-right":"\u2518",left:"\u2502","left-mid":"\u251C",mid:"\u2500","mid-mid":"\u253C",right:"\u2502","right-mid":"\u2524",middle:"\u2502"},truncate:"\u2026",colWidths:[],rowHeights:[],colAligns:[],rowAligns:[],style:{"padding-left":1,"padding-right":1,head:["red"],border:["grey"],compact:!1},head:[]}}function CD(u,e){u=u||{},e=e||FD();let t=Object.assign({},e,u);return t.chars=Object.assign({},e.chars,u.chars),t.style=Object.assign({},e.style,u.style),t}function gD(u,e){let t=[],D=e.split(/(\s+)/g),n=[],r=0,o;for(let l=0;l<D.length;l+=2){let a=D[l],s=r+M(a);r>0&&o&&(s+=o.length),s>u?(r!==0&&t.push(n.join("")),n=[a],r=M(a)):(n.push(o||"",a),r=s),o=D[l+1]}return r&&t.push(n.join("")),t}function ED(u,e){let t=[],D="";function n(o,l){for(D.length&&l&&(D+=l),D+=o;D.length>u;)t.push(D.slice(0,u)),D=D.slice(u)}let r=e.split(/(\s+)/g);for(let o=0;o<r.length;o+=2)n(r[o],o&&r[o-1]);return D.length&&t.push(D),t}function BD(u,e,t=!0){let D=[];e=e.split(`
|
|
65
|
+
`);const n=t?gD:ED;for(let r=0;r<e.length;r++)D.push.apply(D,n(u,e[r]));return D}function xD(u){let e={},t=[];for(let D=0;D<u.length;D++){let n=pD(e,u[D]);e=hD(n);let r=Object.assign({},e);t.push(ge(r,n))}return t}function bD(u,e){const t="\x1B]",D="\x07",n=";";return[t,"8",n,n,u||e,D,e,t,"8",n,n,D].join("")}var Ee={strlen:M,repeat:Q,pad:cD,truncate:dD,mergeOptions:CD,wordWrap:BD,colorizeLines:xD,hyperlink:bD},Be={exports:{}},cu={exports:{}},xe={exports:{}},be={exports:{}},Ae={exports:{}},ye;function AD(){return ye||(ye=1,function(u){var e={};u.exports=e;var t={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(t).forEach(function(D){var n=t[D],r=e[D]=[];r.open="\x1B["+n[0]+"m",r.close="\x1B["+n[1]+"m"})}(Ae)),Ae.exports}var we,Se;function yD(){return Se||(Se=1,we=function(u,e){e=e||process.argv;var t=e.indexOf("--"),D=/^-{1,2}/.test(u)?"":"--",n=e.indexOf(D+u);return n!==-1&&(t===-1?!0:n<t)}),we}var vu,$e;function wD(){if($e)return vu;$e=1;var u=ht,e=yD(),t=process.env,D=void 0;e("no-color")||e("no-colors")||e("color=false")?D=!1:(e("color")||e("colors")||e("color=true")||e("color=always"))&&(D=!0),"FORCE_COLOR"in t&&(D=t.FORCE_COLOR.length===0||parseInt(t.FORCE_COLOR,10)!==0);function n(l){return l===0?!1:{level:l,hasBasic:!0,has256:l>=2,has16m:l>=3}}function r(l){if(D===!1)return 0;if(e("color=16m")||e("color=full")||e("color=truecolor"))return 3;if(e("color=256"))return 2;if(l&&!l.isTTY&&D!==!0)return 0;var a=D?1:0;if(process.platform==="win32"){var s=u.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(s[0])>=10&&Number(s[2])>=10586?Number(s[2])>=14931?3:2:1}if("CI"in t)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(C){return C in t})||t.CI_NAME==="codeship"?1:a;if("TEAMCITY_VERSION"in t)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(t.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in t){var d=parseInt((t.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(t.TERM_PROGRAM){case"iTerm.app":return d>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(t.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(t.TERM)||"COLORTERM"in t?1:(t.TERM,a)}function o(l){var a=r(l);return n(a)}return vu={supportsColor:o,stdout:o(process.stdout),stderr:o(process.stderr)},vu}var ve={exports:{}},Oe;function SD(){return Oe||(Oe=1,function(u){u.exports=function(e,t){var D="";e=e||"Run the trap, drop the bass",e=e.split("");var n={a:["@","\u0104","\u023A","\u0245","\u0394","\u039B","\u0414"],b:["\xDF","\u0181","\u0243","\u026E","\u03B2","\u0E3F"],c:["\xA9","\u023B","\u03FE"],d:["\xD0","\u018A","\u0500","\u0501","\u0502","\u0503"],e:["\xCB","\u0115","\u018E","\u0258","\u03A3","\u03BE","\u04BC","\u0A6C"],f:["\u04FA"],g:["\u0262"],h:["\u0126","\u0195","\u04A2","\u04BA","\u04C7","\u050A"],i:["\u0F0F"],j:["\u0134"],k:["\u0138","\u04A0","\u04C3","\u051E"],l:["\u0139"],m:["\u028D","\u04CD","\u04CE","\u0520","\u0521","\u0D69"],n:["\xD1","\u014B","\u019D","\u0376","\u03A0","\u048A"],o:["\xD8","\xF5","\xF8","\u01FE","\u0298","\u047A","\u05DD","\u06DD","\u0E4F"],p:["\u01F7","\u048E"],q:["\u09CD"],r:["\xAE","\u01A6","\u0210","\u024C","\u0280","\u042F"],s:["\xA7","\u03DE","\u03DF","\u03E8"],t:["\u0141","\u0166","\u0373"],u:["\u01B1","\u054D"],v:["\u05D8"],w:["\u0428","\u0460","\u047C","\u0D70"],x:["\u04B2","\u04FE","\u04FC","\u04FD"],y:["\xA5","\u04B0","\u04CB"],z:["\u01B5","\u0240"]};return e.forEach(function(r){r=r.toLowerCase();var o=n[r]||[" "],l=Math.floor(Math.random()*o.length);typeof n[r]!="undefined"?D+=n[r][l]:D+=r}),D}}(ve)),ve.exports}var Te={exports:{}},Re;function $D(){return Re||(Re=1,function(u){u.exports=function(e,t){e=e||" he is here ";var D={up:["\u030D","\u030E","\u0304","\u0305","\u033F","\u0311","\u0306","\u0310","\u0352","\u0357","\u0351","\u0307","\u0308","\u030A","\u0342","\u0313","\u0308","\u034A","\u034B","\u034C","\u0303","\u0302","\u030C","\u0350","\u0300","\u0301","\u030B","\u030F","\u0312","\u0313","\u0314","\u033D","\u0309","\u0363","\u0364","\u0365","\u0366","\u0367","\u0368","\u0369","\u036A","\u036B","\u036C","\u036D","\u036E","\u036F","\u033E","\u035B","\u0346","\u031A"],down:["\u0316","\u0317","\u0318","\u0319","\u031C","\u031D","\u031E","\u031F","\u0320","\u0324","\u0325","\u0326","\u0329","\u032A","\u032B","\u032C","\u032D","\u032E","\u032F","\u0330","\u0331","\u0332","\u0333","\u0339","\u033A","\u033B","\u033C","\u0345","\u0347","\u0348","\u0349","\u034D","\u034E","\u0353","\u0354","\u0355","\u0356","\u0359","\u035A","\u0323"],mid:["\u0315","\u031B","\u0300","\u0301","\u0358","\u0321","\u0322","\u0327","\u0328","\u0334","\u0335","\u0336","\u035C","\u035D","\u035E","\u035F","\u0360","\u0362","\u0338","\u0337","\u0361"," \u0489"]},n=[].concat(D.up,D.down,D.mid);function r(a){var s=Math.floor(Math.random()*a);return s}function o(a){var s=!1;return n.filter(function(d){s=d===a}),s}function l(a,s){var d="",C,m;s=s||{},s.up=typeof s.up!="undefined"?s.up:!0,s.mid=typeof s.mid!="undefined"?s.mid:!0,s.down=typeof s.down!="undefined"?s.down:!0,s.size=typeof s.size!="undefined"?s.size:"maxi",a=a.split("");for(m in a)if(!o(m)){switch(d=d+a[m],C={up:0,down:0,mid:0},s.size){case"mini":C.up=r(8),C.mid=r(2),C.down=r(8);break;case"maxi":C.up=r(16)+3,C.mid=r(4)+1,C.down=r(64)+3;break;default:C.up=r(8)+1,C.mid=r(6)/2,C.down=r(8)+1;break}var h=["up","mid","down"];for(var i in h)for(var c=h[i],p=0;p<=C[c];p++)s[c]&&(d=d+D[c][r(D[c].length)])}return d}return l(e,t)}}(Te)),Te.exports}var Me={exports:{}},_e;function vD(){return _e||(_e=1,function(u){u.exports=function(e){return function(t,D,n){if(t===" ")return t;switch(D%3){case 0:return e.red(t);case 1:return e.white(t);case 2:return e.blue(t)}}}}(Me)),Me.exports}var ke={exports:{}},Le;function OD(){return Le||(Le=1,function(u){u.exports=function(e){return function(t,D,n){return D%2===0?t:e.inverse(t)}}}(ke)),ke.exports}var Ie={exports:{}},je;function TD(){return je||(je=1,function(u){u.exports=function(e){var t=["red","yellow","green","blue","magenta"];return function(D,n,r){return D===" "?D:e[t[n++%t.length]](D)}}}(Ie)),Ie.exports}var We={exports:{}},Ne;function RD(){return Ne||(Ne=1,function(u){u.exports=function(e){var t=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(D,n,r){return D===" "?D:e[t[Math.round(Math.random()*(t.length-2))]](D)}}}(We)),We.exports}var Pe;function MD(){return Pe||(Pe=1,function(u){var e={};u.exports=e,e.themes={};var t=ct,D=e.styles=AD(),n=Object.defineProperties,r=new RegExp(/[\r\n]+/g);e.supportsColor=wD().supportsColor,typeof e.enabled=="undefined"&&(e.enabled=e.supportsColor()!==!1),e.enable=function(){e.enabled=!0},e.disable=function(){e.enabled=!1},e.stripColors=e.strip=function(c){return(""+c).replace(/\x1B\[\d+m/g,"")},e.stylize=function(c,p){if(!e.enabled)return c+"";var F=D[p];return!F&&p in e?e[p](c):F.open+c+F.close};var o=/[|\\{}()[\]^$+*?.]/g,l=function(c){if(typeof c!="string")throw new TypeError("Expected a string");return c.replace(o,"\\$&")};function a(c){var p=function F(){return C.apply(F,arguments)};return p._styles=c,p.__proto__=d,p}var s=function(){var c={};return D.grey=D.gray,Object.keys(D).forEach(function(p){D[p].closeRe=new RegExp(l(D[p].close),"g"),c[p]={get:function(){return a(this._styles.concat(p))}}}),c}(),d=n(function(){},s);function C(){var c=Array.prototype.slice.call(arguments),p=c.map(function(y){return y!=null&&y.constructor===String?y:t.inspect(y)}).join(" ");if(!e.enabled||!p)return p;for(var F=p.indexOf(`
|
|
66
|
+
`)!=-1,f=this._styles,E=f.length;E--;){var g=D[f[E]];p=g.open+p.replace(g.closeRe,g.open)+g.close,F&&(p=p.replace(r,function(y){return g.close+y+g.open}))}return p}e.setTheme=function(c){if(typeof c=="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var p in c)(function(F){e[F]=function(f){if(typeof c[F]=="object"){var E=f;for(var g in c[F])E=e[c[F][g]](E);return E}return e[c[F]](f)}})(p)};function m(){var c={};return Object.keys(s).forEach(function(p){c[p]={get:function(){return a([p])}}}),c}var h=function(c,p){var F=p.split("");return F=F.map(c),F.join("")};e.trap=SD(),e.zalgo=$D(),e.maps={},e.maps.america=vD()(e),e.maps.zebra=OD()(e),e.maps.rainbow=TD()(e),e.maps.random=RD()(e);for(var i in e.maps)(function(c){e[c]=function(p){return h(e.maps[c],p)}})(i);n(e,m())}(be)),be.exports}var He;function _D(){return He||(He=1,function(u){var e=MD();u.exports=e}(xe)),xe.exports}const{info:kD,debug:Ge}=wu,v=Ee;class eu{constructor(e){this.setOptions(e),this.x=null,this.y=null}setOptions(e){["boolean","number","string"].indexOf(typeof e)!==-1&&(e={content:""+e}),e=e||{},this.options=e;let t=e.content;if(["boolean","number","string"].indexOf(typeof t)!==-1)this.content=String(t);else if(!t)this.content=this.options.href||"";else throw new Error("Content needs to be a primitive, got: "+typeof t);this.colSpan=e.colSpan||1,this.rowSpan=e.rowSpan||1,this.options.href&&Object.defineProperty(this,"href",{get(){return this.options.href}})}mergeTableOptions(e,t){this.cells=t;let D=this.options.chars||{},n=e.chars,r=this.chars={};ID.forEach(function(a){Ru(D,n,a,r)}),this.truncate=this.options.truncate||e.truncate;let o=this.options.style=this.options.style||{},l=e.style;Ru(o,l,"padding-left",this),Ru(o,l,"padding-right",this),this.head=o.head||l.head,this.border=o.border||l.border,this.fixedWidth=e.colWidths[this.x],this.lines=this.computeLines(e),this.desiredWidth=v.strlen(this.content)+this.paddingLeft+this.paddingRight,this.desiredHeight=this.lines.length}computeLines(e){const t=e.wordWrap||e.textWrap,{wordWrap:D=t}=this.options;if(this.fixedWidth&&D){if(this.fixedWidth-=this.paddingLeft+this.paddingRight,this.colSpan){let o=1;for(;o<this.colSpan;)this.fixedWidth+=e.colWidths[this.x+o],o++}const{wrapOnWordBoundary:n=!0}=e,{wrapOnWordBoundary:r=n}=this.options;return this.wrapLines(v.wordWrap(this.fixedWidth,this.content,r))}return this.wrapLines(this.content.split(`
|
|
67
|
+
`))}wrapLines(e){const t=v.colorizeLines(e);return this.href?t.map(D=>v.hyperlink(this.href,D)):t}init(e){let t=this.x,D=this.y;this.widths=e.colWidths.slice(t,t+this.colSpan),this.heights=e.rowHeights.slice(D,D+this.rowSpan),this.width=this.widths.reduce(ze,-1),this.height=this.heights.reduce(ze,-1),this.hAlign=this.options.hAlign||e.colAligns[t],this.vAlign=this.options.vAlign||e.rowAligns[D],this.drawRight=t+this.colSpan==e.colWidths.length}draw(e,t){if(e=="top")return this.drawTop(this.drawRight);if(e=="bottom")return this.drawBottom(this.drawRight);let D=v.truncate(this.content,10,this.truncate);e||kD(`${this.y}-${this.x}: ${this.rowSpan-e}x${this.colSpan} Cell ${D}`);let n=Math.max(this.height-this.lines.length,0),r;switch(this.vAlign){case"center":r=Math.ceil(n/2);break;case"bottom":r=n;break;default:r=0}if(e<r||e>=r+this.lines.length)return this.drawEmpty(this.drawRight,t);let o=this.lines.length>this.height&&e+1>=this.height;return this.drawLine(e-r,this.drawRight,o,t)}drawTop(e){let t=[];return this.cells?this.widths.forEach(function(D,n){t.push(this._topLeftChar(n)),t.push(v.repeat(this.chars[this.y==0?"top":"mid"],D))},this):(t.push(this._topLeftChar(0)),t.push(v.repeat(this.chars[this.y==0?"top":"mid"],this.width))),e&&t.push(this.chars[this.y==0?"topRight":"rightMid"]),this.wrapWithStyleColors("border",t.join(""))}_topLeftChar(e){let t=this.x+e,D;if(this.y==0)D=t==0?"topLeft":e==0?"topMid":"top";else if(t==0)D="leftMid";else if(D=e==0?"midMid":"bottomMid",this.cells&&(this.cells[this.y-1][t]instanceof eu.ColSpanCell&&(D=e==0?"topMid":"mid"),e==0)){let n=1;for(;this.cells[this.y][t-n]instanceof eu.ColSpanCell;)n++;this.cells[this.y][t-n]instanceof eu.RowSpanCell&&(D="leftMid")}return this.chars[D]}wrapWithStyleColors(e,t){if(this[e]&&this[e].length)try{let D=_D();for(let n=this[e].length-1;n>=0;n--)D=D[this[e][n]];return D(t)}catch(D){return t}else return t}drawLine(e,t,D,n){let r=this.chars[this.x==0?"left":"middle"];if(this.x&&n&&this.cells){let m=this.cells[this.y+n][this.x-1];for(;m instanceof Ou;)m=this.cells[m.y][m.x-1];m instanceof Tu||(r=this.chars.rightMid)}let o=v.repeat(" ",this.paddingLeft),l=t?this.chars.right:"",a=v.repeat(" ",this.paddingRight),s=this.lines[e],d=this.width-(this.paddingLeft+this.paddingRight);D&&(s+=this.truncate||"\u2026");let C=v.truncate(s,d,this.truncate);return C=v.pad(C,d," ",this.hAlign),C=o+C+a,this.stylizeLine(r,C,l)}stylizeLine(e,t,D){return e=this.wrapWithStyleColors("border",e),D=this.wrapWithStyleColors("border",D),this.y===0&&(t=this.wrapWithStyleColors("head",t)),e+t+D}drawBottom(e){let t=this.chars[this.x==0?"bottomLeft":"bottomMid"],D=v.repeat(this.chars.bottom,this.width),n=e?this.chars.bottomRight:"";return this.wrapWithStyleColors("border",t+D+n)}drawEmpty(e,t){let D=this.chars[this.x==0?"left":"middle"];if(this.x&&t&&this.cells){let o=this.cells[this.y+t][this.x-1];for(;o instanceof Ou;)o=this.cells[o.y][o.x-1];o instanceof Tu||(D=this.chars.rightMid)}let n=e?this.chars.right:"",r=v.repeat(" ",this.width);return this.stylizeLine(D,r,n)}}class Ou{constructor(){}draw(e){return typeof e=="number"&&Ge(`${this.y}-${this.x}: 1x1 ColSpanCell`),""}init(){}mergeTableOptions(){}}class Tu{constructor(e){this.originalCell=e}init(e){let t=this.y,D=this.originalCell.y;this.cellOffset=t-D,this.offset=LD(e.rowHeights,D,this.cellOffset)}draw(e){return e=="top"?this.originalCell.draw(this.offset,this.cellOffset):e=="bottom"?this.originalCell.draw("bottom"):(Ge(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`),this.originalCell.draw(this.offset+1+e))}mergeTableOptions(){}}function Ye(...u){return u.filter(e=>e!=null).shift()}function Ru(u,e,t,D){let n=t.split("-");n.length>1?(n[1]=n[1].charAt(0).toUpperCase()+n[1].substr(1),n=n.join(""),D[n]=Ye(u[n],u[t],e[n],e[t])):D[t]=Ye(u[t],e[t])}function LD(u,e,t){let D=u[e];for(let n=1;n<t;n++)D+=1+u[e+n];return D}function ze(u,e){return u+e+1}let ID=["top","top-mid","top-left","top-right","bottom","bottom-mid","bottom-left","bottom-right","left","left-mid","mid","mid-mid","right","right-mid","middle"];cu.exports=eu,cu.exports.ColSpanCell=Ou,cu.exports.RowSpanCell=Tu;const{warn:jD,debug:WD}=wu,Mu=cu.exports,{ColSpanCell:ND,RowSpanCell:PD}=Mu;(function(){function u(h,i){return h[i]>0?u(h,i+1):i}function e(h){let i={};h.forEach(function(c,p){let F=0;c.forEach(function(f){f.y=p,f.x=p?u(i,F):F;const E=f.rowSpan||1,g=f.colSpan||1;if(E>1)for(let y=0;y<g;y++)i[f.x+y]=E;F=f.x+g}),Object.keys(i).forEach(f=>{i[f]--,i[f]<1&&delete i[f]})})}function t(h){let i=0;return h.forEach(function(c){c.forEach(function(p){i=Math.max(i,p.x+(p.colSpan||1))})}),i}function D(h){return h.length}function n(h,i){let c=h.y,p=h.y-1+(h.rowSpan||1),F=i.y,f=i.y-1+(i.rowSpan||1),E=!(c>f||F>p),g=h.x,y=h.x-1+(h.colSpan||1),tu=i.x,Du=i.x-1+(i.colSpan||1),I=!(g>Du||tu>y);return E&&I}function r(h,i,c){let p=Math.min(h.length-1,c),F={x:i,y:c};for(let f=0;f<=p;f++){let E=h[f];for(let g=0;g<E.length;g++)if(n(F,E[g]))return!0}return!1}function o(h,i,c,p){for(let F=c;F<p;F++)if(r(h,F,i))return!1;return!0}function l(h){h.forEach(function(i,c){i.forEach(function(p){for(let F=1;F<p.rowSpan;F++){let f=new PD(p);f.x=p.x,f.y=p.y+F,f.colSpan=p.colSpan,s(f,h[c+F])}})})}function a(h){for(let i=h.length-1;i>=0;i--){let c=h[i];for(let p=0;p<c.length;p++){let F=c[p];for(let f=1;f<F.colSpan;f++){let E=new ND;E.x=F.x+f,E.y=F.y,c.splice(p+1,0,E)}}}}function s(h,i){let c=0;for(;c<i.length&&i[c].x<h.x;)c++;i.splice(c,0,h)}function d(h){let i=D(h),c=t(h);WD(`Max rows: ${i}; Max cols: ${c}`);for(let p=0;p<i;p++)for(let F=0;F<c;F++)if(!r(h,F,p)){let f={x:F,y:p,colSpan:1,rowSpan:1};for(F++;F<c&&!r(h,F,p);)f.colSpan++,F++;let E=p+1;for(;E<i&&o(h,E,f.x,f.x+f.colSpan);)f.rowSpan++,E++;let g=new Mu(f);g.x=f.x,g.y=f.y,jD(`Missing cell at ${g.y}-${g.x}.`),s(g,h[p])}}function C(h){return h.map(function(i){if(!Array.isArray(i)){let c=Object.keys(i)[0];i=i[c],Array.isArray(i)?(i=i.slice(),i.unshift(c)):i=[c,i]}return i.map(function(c){return new Mu(c)})})}function m(h){let i=C(h);return e(i),d(i),l(i),a(i),i}Be.exports={makeTableLayout:m,layoutTable:e,addRowSpanCells:l,maxWidth:t,fillInTable:d,computeWidths:Ue("colSpan","desiredWidth","x",1),computeHeights:Ue("rowSpan","desiredHeight","y",1)}})();function Ue(u,e,t,D){return function(n,r){let o=[],l=[],a={};r.forEach(function(s){s.forEach(function(d){(d[u]||1)>1?l.push(d):o[d[t]]=Math.max(o[d[t]]||0,d[e]||0,D)})}),n.forEach(function(s,d){typeof s=="number"&&(o[d]=s)});for(let s=l.length-1;s>=0;s--){let d=l[s],C=d[u],m=d[t],h=o[m],i=typeof n[m]=="number"?0:1;if(typeof h=="number")for(let c=1;c<C;c++)h+=1+o[m+c],typeof n[m+c]!="number"&&i++;else h=e==="desiredWidth"?d.desiredWidth-1:1,(!a[m]||a[m]<h)&&(a[m]=h);if(d[e]>h){let c=0;for(;i>0&&d[e]>h;){if(typeof n[m+c]!="number"){let p=Math.round((d[e]-h)/i);h+=p,o[m+c]+=p,i--}c++}}}Object.assign(n,o,a);for(let s=0;s<n.length;s++)n[s]=Math.max(D,n[s]||0)}}const _=wu,HD=Ee,_u=Be.exports;class Ve extends Array{constructor(e){super();const t=HD.mergeOptions(e);if(Object.defineProperty(this,"options",{value:t,enumerable:t.debug}),t.debug){switch(typeof t.debug){case"boolean":_.setDebugLevel(_.WARN);break;case"number":_.setDebugLevel(t.debug);break;case"string":_.setDebugLevel(parseInt(t.debug,10));break;default:_.setDebugLevel(_.WARN),_.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof t.debug}`)}Object.defineProperty(this,"messages",{get(){return _.debugMessages()}})}}toString(){let e=this,t=this.options.head&&this.options.head.length;t?(e=[this.options.head],this.length&&e.push.apply(e,this)):this.options.style.head=[];let D=_u.makeTableLayout(e);D.forEach(function(r){r.forEach(function(o){o.mergeTableOptions(this.options,D)},this)},this),_u.computeWidths(this.options.colWidths,D),_u.computeHeights(this.options.rowHeights,D),D.forEach(function(r){r.forEach(function(o){o.init(this.options)},this)},this);let n=[];for(let r=0;r<D.length;r++){let o=D[r],l=this.options.rowHeights[r];(r===0||!this.options.style.compact||r==1&&t)&&ku(o,"top",n);for(let a=0;a<l;a++)ku(o,a,n);r+1==D.length&&ku(o,"bottom",n)}return n.join(`
|
|
68
|
+
`)}get width(){return this.toString().split(`
|
|
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.
|
|
74
|
+
|
|
75
|
+
`;m+=hu(l,s,t,D),m+=`
|
|
76
|
+
`,a(m),process.exit(1)}else C?s.raw._.length?s.called!==w&&s.name===w?a(hu(l,s,t,D)):a(Xe(l,s,s.raw._)):a(hu(l,s,t,D)):d()}),o}}),k=new Uint32Array(65536),tn=(u,e)=>{const t=u.length,D=e.length,n=1<<t-1;let r=-1,o=0,l=t,a=t;for(;a--;)k[u.charCodeAt(a)]|=1<<a;for(a=0;a<D;a++){let s=k[e.charCodeAt(a)];const d=s|o;s|=(s&r)+r^r,o|=~(s|r),r&=s,o&n&&l++,r&n&&l--,o=o<<1|1,r=r<<1|~(d|o),o&=d}for(a=t;a--;)k[u.charCodeAt(a)]=0;return l},Dn=(u,e)=>{const t=e.length,D=u.length,n=[],r=[],o=Math.ceil(t/32),l=Math.ceil(D/32);for(let i=0;i<o;i++)r[i]=-1,n[i]=0;let a=0;for(;a<l-1;a++){let i=0,c=-1;const p=a*32,F=Math.min(32,D)+p;for(let f=p;f<F;f++)k[u.charCodeAt(f)]|=1<<f;for(let f=0;f<t;f++){const E=k[e.charCodeAt(f)],g=r[f/32|0]>>>f&1,y=n[f/32|0]>>>f&1,tu=E|i,Du=((E|y)&c)+c^c|E|y;let I=i|~(Du|c),nu=c&Du;I>>>31^g&&(r[f/32|0]^=1<<f),nu>>>31^y&&(n[f/32|0]^=1<<f),I=I<<1|g,nu=nu<<1|y,c=nu|~(tu|I),i=I&tu}for(let f=p;f<F;f++)k[u.charCodeAt(f)]=0}let s=0,d=-1;const C=a*32,m=Math.min(32,D-C)+C;for(let i=C;i<m;i++)k[u.charCodeAt(i)]|=1<<i;let h=D;for(let i=0;i<t;i++){const c=k[e.charCodeAt(i)],p=r[i/32|0]>>>i&1,F=n[i/32|0]>>>i&1,f=c|s,E=((c|F)&d)+d^d|c|F;let g=s|~(E|d),y=d&E;h+=g>>>D-1&1,h-=y>>>D-1&1,g>>>31^p&&(r[i/32|0]^=1<<i),y>>>31^F&&(n[i/32|0]^=1<<i),g=g<<1|p,y=y<<1|F,d=y|~(f|g),s=g&f}for(let i=C;i<m;i++)k[u.charCodeAt(i)]=0;return h},ut=(u,e)=>{if(u.length<e.length){const t=e;e=u,u=t}return e.length===0?u.length:u.length<=32?tn(u,e):Dn(u,e)};var pu=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},nn=1/0,rn="[object Symbol]",on=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,sn="\\u0300-\\u036f\\ufe20-\\ufe23",an="\\u20d0-\\u20f0",ln="["+sn+an+"]",cn=RegExp(ln,"g"),hn={\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"},pn=typeof pu=="object"&&pu&&pu.Object===Object&&pu,mn=typeof self=="object"&&self&&self.Object===Object&&self,fn=pn||mn||Function("return this")();function dn(u){return function(e){return u==null?void 0:u[e]}}var Fn=dn(hn),Cn=Object.prototype,gn=Cn.toString,et=fn.Symbol,tt=et?et.prototype:void 0,Dt=tt?tt.toString:void 0;function En(u){if(typeof u=="string")return u;if(xn(u))return Dt?Dt.call(u):"";var e=u+"";return e=="0"&&1/u==-nn?"-0":e}function Bn(u){return!!u&&typeof u=="object"}function xn(u){return typeof u=="symbol"||Bn(u)&&gn.call(u)==rn}function bn(u){return u==null?"":En(u)}function An(u){return u=bn(u),u&&u.replace(on,Fn).replace(cn,"")}var yn=An;let O,R;(function(u){u.ALL_CLOSEST_MATCHES="all-closest-matches",u.ALL_MATCHES="all-matches",u.ALL_SORTED_MATCHES="all-sorted-matches",u.FIRST_CLOSEST_MATCH="first-closest-match",u.FIRST_MATCH="first-match"})(O||(O={})),function(u){u.EDIT_DISTANCE="edit-distance",u.SIMILARITY="similarity"}(R||(R={}));const nt=new Error("unknown returnType"),mu=new Error("unknown thresholdType"),rt=(u,e)=>{let t=u;return e.trimSpaces&&(t=t.trim().replace(/\s+/g," ")),e.deburr&&(t=yn(t)),e.caseSensitive||(t=t.toLowerCase()),t},ot=(u,e)=>{const{matchPath:t}=e,D=((n,r)=>{const o=r.length>0?r.reduce((l,a)=>l==null?void 0:l[a],n):n;return typeof o!="string"?"":o})(u,t);return rt(D,e)};function wn(u,e,t){const D=(m=>{const h={caseSensitive:!1,deburr:!0,matchPath:[],returnType:O.FIRST_CLOSEST_MATCH,thresholdType:R.SIMILARITY,trimSpaces:!0,...m};switch(h.thresholdType){case R.EDIT_DISTANCE:return{threshold:20,...h};case R.SIMILARITY:return{threshold:.4,...h};default:throw mu}})(t),{returnType:n,threshold:r,thresholdType:o}=D,l=rt(u,D);let a,s;switch(o){case R.EDIT_DISTANCE:a=m=>m<=r,s=m=>ut(l,ot(m,D));break;case R.SIMILARITY:a=m=>m>=r,s=m=>((h,i)=>{if(!h||!i)return 0;if(h===i)return 1;const c=ut(h,i),p=Math.max(h.length,i.length);return(p-c)/p})(l,ot(m,D));break;default:throw mu}const d=[],C=e.length;switch(n){case O.ALL_CLOSEST_MATCHES:case O.FIRST_CLOSEST_MATCH:{const m=[];let h;switch(o){case R.EDIT_DISTANCE:h=1/0;for(let c=0;c<C;c+=1){const p=s(e[c]);h>p&&(h=p),m.push(p)}break;case R.SIMILARITY:h=0;for(let c=0;c<C;c+=1){const p=s(e[c]);h<p&&(h=p),m.push(p)}break;default:throw mu}const i=m.length;for(let c=0;c<i;c+=1){const p=m[c];a(p)&&p===h&&d.push(c)}break}case O.ALL_MATCHES:for(let m=0;m<C;m+=1)a(s(e[m]))&&d.push(m);break;case O.ALL_SORTED_MATCHES:{const m=[];for(let h=0;h<C;h+=1){const i=s(e[h]);a(i)&&m.push({score:i,index:h})}switch(o){case R.EDIT_DISTANCE:m.sort((h,i)=>h.score-i.score);break;case R.SIMILARITY:m.sort((h,i)=>i.score-h.score);break;default:throw mu}for(const h of m)d.push(h.index);break}case O.FIRST_MATCH:for(let m=0;m<C;m+=1)if(a(s(e[m]))){d.push(m);break}break;default:throw nt}return((m,h,i)=>{switch(i){case O.ALL_CLOSEST_MATCHES:case O.ALL_MATCHES:case O.ALL_SORTED_MATCHES:return h.map(c=>m[c]);case O.FIRST_CLOSEST_MATCH:case O.FIRST_MATCH:return h.length?m[h[0]]:null;default:throw nt}})(e,d,n)}var V={exports:{}};let Sn=fu,$n=!("NO_COLOR"in process.env||process.argv.includes("--no-color"))&&("FORCE_COLOR"in process.env||process.argv.includes("--color")||process.platform==="win32"||Sn.isatty(1)&&process.env.TERM!=="dumb"||"CI"in process.env),b=(u,e,t=u)=>D=>{let n=""+D,r=n.indexOf(e,u.length);return~r?u+st(n,e,t,r)+e:u+n+e},st=(u,e,t,D)=>{let n=u.substring(0,D)+t,r=u.substring(D+e.length),o=r.indexOf(e);return~o?n+st(r,e,t,o):n+r},it=(u=$n)=>({isColorSupported:u,reset:u?e=>`\x1B[0m${e}\x1B[0m`:String,bold:u?b("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"):String,dim:u?b("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"):String,italic:u?b("\x1B[3m","\x1B[23m"):String,underline:u?b("\x1B[4m","\x1B[24m"):String,inverse:u?b("\x1B[7m","\x1B[27m"):String,hidden:u?b("\x1B[8m","\x1B[28m"):String,strikethrough:u?b("\x1B[9m","\x1B[29m"):String,black:u?b("\x1B[30m","\x1B[39m"):String,red:u?b("\x1B[31m","\x1B[39m"):String,green:u?b("\x1B[32m","\x1B[39m"):String,yellow:u?b("\x1B[33m","\x1B[39m"):String,blue:u?b("\x1B[34m","\x1B[39m"):String,magenta:u?b("\x1B[35m","\x1B[39m"):String,cyan:u?b("\x1B[36m","\x1B[39m"):String,white:u?b("\x1B[37m","\x1B[39m"):String,gray:u?b("\x1B[90m","\x1B[39m"):String,bgBlack:u?b("\x1B[40m","\x1B[49m"):String,bgRed:u?b("\x1B[41m","\x1B[49m"):String,bgGreen:u?b("\x1B[42m","\x1B[49m"):String,bgYellow:u?b("\x1B[43m","\x1B[49m"):String,bgBlue:u?b("\x1B[44m","\x1B[49m"):String,bgMagenta:u?b("\x1B[45m","\x1B[49m"):String,bgCyan:u?b("\x1B[46m","\x1B[49m"):String,bgWhite:u?b("\x1B[47m","\x1B[49m"):String});V.exports=it(),V.exports.createColors=it;const vn=u=>u.length<=1?u[0]:`${u.slice(0,-1).map(V.exports.bold).join(", ")} and ${V.exports.bold(u[u.length-1])}`,On=()=>H({setup:u=>u.inspector({enforce:"pre",fn:(e,t)=>{const D=Object.keys(u._commands),n=!!D.length;try{t()}catch(r){if(!(r instanceof ou||r instanceof su))throw r;if(e.raw._.length===0||r instanceof su){console.error("No command given."),n&&console.error(`Possible commands: ${vn(D)}.`);return}const o=r.commandName,l=wn(o,D);console.error(`Command "${V.exports.strikethrough(o)}" not found.`),n&&l?console.error(`Did you mean "${V.exports.bold(l)}"?`):n||console.error("NOTE: You haven't register any command yet."),process.stderr.write(`
|
|
77
|
+
`),process.exit(2)}}})}),Tn=u=>u.length<=1?u[0]:`${u.slice(0,-1).join(", ")} and ${u[u.length-1]}`,Rn=()=>H({setup:u=>u.inspector((e,t)=>{const D=Object.keys(e.unknownFlags);if(!e.resolved||D.length===0)t();else throw new Error(`Unexpected flag${D.length>1?"s":""}: ${Tn(D)}`)})}),Mn=u=>u.length===0?"":u.startsWith("v")?u:`v${u}`,_n=({alias:u=["V"],command:e=!0}={})=>H({setup:t=>{const D=Mn(t._version);return e&&(t=t.command("version","Show version",{notes:['The version string begins with a "v".']}).on("version",()=>{process.stdout.write(D)})),t.inspector({enforce:"pre",fn:(n,r)=>{let o=!1;const l=["version",...u];for(const a of Object.keys(n.raw.mergedFlags))if(l.includes(a)){o=!0;break}o?process.stdout.write(D):r()}})}});var L={exports:{}};let kn=fu,Ln=!("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),A=(u,e,t=u)=>D=>{let n=""+D,r=n.indexOf(e,u.length);return~r?u+at(n,e,t,r)+e:u+n+e},at=(u,e,t,D)=>{let n=u.substring(0,D)+t,r=u.substring(D+e.length),o=r.indexOf(e);return~o?n+at(r,e,t,o):n+r},lt=(u=Ln)=>({isColorSupported:u,reset:u?e=>`\x1B[0m${e}\x1B[0m`:String,bold:u?A("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"):String,dim:u?A("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"):String,italic:u?A("\x1B[3m","\x1B[23m"):String,underline:u?A("\x1B[4m","\x1B[24m"):String,inverse:u?A("\x1B[7m","\x1B[27m"):String,hidden:u?A("\x1B[8m","\x1B[28m"):String,strikethrough:u?A("\x1B[9m","\x1B[29m"):String,black:u?A("\x1B[30m","\x1B[39m"):String,red:u?A("\x1B[31m","\x1B[39m"):String,green:u?A("\x1B[32m","\x1B[39m"):String,yellow:u?A("\x1B[33m","\x1B[39m"):String,blue:u?A("\x1B[34m","\x1B[39m"):String,magenta:u?A("\x1B[35m","\x1B[39m"):String,cyan:u?A("\x1B[36m","\x1B[39m"):String,white:u?A("\x1B[37m","\x1B[39m"):String,gray:u?A("\x1B[90m","\x1B[39m"):String,bgBlack:u?A("\x1B[40m","\x1B[49m"):String,bgRed:u?A("\x1B[41m","\x1B[49m"):String,bgGreen:u?A("\x1B[42m","\x1B[49m"):String,bgYellow:u?A("\x1B[43m","\x1B[49m"):String,bgBlue:u?A("\x1B[44m","\x1B[49m"):String,bgMagenta:u?A("\x1B[45m","\x1B[49m"):String,bgCyan:u?A("\x1B[46m","\x1B[49m"):String,bgWhite:u?A("\x1B[47m","\x1B[49m"):String});L.exports=lt(),L.exports.createColors=lt;function In(u){return u.split(`
|
|
78
|
+
`).splice(1).map(e=>e.trim().replace("file://",""))}function jn(u){return`
|
|
79
|
+
${In(u).map(e=>` ${e.replace(/^at ([\s\S]+) \((.+)\)/,(t,D,n)=>L.exports.gray(`at ${D} (${L.exports.cyan(n)})`))}`).join(`
|
|
80
|
+
`)}`}function Wn(u){return u.map(e=>typeof(e==null?void 0:e.stack)=="string"?`${e.message}
|
|
81
|
+
${jn(e.stack)}`:e)}function Nn(u,e){const t=u.toUpperCase(),D=L.exports[e];return L.exports.bold(L.exports.inverse(D(` ${t} `)))}function uu(u,e,t){const D=L.exports[e],n=t!=null&&t.textColor?L.exports[t.textColor]:D,r=(t==null?void 0:t.target)||console.log;return(...o)=>{const l=Wn(o);r(`${Nn(u,e)} ${n(l.join(" "))}
|
|
82
|
+
`)}}uu("log","gray"),uu("info","blue",{target:console.info}),uu("warn","yellow",{target:console.warn}),uu("success","green");const Pn=uu("error","red",{target:console.error}),Hn=()=>H({setup:u=>u.inspector({enforce:"pre",fn:(e,t)=>{try{t()}catch(D){Pn(D.message),process.exit(1)}}})});export{Nt as Clerc,Pu as CommandExistsError,Hu as CommandNameConflictError,Yu as DescriptionNotSetError,Uu as InvalidCommandNameError,Gu as NameNotSetError,su as NoCommandGivenError,ou as NoSuchCommandError,w as Root,zu as VersionNotSetError,Zt as completionsPlugin,Qu as compose,Gt as defineCommand,Pt as defineHandler,Ht as defineInspector,H as definePlugin,G as formatCommandName,Hn as friendlyErrorPlugin,en as helpPlugin,Xu as isInvalidName,On as notFoundPlugin,Cu as resolveArgv,Fu as resolveCommand,Zu as resolveFlattenCommands,Ku as resolveParametersBeforeFlag,It as resolveRootCommands,Ju as resolveSubcommandsByParent,Rn as strictFlagsPlugin,_n as versionPlugin,ue as withBrackets};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clerc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.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": [
|
|
@@ -26,15 +26,11 @@
|
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
|
-
"import": "./dist/index.
|
|
30
|
-
},
|
|
31
|
-
"./toolkit": {
|
|
32
|
-
"types": "./dist/toolkit.d.ts",
|
|
33
|
-
"import": "./dist/toolkit.mjs"
|
|
29
|
+
"import": "./dist/index.js"
|
|
34
30
|
}
|
|
35
31
|
},
|
|
36
32
|
"main": "dist/index.js",
|
|
37
|
-
"module": "dist/index.
|
|
33
|
+
"module": "dist/index.js",
|
|
38
34
|
"types": "dist/index.d.ts",
|
|
39
35
|
"typesVersions": {
|
|
40
36
|
"*": {
|
|
@@ -50,18 +46,17 @@
|
|
|
50
46
|
"publishConfig": {
|
|
51
47
|
"access": "public"
|
|
52
48
|
},
|
|
53
|
-
"
|
|
54
|
-
"@clerc/
|
|
55
|
-
"@clerc/
|
|
56
|
-
"@clerc/plugin-
|
|
57
|
-
"@clerc/plugin-
|
|
58
|
-
"@clerc/plugin-
|
|
59
|
-
"@clerc/plugin-
|
|
60
|
-
"@clerc/
|
|
61
|
-
"@clerc/plugin-version": "0.25.1"
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@clerc/plugin-not-found": "0.27.1",
|
|
51
|
+
"@clerc/core": "0.27.1",
|
|
52
|
+
"@clerc/plugin-completions": "0.27.1",
|
|
53
|
+
"@clerc/plugin-version": "0.27.1",
|
|
54
|
+
"@clerc/plugin-help": "0.27.1",
|
|
55
|
+
"@clerc/plugin-strict-flags": "0.27.1",
|
|
56
|
+
"@clerc/plugin-friendly-error": "0.27.1"
|
|
62
57
|
},
|
|
63
58
|
"scripts": {
|
|
64
|
-
"build": "puild",
|
|
59
|
+
"build": "puild --minify",
|
|
65
60
|
"watch": "puild --watch"
|
|
66
61
|
}
|
|
67
62
|
}
|
package/dist/index.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from '@clerc/core';
|
|
2
|
-
export * from '@clerc/plugin-completions';
|
|
3
|
-
export * from '@clerc/plugin-help';
|
|
4
|
-
export * from '@clerc/plugin-not-found';
|
|
5
|
-
export * from '@clerc/plugin-strict-flags';
|
|
6
|
-
export * from '@clerc/plugin-version';
|
|
7
|
-
export * from '@clerc/plugin-friendly-error';
|
package/dist/toolkit.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@clerc/toolkit';
|
package/dist/toolkit.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@clerc/toolkit';
|
package/dist/toolkit.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@clerc/toolkit';
|