clerc 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +472 -472
- package/dist/index.js +23 -23
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -220,511 +220,511 @@ type LiteralUnion<
|
|
|
220
220
|
BaseType extends Primitive,
|
|
221
221
|
> = LiteralType | (BaseType & Record<never, never>);
|
|
222
222
|
|
|
223
|
-
type Equals<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
224
|
-
type Dict<T> = Record<string, T>;
|
|
225
|
-
type MaybeArray$1<T> = T | T[];
|
|
226
|
-
type AlphabetLowercase = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
227
|
-
type Numeric = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
|
228
|
-
type AlphaNumeric = AlphabetLowercase | Uppercase<AlphabetLowercase> | Numeric;
|
|
223
|
+
type Equals<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
224
|
+
type Dict<T> = Record<string, T>;
|
|
225
|
+
type MaybeArray$1<T> = T | T[];
|
|
226
|
+
type AlphabetLowercase = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
227
|
+
type Numeric = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
|
228
|
+
type AlphaNumeric = AlphabetLowercase | Uppercase<AlphabetLowercase> | Numeric;
|
|
229
229
|
type CamelCase<Word extends string> = (Word extends `${infer FirstCharacter}${infer Rest}` ? (FirstCharacter extends AlphaNumeric ? `${FirstCharacter}${CamelCase<Rest>}` : Capitalize<CamelCase<Rest>>) : Word);
|
|
230
230
|
|
|
231
|
-
declare const DOUBLE_DASH = "--";
|
|
232
|
-
type TypeFunction<ReturnType = any> = (value: any) => ReturnType;
|
|
233
|
-
type TypeFunctionArray<ReturnType> = readonly [TypeFunction<ReturnType>];
|
|
234
|
-
type FlagType<ReturnType = any> = TypeFunction<ReturnType> | TypeFunctionArray<ReturnType>;
|
|
235
|
-
type FlagSchemaBase<TF> = {
|
|
236
|
-
/**
|
|
237
|
-
Type of the flag as a function that parses the argv string and returns the parsed value.
|
|
238
|
-
|
|
239
|
-
@example
|
|
240
|
-
```
|
|
241
|
-
type: String
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
@example Wrap in an array to accept multiple values.
|
|
245
|
-
```
|
|
246
|
-
type: [Boolean]
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
@example Custom function type that uses moment.js to parse string as date.
|
|
250
|
-
```
|
|
251
|
-
type: function CustomDate(value: string) {
|
|
252
|
-
return moment(value).toDate();
|
|
253
|
-
}
|
|
254
|
-
```
|
|
255
|
-
*/
|
|
256
|
-
type: TF;
|
|
257
|
-
/**
|
|
258
|
-
A single-character alias for the flag.
|
|
259
|
-
|
|
260
|
-
@example
|
|
261
|
-
```
|
|
262
|
-
alias: 's'
|
|
263
|
-
```
|
|
264
|
-
*/
|
|
265
|
-
alias?: string;
|
|
266
|
-
} & Record<PropertyKey, unknown>;
|
|
267
|
-
type FlagSchemaDefault<TF, DefaultType = any> = FlagSchemaBase<TF> & {
|
|
268
|
-
/**
|
|
269
|
-
Default value of the flag. Also accepts a function that returns the default value.
|
|
270
|
-
[Default: undefined]
|
|
271
|
-
|
|
272
|
-
@example
|
|
273
|
-
```
|
|
274
|
-
default: 'hello'
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
@example
|
|
278
|
-
```
|
|
279
|
-
default: () => [1, 2, 3]
|
|
280
|
-
```
|
|
281
|
-
*/
|
|
282
|
-
default: DefaultType | (() => DefaultType);
|
|
283
|
-
};
|
|
284
|
-
type FlagSchema<TF = FlagType> = (FlagSchemaBase<TF> | FlagSchemaDefault<TF>);
|
|
285
|
-
type FlagTypeOrSchema<ExtraOptions = Record<string, unknown>> = FlagType | (FlagSchema & ExtraOptions);
|
|
286
|
-
type Flags$1<ExtraOptions = Record<string, unknown>> = Record<string, FlagTypeOrSchema<ExtraOptions>>;
|
|
287
|
-
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));
|
|
288
|
-
interface ParsedFlags<Schemas = Record<string, unknown>> {
|
|
289
|
-
flags: Schemas;
|
|
290
|
-
unknownFlags: Record<string, (string | boolean)[]>;
|
|
291
|
-
_: string[] & {
|
|
292
|
-
[DOUBLE_DASH]: string[];
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
type TypeFlag<Schemas extends Flags$1> = ParsedFlags<{
|
|
296
|
-
[flag in keyof Schemas]: InferFlagType<Schemas[flag]>;
|
|
231
|
+
declare const DOUBLE_DASH = "--";
|
|
232
|
+
type TypeFunction<ReturnType = any> = (value: any) => ReturnType;
|
|
233
|
+
type TypeFunctionArray<ReturnType> = readonly [TypeFunction<ReturnType>];
|
|
234
|
+
type FlagType<ReturnType = any> = TypeFunction<ReturnType> | TypeFunctionArray<ReturnType>;
|
|
235
|
+
type FlagSchemaBase<TF> = {
|
|
236
|
+
/**
|
|
237
|
+
Type of the flag as a function that parses the argv string and returns the parsed value.
|
|
238
|
+
|
|
239
|
+
@example
|
|
240
|
+
```
|
|
241
|
+
type: String
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
@example Wrap in an array to accept multiple values.
|
|
245
|
+
```
|
|
246
|
+
type: [Boolean]
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
@example Custom function type that uses moment.js to parse string as date.
|
|
250
|
+
```
|
|
251
|
+
type: function CustomDate(value: string) {
|
|
252
|
+
return moment(value).toDate();
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
*/
|
|
256
|
+
type: TF;
|
|
257
|
+
/**
|
|
258
|
+
A single-character alias for the flag.
|
|
259
|
+
|
|
260
|
+
@example
|
|
261
|
+
```
|
|
262
|
+
alias: 's'
|
|
263
|
+
```
|
|
264
|
+
*/
|
|
265
|
+
alias?: string;
|
|
266
|
+
} & Record<PropertyKey, unknown>;
|
|
267
|
+
type FlagSchemaDefault<TF, DefaultType = any> = FlagSchemaBase<TF> & {
|
|
268
|
+
/**
|
|
269
|
+
Default value of the flag. Also accepts a function that returns the default value.
|
|
270
|
+
[Default: undefined]
|
|
271
|
+
|
|
272
|
+
@example
|
|
273
|
+
```
|
|
274
|
+
default: 'hello'
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
@example
|
|
278
|
+
```
|
|
279
|
+
default: () => [1, 2, 3]
|
|
280
|
+
```
|
|
281
|
+
*/
|
|
282
|
+
default: DefaultType | (() => DefaultType);
|
|
283
|
+
};
|
|
284
|
+
type FlagSchema<TF = FlagType> = (FlagSchemaBase<TF> | FlagSchemaDefault<TF>);
|
|
285
|
+
type FlagTypeOrSchema<ExtraOptions = Record<string, unknown>> = FlagType | (FlagSchema & ExtraOptions);
|
|
286
|
+
type Flags$1<ExtraOptions = Record<string, unknown>> = Record<string, FlagTypeOrSchema<ExtraOptions>>;
|
|
287
|
+
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));
|
|
288
|
+
interface ParsedFlags<Schemas = Record<string, unknown>> {
|
|
289
|
+
flags: Schemas;
|
|
290
|
+
unknownFlags: Record<string, (string | boolean)[]>;
|
|
291
|
+
_: string[] & {
|
|
292
|
+
[DOUBLE_DASH]: string[];
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
type TypeFlag<Schemas extends Flags$1> = ParsedFlags<{
|
|
296
|
+
[flag in keyof Schemas]: InferFlagType<Schemas[flag]>;
|
|
297
297
|
}>;
|
|
298
298
|
|
|
299
|
-
type StripBrackets<Parameter extends string> = (Parameter extends `<${infer ParameterName}>` | `[${infer ParameterName}]` ? (ParameterName extends `${infer SpreadName}...` ? SpreadName : ParameterName) : never);
|
|
300
|
-
type ParameterType<Parameter extends string> = (Parameter extends `<${infer _ParameterName}...>` | `[${infer _ParameterName}...]` ? string[] : Parameter extends `<${infer _ParameterName}>` ? string : Parameter extends `[${infer _ParameterName}]` ? string | undefined : never);
|
|
301
|
-
type NonNullableParameters<T extends string[] | undefined> = T extends undefined ? [] : NonNullable<T>;
|
|
302
|
-
type TransformParameters<C extends Command> = {
|
|
303
|
-
[Parameter in NonNullableParameters<C["parameters"]>[number] as CamelCase<StripBrackets<Parameter>>]: ParameterType<Parameter>;
|
|
304
|
-
};
|
|
305
|
-
type MakeEventMap<T extends Commands> = {
|
|
306
|
-
[K in keyof T]: [InspectorContext];
|
|
307
|
-
};
|
|
308
|
-
type FallbackFlags<F extends Flags | undefined> = Equals<NonNullableFlag<F>["flags"], {}> extends true ? Dict<any> : NonNullableFlag<F>["flags"];
|
|
309
|
-
type NonNullableFlag<F extends Flags | undefined> = TypeFlag<NonNullable<F>>;
|
|
310
|
-
type ParseFlag<C extends Commands, N extends keyof C, GF extends
|
|
311
|
-
type ParseRaw<C extends Command, GF extends
|
|
312
|
-
flags: FallbackFlags<C["flags"] & GF>;
|
|
313
|
-
parameters: string[];
|
|
314
|
-
mergedFlags: FallbackFlags<C["flags"] & GF> & NonNullableFlag<C["flags"] & GF>["unknownFlags"];
|
|
315
|
-
};
|
|
299
|
+
type StripBrackets<Parameter extends string> = (Parameter extends `<${infer ParameterName}>` | `[${infer ParameterName}]` ? (ParameterName extends `${infer SpreadName}...` ? SpreadName : ParameterName) : never);
|
|
300
|
+
type ParameterType<Parameter extends string> = (Parameter extends `<${infer _ParameterName}...>` | `[${infer _ParameterName}...]` ? string[] : Parameter extends `<${infer _ParameterName}>` ? string : Parameter extends `[${infer _ParameterName}]` ? string | undefined : never);
|
|
301
|
+
type NonNullableParameters<T extends string[] | undefined> = T extends undefined ? [] : NonNullable<T>;
|
|
302
|
+
type TransformParameters<C extends Command> = {
|
|
303
|
+
[Parameter in NonNullableParameters<C["parameters"]>[number] as CamelCase<StripBrackets<Parameter>>]: ParameterType<Parameter>;
|
|
304
|
+
};
|
|
305
|
+
type MakeEventMap<T extends Commands> = {
|
|
306
|
+
[K in keyof T]: [InspectorContext];
|
|
307
|
+
};
|
|
308
|
+
type FallbackFlags<F extends Flags | undefined> = Equals<NonNullableFlag<F>["flags"], {}> extends true ? Dict<any> : NonNullableFlag<F>["flags"];
|
|
309
|
+
type NonNullableFlag<F extends Flags | undefined> = TypeFlag<NonNullable<F>>;
|
|
310
|
+
type ParseFlag<C extends Commands, N extends keyof C, GF extends GlobalFlagOptions = {}> = N extends keyof C ? OmitIndexSignature<NonNullableFlag<C[N]["flags"] & GF>["flags"]> : FallbackFlags<C[N]["flags"] & GF>["flags"];
|
|
311
|
+
type ParseRaw<C extends Command, GF extends GlobalFlagOptions = {}> = NonNullableFlag<C["flags"] & GF> & {
|
|
312
|
+
flags: FallbackFlags<C["flags"] & GF>;
|
|
313
|
+
parameters: string[];
|
|
314
|
+
mergedFlags: FallbackFlags<C["flags"] & GF> & NonNullableFlag<C["flags"] & GF>["unknownFlags"];
|
|
315
|
+
};
|
|
316
316
|
type ParseParameters<C extends Commands = Commands, N extends keyof C = keyof C> = Equals<TransformParameters<C[N]>, {}> extends true ? N extends keyof C ? TransformParameters<C[N]> : Dict<string | string[] | undefined> : TransformParameters<C[N]>;
|
|
317
317
|
|
|
318
|
-
interface Plugin<T extends Clerc = Clerc, U extends Clerc = Clerc> {
|
|
319
|
-
setup: (cli: T) => U;
|
|
318
|
+
interface Plugin<T extends Clerc = Clerc, U extends Clerc = Clerc> {
|
|
319
|
+
setup: (cli: T) => U;
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
type Locales = Dict<Dict<string>>;
|
|
323
|
-
type TranslateFn = (name: string, ...args: string[]) => string | undefined;
|
|
324
|
-
interface I18N {
|
|
325
|
-
add: (locales: Locales) => void;
|
|
326
|
-
t: TranslateFn;
|
|
322
|
+
type Locales = Dict<Dict<string>>;
|
|
323
|
+
type TranslateFn = (name: string, ...args: string[]) => string | undefined;
|
|
324
|
+
interface I18N {
|
|
325
|
+
add: (locales: Locales) => void;
|
|
326
|
+
t: TranslateFn;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
type CommandType = RootType | string;
|
|
330
|
-
type FlagOptions = FlagSchema & {
|
|
331
|
-
description: string;
|
|
332
|
-
};
|
|
333
|
-
type Flag = FlagOptions & {
|
|
334
|
-
name: string;
|
|
335
|
-
};
|
|
336
|
-
type
|
|
337
|
-
type Flags = Dict<FlagOptions>;
|
|
338
|
-
type
|
|
339
|
-
declare interface CommandCustomProperties {
|
|
340
|
-
}
|
|
341
|
-
interface CommandOptions<P extends string[] = string[], A extends MaybeArray$1<string | RootType> = MaybeArray$1<string | RootType>, F extends Flags = Flags> extends CommandCustomProperties {
|
|
342
|
-
alias?: A;
|
|
343
|
-
parameters?: P;
|
|
344
|
-
flags?: F;
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
enforce?: "pre" | "post";
|
|
389
|
-
fn: InspectorFn<C>;
|
|
329
|
+
type CommandType = RootType | string;
|
|
330
|
+
type FlagOptions = FlagSchema & {
|
|
331
|
+
description: string;
|
|
332
|
+
};
|
|
333
|
+
type Flag = FlagOptions & {
|
|
334
|
+
name: string;
|
|
335
|
+
};
|
|
336
|
+
type GlobalFlagOption = FlagSchema;
|
|
337
|
+
type Flags = Dict<FlagOptions>;
|
|
338
|
+
type GlobalFlagOptions = Dict<GlobalFlagOption>;
|
|
339
|
+
declare interface CommandCustomProperties {
|
|
340
|
+
}
|
|
341
|
+
interface CommandOptions<P extends string[] = string[], A extends MaybeArray$1<string | RootType> = MaybeArray$1<string | RootType>, F extends Flags = Flags> extends CommandCustomProperties {
|
|
342
|
+
alias?: A;
|
|
343
|
+
parameters?: P;
|
|
344
|
+
flags?: F;
|
|
345
|
+
}
|
|
346
|
+
type Command<N extends string | RootType = string, O extends CommandOptions = CommandOptions> = O & {
|
|
347
|
+
name: N;
|
|
348
|
+
description: string;
|
|
349
|
+
};
|
|
350
|
+
type CommandAlias<N extends string | RootType = string, O extends CommandOptions = CommandOptions> = Command<N, O> & {
|
|
351
|
+
__isAlias?: true;
|
|
352
|
+
};
|
|
353
|
+
type CommandWithHandler<N extends string | RootType = string, O extends CommandOptions = CommandOptions> = Command<N, O> & {
|
|
354
|
+
handler?: HandlerInCommand<HandlerContext<Record<N, Command<N, O>> & Record<never, never>, N>>;
|
|
355
|
+
};
|
|
356
|
+
type Commands = Dict<Command> & {
|
|
357
|
+
[Root]?: Command;
|
|
358
|
+
};
|
|
359
|
+
interface ParseOptions {
|
|
360
|
+
argv?: string[];
|
|
361
|
+
run?: boolean;
|
|
362
|
+
}
|
|
363
|
+
interface HandlerContext<C extends Commands = Commands, N extends keyof C = keyof C, GF extends GlobalFlagOptions = {}> {
|
|
364
|
+
name?: LiteralUnion<N, string>;
|
|
365
|
+
called?: string | RootType;
|
|
366
|
+
resolved: boolean;
|
|
367
|
+
hasRootOrAlias: boolean;
|
|
368
|
+
hasRoot: boolean;
|
|
369
|
+
raw: Simplify<ParseRaw<C[N], GF>>;
|
|
370
|
+
parameters: Simplify<ParseParameters<C, N>>;
|
|
371
|
+
unknownFlags: ParsedFlags["unknownFlags"];
|
|
372
|
+
flags: Simplify<ParseFlag<C, N, GF> & Record<string, any>>;
|
|
373
|
+
cli: Clerc<C, GF>;
|
|
374
|
+
}
|
|
375
|
+
type Handler<C extends Commands = Commands, K extends keyof C = keyof C, GF extends GlobalFlagOptions = {}> = (ctx: HandlerContext<C, K, GF>) => void;
|
|
376
|
+
type HandlerInCommand<C extends HandlerContext> = (ctx: {
|
|
377
|
+
[K in keyof C]: C[K];
|
|
378
|
+
}) => void;
|
|
379
|
+
type FallbackType<T, U> = {} extends T ? U : T;
|
|
380
|
+
type InspectorContext<C extends Commands = Commands> = HandlerContext<C> & {
|
|
381
|
+
flags: FallbackType<TypeFlag<NonNullable<C[keyof C]["flags"]>>["flags"], Dict<any>>;
|
|
382
|
+
};
|
|
383
|
+
type Inspector<C extends Commands = Commands> = InspectorFn<C> | InspectorObject<C>;
|
|
384
|
+
type InspectorFn<C extends Commands = Commands> = (ctx: InspectorContext<C>, next: () => void) => (() => void) | void;
|
|
385
|
+
interface InspectorObject<C extends Commands = Commands> {
|
|
386
|
+
enforce?: "pre" | "post";
|
|
387
|
+
fn: InspectorFn<C>;
|
|
390
388
|
}
|
|
391
389
|
|
|
392
|
-
declare const Root: unique symbol;
|
|
393
|
-
type RootType = typeof Root;
|
|
394
|
-
declare class Clerc<C extends Commands = {}, GF extends
|
|
395
|
-
#private;
|
|
396
|
-
i18n: I18N;
|
|
397
|
-
private constructor();
|
|
398
|
-
get _name(): string;
|
|
399
|
-
get _description(): string;
|
|
400
|
-
get _version(): string;
|
|
401
|
-
get _inspectors(): Inspector
|
|
402
|
-
get _commands(): C;
|
|
403
|
-
get _flags(): GF;
|
|
404
|
-
/**
|
|
405
|
-
* Create a new cli
|
|
406
|
-
* @returns
|
|
407
|
-
* @example
|
|
408
|
-
* ```ts
|
|
409
|
-
* const cli = Clerc.create()
|
|
410
|
-
* ```
|
|
411
|
-
*/
|
|
412
|
-
static create(name?: string, description?: string, version?: string): Clerc<{}, {}>;
|
|
413
|
-
/**
|
|
414
|
-
* Set the name of the cli
|
|
415
|
-
* @param name
|
|
416
|
-
* @returns
|
|
417
|
-
* @example
|
|
418
|
-
* ```ts
|
|
419
|
-
* Clerc.create()
|
|
420
|
-
* .name("test")
|
|
421
|
-
* ```
|
|
422
|
-
*/
|
|
423
|
-
name(name: string): this;
|
|
424
|
-
/**
|
|
425
|
-
* Set the description of the cli
|
|
426
|
-
* @param description
|
|
427
|
-
* @returns
|
|
428
|
-
* @example
|
|
429
|
-
* ```ts
|
|
430
|
-
* Clerc.create()
|
|
431
|
-
* .description("test cli")
|
|
432
|
-
* ```
|
|
433
|
-
*/
|
|
434
|
-
description(description: string): this;
|
|
435
|
-
/**
|
|
436
|
-
* Set the version of the cli
|
|
437
|
-
* @param version
|
|
438
|
-
* @returns
|
|
439
|
-
* @example
|
|
440
|
-
* ```ts
|
|
441
|
-
* Clerc.create()
|
|
442
|
-
* .version("1.0.0")
|
|
443
|
-
* ```
|
|
444
|
-
*/
|
|
445
|
-
version(version: string): this;
|
|
446
|
-
/**
|
|
447
|
-
* Set the Locale
|
|
448
|
-
* You must call this method once after you created the Clerc instance.
|
|
449
|
-
* @param locale
|
|
450
|
-
* @returns
|
|
451
|
-
* @example
|
|
452
|
-
* ```ts
|
|
453
|
-
* Clerc.create()
|
|
454
|
-
* .locale("en")
|
|
455
|
-
* .command(...)
|
|
456
|
-
* ```
|
|
457
|
-
*/
|
|
458
|
-
locale(locale: string): this;
|
|
459
|
-
/**
|
|
460
|
-
* Set the fallback Locale
|
|
461
|
-
* You must call this method once after you created the Clerc instance.
|
|
462
|
-
* @param fallbackLocale
|
|
463
|
-
* @returns
|
|
464
|
-
* @example
|
|
465
|
-
* ```ts
|
|
466
|
-
* Clerc.create()
|
|
467
|
-
* .fallbackLocale("en")
|
|
468
|
-
* .command(...)
|
|
469
|
-
* ```
|
|
470
|
-
*/
|
|
471
|
-
fallbackLocale(fallbackLocale: string): this;
|
|
472
|
-
/**
|
|
473
|
-
* Register a error handler
|
|
474
|
-
* @param handler
|
|
475
|
-
* @returns
|
|
476
|
-
* @example
|
|
477
|
-
* ```ts
|
|
478
|
-
* Clerc.create()
|
|
479
|
-
* .errorHandler((err) => { console.log(err); })
|
|
480
|
-
* ```
|
|
481
|
-
*/
|
|
482
|
-
errorHandler(handler: (err: any) => void): this;
|
|
483
|
-
/**
|
|
484
|
-
* Register a command
|
|
485
|
-
* @param name
|
|
486
|
-
* @param description
|
|
487
|
-
* @param options
|
|
488
|
-
* @returns
|
|
489
|
-
* @example
|
|
490
|
-
* ```ts
|
|
491
|
-
* Clerc.create()
|
|
492
|
-
* .command("test", "test command", {
|
|
493
|
-
* alias: "t",
|
|
494
|
-
* flags: {
|
|
495
|
-
* foo: {
|
|
496
|
-
* alias: "f",
|
|
497
|
-
* description: "foo flag",
|
|
498
|
-
* }
|
|
499
|
-
* }
|
|
500
|
-
* })
|
|
501
|
-
* ```
|
|
502
|
-
* @example
|
|
503
|
-
* ```ts
|
|
504
|
-
* Clerc.create()
|
|
505
|
-
* .command("", "root", {
|
|
506
|
-
* flags: {
|
|
507
|
-
* foo: {
|
|
508
|
-
* alias: "f",
|
|
509
|
-
* description: "foo flag",
|
|
510
|
-
* }
|
|
511
|
-
* }
|
|
512
|
-
* })
|
|
513
|
-
* ```
|
|
514
|
-
*/
|
|
515
|
-
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>>, GF>;
|
|
516
|
-
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>>, GF>;
|
|
517
|
-
/**
|
|
518
|
-
* Register a global flag
|
|
519
|
-
* @param name
|
|
520
|
-
* @param
|
|
521
|
-
* @
|
|
522
|
-
* @
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
*
|
|
535
|
-
* @param
|
|
536
|
-
* @
|
|
537
|
-
* @
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
* .
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
*
|
|
550
|
-
* @
|
|
551
|
-
* @
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
*
|
|
561
|
-
* @
|
|
562
|
-
* @
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
*
|
|
567
|
-
*
|
|
568
|
-
*
|
|
569
|
-
*
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
*
|
|
575
|
-
* @
|
|
576
|
-
* @
|
|
577
|
-
*
|
|
578
|
-
*
|
|
579
|
-
*
|
|
580
|
-
*
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
*
|
|
586
|
-
* @
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
* .
|
|
591
|
-
*
|
|
592
|
-
|
|
593
|
-
|
|
390
|
+
declare const Root: unique symbol;
|
|
391
|
+
type RootType = typeof Root;
|
|
392
|
+
declare class Clerc<C extends Commands = {}, GF extends GlobalFlagOptions = {}> {
|
|
393
|
+
#private;
|
|
394
|
+
i18n: I18N;
|
|
395
|
+
private constructor();
|
|
396
|
+
get _name(): string;
|
|
397
|
+
get _description(): string;
|
|
398
|
+
get _version(): string;
|
|
399
|
+
get _inspectors(): Inspector[];
|
|
400
|
+
get _commands(): C;
|
|
401
|
+
get _flags(): GF;
|
|
402
|
+
/**
|
|
403
|
+
* Create a new cli
|
|
404
|
+
* @returns
|
|
405
|
+
* @example
|
|
406
|
+
* ```ts
|
|
407
|
+
* const cli = Clerc.create()
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
static create(name?: string, description?: string, version?: string): Clerc<{}, {}>;
|
|
411
|
+
/**
|
|
412
|
+
* Set the name of the cli
|
|
413
|
+
* @param name
|
|
414
|
+
* @returns
|
|
415
|
+
* @example
|
|
416
|
+
* ```ts
|
|
417
|
+
* Clerc.create()
|
|
418
|
+
* .name("test")
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
name(name: string): this;
|
|
422
|
+
/**
|
|
423
|
+
* Set the description of the cli
|
|
424
|
+
* @param description
|
|
425
|
+
* @returns
|
|
426
|
+
* @example
|
|
427
|
+
* ```ts
|
|
428
|
+
* Clerc.create()
|
|
429
|
+
* .description("test cli")
|
|
430
|
+
* ```
|
|
431
|
+
*/
|
|
432
|
+
description(description: string): this;
|
|
433
|
+
/**
|
|
434
|
+
* Set the version of the cli
|
|
435
|
+
* @param version
|
|
436
|
+
* @returns
|
|
437
|
+
* @example
|
|
438
|
+
* ```ts
|
|
439
|
+
* Clerc.create()
|
|
440
|
+
* .version("1.0.0")
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
version(version: string): this;
|
|
444
|
+
/**
|
|
445
|
+
* Set the Locale
|
|
446
|
+
* You must call this method once after you created the Clerc instance.
|
|
447
|
+
* @param locale
|
|
448
|
+
* @returns
|
|
449
|
+
* @example
|
|
450
|
+
* ```ts
|
|
451
|
+
* Clerc.create()
|
|
452
|
+
* .locale("en")
|
|
453
|
+
* .command(...)
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
locale(locale: string): this;
|
|
457
|
+
/**
|
|
458
|
+
* Set the fallback Locale
|
|
459
|
+
* You must call this method once after you created the Clerc instance.
|
|
460
|
+
* @param fallbackLocale
|
|
461
|
+
* @returns
|
|
462
|
+
* @example
|
|
463
|
+
* ```ts
|
|
464
|
+
* Clerc.create()
|
|
465
|
+
* .fallbackLocale("en")
|
|
466
|
+
* .command(...)
|
|
467
|
+
* ```
|
|
468
|
+
*/
|
|
469
|
+
fallbackLocale(fallbackLocale: string): this;
|
|
470
|
+
/**
|
|
471
|
+
* Register a error handler
|
|
472
|
+
* @param handler
|
|
473
|
+
* @returns
|
|
474
|
+
* @example
|
|
475
|
+
* ```ts
|
|
476
|
+
* Clerc.create()
|
|
477
|
+
* .errorHandler((err) => { console.log(err); })
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
errorHandler(handler: (err: any) => void): this;
|
|
481
|
+
/**
|
|
482
|
+
* Register a command
|
|
483
|
+
* @param name
|
|
484
|
+
* @param description
|
|
485
|
+
* @param options
|
|
486
|
+
* @returns
|
|
487
|
+
* @example
|
|
488
|
+
* ```ts
|
|
489
|
+
* Clerc.create()
|
|
490
|
+
* .command("test", "test command", {
|
|
491
|
+
* alias: "t",
|
|
492
|
+
* flags: {
|
|
493
|
+
* foo: {
|
|
494
|
+
* alias: "f",
|
|
495
|
+
* description: "foo flag",
|
|
496
|
+
* }
|
|
497
|
+
* }
|
|
498
|
+
* })
|
|
499
|
+
* ```
|
|
500
|
+
* @example
|
|
501
|
+
* ```ts
|
|
502
|
+
* Clerc.create()
|
|
503
|
+
* .command("", "root", {
|
|
504
|
+
* flags: {
|
|
505
|
+
* foo: {
|
|
506
|
+
* alias: "f",
|
|
507
|
+
* description: "foo flag",
|
|
508
|
+
* }
|
|
509
|
+
* }
|
|
510
|
+
* })
|
|
511
|
+
* ```
|
|
512
|
+
*/
|
|
513
|
+
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>>, GF>;
|
|
514
|
+
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>>, GF>;
|
|
515
|
+
/**
|
|
516
|
+
* Register a global flag
|
|
517
|
+
* @param name
|
|
518
|
+
* @param description
|
|
519
|
+
* @param options
|
|
520
|
+
* @returns
|
|
521
|
+
* @example
|
|
522
|
+
* ```ts
|
|
523
|
+
* Clerc.create()
|
|
524
|
+
* .flag("help", "help", {
|
|
525
|
+
* alias: "h",
|
|
526
|
+
* type: Boolean,
|
|
527
|
+
* })
|
|
528
|
+
* ```
|
|
529
|
+
*/
|
|
530
|
+
flag<N extends string, O extends GlobalFlagOption>(name: N, description: string, options: O): this & Clerc<C, GF & Record<N, O>>;
|
|
531
|
+
/**
|
|
532
|
+
* Register a handler
|
|
533
|
+
* @param name
|
|
534
|
+
* @param handler
|
|
535
|
+
* @returns
|
|
536
|
+
* @example
|
|
537
|
+
* ```ts
|
|
538
|
+
* Clerc.create()
|
|
539
|
+
* .command("test", "test command")
|
|
540
|
+
* .on("test", (ctx) => {
|
|
541
|
+
* console.log(ctx);
|
|
542
|
+
* })
|
|
543
|
+
* ```
|
|
544
|
+
*/
|
|
545
|
+
on<K extends LiteralUnion<keyof CM, string | RootType>, CM extends this["_commands"] = this["_commands"]>(name: K, handler: Handler<CM, K, this["_flags"]>): this;
|
|
546
|
+
/**
|
|
547
|
+
* Use a plugin
|
|
548
|
+
* @param plugin
|
|
549
|
+
* @returns
|
|
550
|
+
* @example
|
|
551
|
+
* ```ts
|
|
552
|
+
* Clerc.create()
|
|
553
|
+
* .use(plugin)
|
|
554
|
+
* ```
|
|
555
|
+
*/
|
|
556
|
+
use<T extends Clerc, U extends Clerc>(plugin: Plugin<T, U>): this & Clerc<C & U["_commands"]> & U;
|
|
557
|
+
/**
|
|
558
|
+
* Register a inspector
|
|
559
|
+
* @param inspector
|
|
560
|
+
* @returns
|
|
561
|
+
* @example
|
|
562
|
+
* ```ts
|
|
563
|
+
* Clerc.create()
|
|
564
|
+
* .inspector((ctx, next) => {
|
|
565
|
+
* console.log(ctx);
|
|
566
|
+
* next();
|
|
567
|
+
* })
|
|
568
|
+
* ```
|
|
569
|
+
*/
|
|
570
|
+
inspector(inspector: Inspector): this;
|
|
571
|
+
/**
|
|
572
|
+
* Parse the command line arguments
|
|
573
|
+
* @param args
|
|
574
|
+
* @returns
|
|
575
|
+
* @example
|
|
576
|
+
* ```ts
|
|
577
|
+
* Clerc.create()
|
|
578
|
+
* .parse(process.argv.slice(2)) // Optional
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
parse(optionsOrArgv?: string[] | ParseOptions): this;
|
|
582
|
+
/**
|
|
583
|
+
* Run matched command
|
|
584
|
+
* @returns
|
|
585
|
+
* @example
|
|
586
|
+
* ```ts
|
|
587
|
+
* Clerc.create()
|
|
588
|
+
* .parse({ run: false })
|
|
589
|
+
* .runMatchedCommand()
|
|
590
|
+
* ```
|
|
591
|
+
*/
|
|
592
|
+
runMatchedCommand(): this;
|
|
594
593
|
}
|
|
595
594
|
|
|
596
595
|
type MaybeArray<T> = T | T[];
|
|
597
596
|
|
|
598
|
-
declare const definePlugin: <T extends Clerc<{}, {}>, U extends Clerc<{}, {}>>(p: Plugin<T, U>) => Plugin<T, U>;
|
|
599
|
-
declare const defineHandler: <C extends Clerc<{}, {}>, K extends keyof C["_commands"]>(_cli: C, _key: K, handler: Handler<C["_commands"], K
|
|
600
|
-
declare const defineInspector: <C extends Clerc<{}, {}>>(_cli: C, inspector: Inspector<C["_commands"]>) => Inspector<C["_commands"]>;
|
|
597
|
+
declare const definePlugin: <T extends Clerc<{}, {}>, U extends Clerc<{}, {}>>(p: Plugin<T, U>) => Plugin<T, U>;
|
|
598
|
+
declare const defineHandler: <C extends Clerc<{}, {}>, K extends keyof C["_commands"]>(_cli: C, _key: K, handler: Handler<C["_commands"], K>) => Handler<C["_commands"], K>;
|
|
599
|
+
declare const defineInspector: <C extends Clerc<{}, {}>>(_cli: C, inspector: Inspector<C["_commands"]>) => Inspector<C["_commands"]>;
|
|
601
600
|
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>>;
|
|
602
601
|
|
|
603
|
-
declare class CommandExistsError extends Error {
|
|
604
|
-
commandName: string;
|
|
605
|
-
constructor(commandName: string, t: TranslateFn);
|
|
606
|
-
}
|
|
607
|
-
declare class NoSuchCommandError extends Error {
|
|
608
|
-
commandName: string;
|
|
609
|
-
constructor(commandName: string, t: TranslateFn);
|
|
610
|
-
}
|
|
611
|
-
declare class NoCommandGivenError extends Error {
|
|
612
|
-
constructor(t: TranslateFn);
|
|
613
|
-
}
|
|
614
|
-
declare class CommandNameConflictError extends Error {
|
|
615
|
-
n1: string;
|
|
616
|
-
n2: string;
|
|
617
|
-
constructor(n1: string, n2: string, t: TranslateFn);
|
|
618
|
-
}
|
|
619
|
-
declare class NameNotSetError extends Error {
|
|
620
|
-
constructor(t: TranslateFn);
|
|
621
|
-
}
|
|
622
|
-
declare class DescriptionNotSetError extends Error {
|
|
623
|
-
constructor(t: TranslateFn);
|
|
624
|
-
}
|
|
625
|
-
declare class VersionNotSetError extends Error {
|
|
626
|
-
constructor(t: TranslateFn);
|
|
627
|
-
}
|
|
628
|
-
declare class InvalidCommandNameError extends Error {
|
|
629
|
-
commandName: string;
|
|
630
|
-
constructor(commandName: string, t: TranslateFn);
|
|
631
|
-
}
|
|
632
|
-
declare class LocaleNotCalledFirstError extends Error {
|
|
633
|
-
constructor(t: TranslateFn);
|
|
602
|
+
declare class CommandExistsError extends Error {
|
|
603
|
+
commandName: string;
|
|
604
|
+
constructor(commandName: string, t: TranslateFn);
|
|
605
|
+
}
|
|
606
|
+
declare class NoSuchCommandError extends Error {
|
|
607
|
+
commandName: string;
|
|
608
|
+
constructor(commandName: string, t: TranslateFn);
|
|
609
|
+
}
|
|
610
|
+
declare class NoCommandGivenError extends Error {
|
|
611
|
+
constructor(t: TranslateFn);
|
|
612
|
+
}
|
|
613
|
+
declare class CommandNameConflictError extends Error {
|
|
614
|
+
n1: string;
|
|
615
|
+
n2: string;
|
|
616
|
+
constructor(n1: string, n2: string, t: TranslateFn);
|
|
617
|
+
}
|
|
618
|
+
declare class NameNotSetError extends Error {
|
|
619
|
+
constructor(t: TranslateFn);
|
|
620
|
+
}
|
|
621
|
+
declare class DescriptionNotSetError extends Error {
|
|
622
|
+
constructor(t: TranslateFn);
|
|
623
|
+
}
|
|
624
|
+
declare class VersionNotSetError extends Error {
|
|
625
|
+
constructor(t: TranslateFn);
|
|
626
|
+
}
|
|
627
|
+
declare class InvalidCommandNameError extends Error {
|
|
628
|
+
commandName: string;
|
|
629
|
+
constructor(commandName: string, t: TranslateFn);
|
|
630
|
+
}
|
|
631
|
+
declare class LocaleNotCalledFirstError extends Error {
|
|
632
|
+
constructor(t: TranslateFn);
|
|
634
633
|
}
|
|
635
634
|
|
|
636
|
-
declare function resolveFlattenCommands(commands: Commands, t: TranslateFn): Map<string[] | typeof Root, CommandAlias
|
|
637
|
-
declare function resolveCommand(commands: Commands, argv: string[], t: TranslateFn): [Command<string | RootType> | undefined, string[] | RootType | undefined];
|
|
638
|
-
declare
|
|
639
|
-
declare function
|
|
640
|
-
declare const
|
|
641
|
-
declare const
|
|
642
|
-
declare
|
|
643
|
-
declare const
|
|
644
|
-
declare const withBrackets: (s: string, isOptional?: boolean) => string;
|
|
645
|
-
declare const formatCommandName: (name: string | string[] | RootType) => string;
|
|
646
|
-
declare const detectLocale: () => string;
|
|
635
|
+
declare function resolveFlattenCommands(commands: Commands, t: TranslateFn): Map<string[] | typeof Root, CommandAlias>;
|
|
636
|
+
declare function resolveCommand(commands: Commands, argv: string[], t: TranslateFn): [Command<string | RootType> | undefined, string[] | RootType | undefined];
|
|
637
|
+
declare const resolveArgv: () => string[];
|
|
638
|
+
declare function compose(inspectors: Inspector[]): (ctx: InspectorContext) => void;
|
|
639
|
+
declare const isValidName: (name: CommandType) => boolean;
|
|
640
|
+
declare const withBrackets: (s: string, isOptional?: boolean) => string;
|
|
641
|
+
declare const formatCommandName: (name: string | string[] | RootType) => string;
|
|
642
|
+
declare const detectLocale: () => string;
|
|
647
643
|
declare const stripFlags: (argv: string[]) => string[];
|
|
648
644
|
|
|
649
|
-
interface CompletionsPluginOptions {
|
|
650
|
-
command?: boolean;
|
|
651
|
-
}
|
|
645
|
+
interface CompletionsPluginOptions {
|
|
646
|
+
command?: boolean;
|
|
647
|
+
}
|
|
652
648
|
declare const completionsPlugin: (options?: CompletionsPluginOptions) => Plugin<Clerc<{}, {}>, Clerc<{}, {}>>;
|
|
653
649
|
|
|
654
|
-
interface BlockSection {
|
|
655
|
-
type?: "block";
|
|
656
|
-
title: string;
|
|
657
|
-
body: string[];
|
|
658
|
-
}
|
|
659
|
-
interface InlineSection {
|
|
660
|
-
type: "inline";
|
|
661
|
-
items: {
|
|
662
|
-
title: string;
|
|
663
|
-
body: string;
|
|
664
|
-
}[];
|
|
665
|
-
}
|
|
666
|
-
type Section = BlockSection | InlineSection;
|
|
667
|
-
interface Renderers {
|
|
668
|
-
renderSections?: (sections: Section[]) => Section[];
|
|
669
|
-
renderFlagName?: (name: string) => string;
|
|
670
|
-
renderType?: (type: any, hasDefault: boolean) => string;
|
|
671
|
-
renderDefault?: (default_: any) => string;
|
|
650
|
+
interface BlockSection {
|
|
651
|
+
type?: "block";
|
|
652
|
+
title: string;
|
|
653
|
+
body: string[];
|
|
654
|
+
}
|
|
655
|
+
interface InlineSection {
|
|
656
|
+
type: "inline";
|
|
657
|
+
items: {
|
|
658
|
+
title: string;
|
|
659
|
+
body: string;
|
|
660
|
+
}[];
|
|
661
|
+
}
|
|
662
|
+
type Section = BlockSection | InlineSection;
|
|
663
|
+
interface Renderers {
|
|
664
|
+
renderSections?: (sections: Section[]) => Section[];
|
|
665
|
+
renderFlagName?: (name: string) => string;
|
|
666
|
+
renderType?: (type: any, hasDefault: boolean) => string;
|
|
667
|
+
renderDefault?: (default_: any) => string;
|
|
672
668
|
}
|
|
673
669
|
|
|
674
|
-
declare module "@clerc/core" {
|
|
675
|
-
interface CommandCustomProperties {
|
|
676
|
-
help?:
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
*
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
*
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
*
|
|
697
|
-
*/
|
|
698
|
-
|
|
699
|
-
/**
|
|
700
|
-
* Global
|
|
701
|
-
*/
|
|
702
|
-
|
|
703
|
-
/**
|
|
704
|
-
*
|
|
705
|
-
*/
|
|
706
|
-
|
|
707
|
-
|
|
670
|
+
declare module "@clerc/core" {
|
|
671
|
+
interface CommandCustomProperties {
|
|
672
|
+
help?: {
|
|
673
|
+
renderers?: Renderers;
|
|
674
|
+
examples?: [string, string][];
|
|
675
|
+
notes?: string[];
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
interface HelpPluginOptions {
|
|
680
|
+
/**
|
|
681
|
+
* Whether to register the help command.
|
|
682
|
+
* @default true
|
|
683
|
+
*/
|
|
684
|
+
command?: boolean;
|
|
685
|
+
/**
|
|
686
|
+
* Whether to register the global help flag.
|
|
687
|
+
* @default true
|
|
688
|
+
*/
|
|
689
|
+
flag?: boolean;
|
|
690
|
+
/**
|
|
691
|
+
* Whether to show help when no command is specified.
|
|
692
|
+
* @default true
|
|
693
|
+
*/
|
|
694
|
+
showHelpWhenNoCommand?: boolean;
|
|
695
|
+
/**
|
|
696
|
+
* Global notes.
|
|
697
|
+
*/
|
|
698
|
+
notes?: string[];
|
|
699
|
+
/**
|
|
700
|
+
* Global examples.
|
|
701
|
+
*/
|
|
702
|
+
examples?: [string, string][];
|
|
703
|
+
/**
|
|
704
|
+
* Banner.
|
|
705
|
+
*/
|
|
706
|
+
banner?: string;
|
|
707
|
+
}
|
|
708
708
|
declare const helpPlugin: ({ command, flag, showHelpWhenNoCommand, notes, examples, banner, }?: HelpPluginOptions) => Plugin<Clerc<{}, {}>, Clerc<{}, {}>>;
|
|
709
709
|
|
|
710
710
|
declare const notFoundPlugin: () => Plugin<Clerc<{}, {}>, Clerc<{}, {}>>;
|
|
711
711
|
|
|
712
712
|
declare const strictFlagsPlugin: () => Plugin<Clerc<{}, {}>, Clerc<{}, {}>>;
|
|
713
713
|
|
|
714
|
-
interface VersionPluginOptions {
|
|
715
|
-
/**
|
|
716
|
-
* Whether to register the help command.
|
|
717
|
-
* @default true
|
|
718
|
-
*/
|
|
719
|
-
command?: boolean;
|
|
720
|
-
/**
|
|
721
|
-
* Whether to register the global help flag.
|
|
722
|
-
* @default true
|
|
723
|
-
*/
|
|
724
|
-
flag?: boolean;
|
|
725
|
-
}
|
|
714
|
+
interface VersionPluginOptions {
|
|
715
|
+
/**
|
|
716
|
+
* Whether to register the help command.
|
|
717
|
+
* @default true
|
|
718
|
+
*/
|
|
719
|
+
command?: boolean;
|
|
720
|
+
/**
|
|
721
|
+
* Whether to register the global help flag.
|
|
722
|
+
* @default true
|
|
723
|
+
*/
|
|
724
|
+
flag?: boolean;
|
|
725
|
+
}
|
|
726
726
|
declare const versionPlugin: ({ command, flag, }?: VersionPluginOptions) => Plugin<Clerc<{}, {}>, Clerc<{}, {}>>;
|
|
727
727
|
|
|
728
728
|
declare const friendlyErrorPlugin: () => Plugin<Clerc<{}, {}>, Clerc<{}, {}>>;
|
|
729
729
|
|
|
730
|
-
export { Clerc, Command, CommandAlias, CommandCustomProperties, CommandExistsError, CommandNameConflictError, CommandOptions, CommandType, CommandWithHandler, Commands, CompletionsPluginOptions, DescriptionNotSetError, FallbackType, Flag, FlagOptions,
|
|
730
|
+
export { Clerc, Command, CommandAlias, CommandCustomProperties, CommandExistsError, CommandNameConflictError, CommandOptions, CommandType, CommandWithHandler, Commands, CompletionsPluginOptions, DescriptionNotSetError, FallbackType, Flag, FlagOptions, Flags, GlobalFlagOption, GlobalFlagOptions, Handler, HandlerContext, HandlerInCommand, HelpPluginOptions, I18N, Inspector, InspectorContext, InspectorFn, InspectorObject, InvalidCommandNameError, LocaleNotCalledFirstError, Locales, MakeEventMap, NameNotSetError, NoCommandGivenError, NoSuchCommandError, ParseOptions, Plugin, Root, RootType, TranslateFn, VersionNotSetError, completionsPlugin, compose, defineCommand, defineHandler, defineInspector, definePlugin, detectLocale, formatCommandName, friendlyErrorPlugin, helpPlugin, isValidName, notFoundPlugin, resolveArgv, resolveCommand, resolveFlattenCommands, strictFlagsPlugin, stripFlags, versionPlugin, withBrackets };
|