@shuiyangsuan/cli 0.0.3 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -12,5 +12,967 @@ interface CliConfig {
12
12
  verbose?: boolean;
13
13
  }
14
14
  //#endregion
15
- export { CliConfig };
15
+ //#region node_modules/.pnpm/commander@14.0.3/node_modules/commander/typings/index.d.ts
16
+ // Type definitions for commander
17
+ // Original definitions by: Alan Agius <https://github.com/alan-agius4>, Marcelo Dezem <https://github.com/mdezem>, vvakame <https://github.com/vvakame>, Jules Randolph <https://github.com/sveinburne>
18
+ /* eslint-disable @typescript-eslint/no-explicit-any */
19
+ // This is a trick to encourage editor to suggest the known literals while still
20
+ // allowing any BaseType value.
21
+ // References:
22
+ // - https://github.com/microsoft/TypeScript/issues/29729
23
+ // - https://github.com/sindresorhus/type-fest/blob/main/source/literal-union.d.ts
24
+ // - https://github.com/sindresorhus/type-fest/blob/main/source/primitive.d.ts
25
+ type LiteralUnion<LiteralType, BaseType extends string | number> = LiteralType | (BaseType & Record<never, never>);
26
+ declare class CommanderError extends Error {
27
+ code: string;
28
+ exitCode: number;
29
+ message: string;
30
+ nestedError?: string;
31
+ /**
32
+ * Constructs the CommanderError class
33
+ * @param exitCode - suggested exit code which could be used with process.exit
34
+ * @param code - an id string representing the error
35
+ * @param message - human-readable description of the error
36
+ */
37
+ constructor(exitCode: number, code: string, message: string);
38
+ }
39
+ // deprecated old name
40
+ interface ErrorOptions {
41
+ // optional parameter for error()
42
+ /** an id string representing the error */
43
+ code?: string;
44
+ /** suggested exit code which could be used with process.exit */
45
+ exitCode?: number;
46
+ }
47
+ declare class Argument {
48
+ description: string;
49
+ required: boolean;
50
+ variadic: boolean;
51
+ defaultValue?: any;
52
+ defaultValueDescription?: string;
53
+ parseArg?: <T>(value: string, previous: T) => T;
54
+ argChoices?: string[];
55
+ /**
56
+ * Initialize a new command argument with the given name and description.
57
+ * The default is that the argument is required, and you can explicitly
58
+ * indicate this with <> around the name. Put [] around the name for an optional argument.
59
+ */
60
+ constructor(arg: string, description?: string);
61
+ /**
62
+ * Return argument name.
63
+ */
64
+ name(): string;
65
+ /**
66
+ * Set the default value, and optionally supply the description to be displayed in the help.
67
+ */
68
+ default(value: unknown, description?: string): this;
69
+ /**
70
+ * Set the custom handler for processing CLI command arguments into argument values.
71
+ */
72
+ argParser<T>(fn: (value: string, previous: T) => T): this;
73
+ /**
74
+ * Only allow argument value to be one of choices.
75
+ */
76
+ choices(values: readonly string[]): this;
77
+ /**
78
+ * Make argument required.
79
+ */
80
+ argRequired(): this;
81
+ /**
82
+ * Make argument optional.
83
+ */
84
+ argOptional(): this;
85
+ }
86
+ declare class Option {
87
+ flags: string;
88
+ description: string;
89
+ required: boolean; // A value must be supplied when the option is specified.
90
+ optional: boolean; // A value is optional when the option is specified.
91
+ variadic: boolean;
92
+ mandatory: boolean; // The option must have a value after parsing, which usually means it must be specified on command line.
93
+ short?: string;
94
+ long?: string;
95
+ negate: boolean;
96
+ defaultValue?: any;
97
+ defaultValueDescription?: string;
98
+ presetArg?: unknown;
99
+ envVar?: string;
100
+ parseArg?: <T>(value: string, previous: T) => T;
101
+ hidden: boolean;
102
+ argChoices?: string[];
103
+ helpGroupHeading?: string;
104
+ constructor(flags: string, description?: string);
105
+ /**
106
+ * Set the default value, and optionally supply the description to be displayed in the help.
107
+ */
108
+ default(value: unknown, description?: string): this;
109
+ /**
110
+ * Preset to use when option used without option-argument, especially optional but also boolean and negated.
111
+ * The custom processing (parseArg) is called.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * new Option('--color').default('GREYSCALE').preset('RGB');
116
+ * new Option('--donate [amount]').preset('20').argParser(parseFloat);
117
+ * ```
118
+ */
119
+ preset(arg: unknown): this;
120
+ /**
121
+ * Add option name(s) that conflict with this option.
122
+ * An error will be displayed if conflicting options are found during parsing.
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * new Option('--rgb').conflicts('cmyk');
127
+ * new Option('--js').conflicts(['ts', 'jsx']);
128
+ * ```
129
+ */
130
+ conflicts(names: string | string[]): this;
131
+ /**
132
+ * Specify implied option values for when this option is set and the implied options are not.
133
+ *
134
+ * The custom processing (parseArg) is not called on the implied values.
135
+ *
136
+ * @example
137
+ * program
138
+ * .addOption(new Option('--log', 'write logging information to file'))
139
+ * .addOption(new Option('--trace', 'log extra details').implies({ log: 'trace.txt' }));
140
+ */
141
+ implies(optionValues: OptionValues): this;
142
+ /**
143
+ * Set environment variable to check for option value.
144
+ *
145
+ * An environment variables is only used if when processed the current option value is
146
+ * undefined, or the source of the current value is 'default' or 'config' or 'env'.
147
+ */
148
+ env(name: string): this;
149
+ /**
150
+ * Set the custom handler for processing CLI option arguments into option values.
151
+ */
152
+ argParser<T>(fn: (value: string, previous: T) => T): this;
153
+ /**
154
+ * Whether the option is mandatory and must have a value after parsing.
155
+ */
156
+ makeOptionMandatory(mandatory?: boolean): this;
157
+ /**
158
+ * Hide option in help.
159
+ */
160
+ hideHelp(hide?: boolean): this;
161
+ /**
162
+ * Only allow option value to be one of choices.
163
+ */
164
+ choices(values: readonly string[]): this;
165
+ /**
166
+ * Return option name.
167
+ */
168
+ name(): string;
169
+ /**
170
+ * Return option name, in a camelcase format that can be used
171
+ * as an object attribute key.
172
+ */
173
+ attributeName(): string;
174
+ /**
175
+ * Set the help group heading.
176
+ */
177
+ helpGroup(heading: string): this;
178
+ /**
179
+ * Return whether a boolean option.
180
+ *
181
+ * Options are one of boolean, negated, required argument, or optional argument.
182
+ */
183
+ isBoolean(): boolean;
184
+ }
185
+ declare class Help {
186
+ /** output helpWidth, long lines are wrapped to fit */
187
+ helpWidth?: number;
188
+ minWidthToWrap: number;
189
+ sortSubcommands: boolean;
190
+ sortOptions: boolean;
191
+ showGlobalOptions: boolean;
192
+ constructor();
193
+ /*
194
+ * prepareContext is called by Commander after applying overrides from `Command.configureHelp()`
195
+ * and just before calling `formatHelp()`.
196
+ *
197
+ * Commander just uses the helpWidth and the others are provided for subclasses.
198
+ */
199
+ prepareContext(contextOptions: {
200
+ error?: boolean;
201
+ helpWidth?: number;
202
+ outputHasColors?: boolean;
203
+ }): void;
204
+ /** Get the command term to show in the list of subcommands. */
205
+ subcommandTerm(cmd: Command): string;
206
+ /** Get the command summary to show in the list of subcommands. */
207
+ subcommandDescription(cmd: Command): string;
208
+ /** Get the option term to show in the list of options. */
209
+ optionTerm(option: Option): string;
210
+ /** Get the option description to show in the list of options. */
211
+ optionDescription(option: Option): string;
212
+ /** Get the argument term to show in the list of arguments. */
213
+ argumentTerm(argument: Argument): string;
214
+ /** Get the argument description to show in the list of arguments. */
215
+ argumentDescription(argument: Argument): string;
216
+ /** Get the command usage to be displayed at the top of the built-in help. */
217
+ commandUsage(cmd: Command): string;
218
+ /** Get the description for the command. */
219
+ commandDescription(cmd: Command): string;
220
+ /** Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one. */
221
+ visibleCommands(cmd: Command): Command[];
222
+ /** Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one. */
223
+ visibleOptions(cmd: Command): Option[];
224
+ /** Get an array of the visible global options. (Not including help.) */
225
+ visibleGlobalOptions(cmd: Command): Option[];
226
+ /** Get an array of the arguments which have descriptions. */
227
+ visibleArguments(cmd: Command): Argument[];
228
+ /** Get the longest command term length. */
229
+ longestSubcommandTermLength(cmd: Command, helper: Help): number;
230
+ /** Get the longest option term length. */
231
+ longestOptionTermLength(cmd: Command, helper: Help): number;
232
+ /** Get the longest global option term length. */
233
+ longestGlobalOptionTermLength(cmd: Command, helper: Help): number;
234
+ /** Get the longest argument term length. */
235
+ longestArgumentTermLength(cmd: Command, helper: Help): number;
236
+ /** Return display width of string, ignoring ANSI escape sequences. Used in padding and wrapping calculations. */
237
+ displayWidth(str: string): number;
238
+ /** Style the titles. Called with 'Usage:', 'Options:', etc. */
239
+ styleTitle(title: string): string;
240
+ /** Usage: <str> */
241
+ styleUsage(str: string): string;
242
+ /** Style for command name in usage string. */
243
+ styleCommandText(str: string): string;
244
+ styleCommandDescription(str: string): string;
245
+ styleOptionDescription(str: string): string;
246
+ styleSubcommandDescription(str: string): string;
247
+ styleArgumentDescription(str: string): string;
248
+ /** Base style used by descriptions. */
249
+ styleDescriptionText(str: string): string;
250
+ styleOptionTerm(str: string): string;
251
+ styleSubcommandTerm(str: string): string;
252
+ styleArgumentTerm(str: string): string;
253
+ /** Base style used in terms and usage for options. */
254
+ styleOptionText(str: string): string;
255
+ /** Base style used in terms and usage for subcommands. */
256
+ styleSubcommandText(str: string): string;
257
+ /** Base style used in terms and usage for arguments. */
258
+ styleArgumentText(str: string): string;
259
+ /** Calculate the pad width from the maximum term length. */
260
+ padWidth(cmd: Command, helper: Help): number;
261
+ /**
262
+ * Wrap a string at whitespace, preserving existing line breaks.
263
+ * Wrapping is skipped if the width is less than `minWidthToWrap`.
264
+ */
265
+ boxWrap(str: string, width: number): string;
266
+ /** Detect manually wrapped and indented strings by checking for line break followed by whitespace. */
267
+ preformatted(str: string): boolean;
268
+ /**
269
+ * Format the "item", which consists of a term and description. Pad the term and wrap the description, indenting the following lines.
270
+ *
271
+ * So "TTT", 5, "DDD DDDD DD DDD" might be formatted for this.helpWidth=17 like so:
272
+ * TTT DDD DDDD
273
+ * DD DDD
274
+ */
275
+ formatItem(term: string, termWidth: number, description: string, helper: Help): string;
276
+ /**
277
+ * Format a list of items, given a heading and an array of formatted items.
278
+ */
279
+ formatItemList(heading: string, items: string[], helper: Help): string[];
280
+ /**
281
+ * Group items by their help group heading.
282
+ */
283
+ groupItems<T extends Command | Option>(unsortedItems: T[], visibleItems: T[], getGroup: (item: T) => string): Map<string, T[]>;
284
+ /** Generate the built-in help text. */
285
+ formatHelp(cmd: Command, helper: Help): string;
286
+ }
287
+ type HelpConfiguration = Partial<Help>;
288
+ interface ParseOptions {
289
+ from: 'node' | 'electron' | 'user';
290
+ }
291
+ interface HelpContext {
292
+ // optional parameter for .help() and .outputHelp()
293
+ error: boolean;
294
+ }
295
+ interface AddHelpTextContext {
296
+ // passed to text function used with .addHelpText()
297
+ error: boolean;
298
+ command: Command;
299
+ }
300
+ interface OutputConfiguration {
301
+ writeOut?(str: string): void;
302
+ writeErr?(str: string): void;
303
+ outputError?(str: string, write: (str: string) => void): void;
304
+ getOutHelpWidth?(): number;
305
+ getErrHelpWidth?(): number;
306
+ getOutHasColors?(): boolean;
307
+ getErrHasColors?(): boolean;
308
+ stripColor?(str: string): string;
309
+ }
310
+ type AddHelpTextPosition = 'beforeAll' | 'before' | 'after' | 'afterAll';
311
+ type HookEvent = 'preSubcommand' | 'preAction' | 'postAction';
312
+ // The source is a string so author can define their own too.
313
+ type OptionValueSource = LiteralUnion<'default' | 'config' | 'env' | 'cli' | 'implied', string> | undefined;
314
+ type OptionValues = Record<string, any>;
315
+ declare class Command {
316
+ args: string[];
317
+ processedArgs: any[];
318
+ readonly commands: readonly Command[];
319
+ readonly options: readonly Option[];
320
+ readonly registeredArguments: readonly Argument[];
321
+ parent: Command | null;
322
+ constructor(name?: string);
323
+ /**
324
+ * Set the program version to `str`.
325
+ *
326
+ * This method auto-registers the "-V, --version" flag
327
+ * which will print the version number when passed.
328
+ *
329
+ * You can optionally supply the flags and description to override the defaults.
330
+ */
331
+ version(str: string, flags?: string, description?: string): this;
332
+ /**
333
+ * Get the program version.
334
+ */
335
+ version(): string | undefined;
336
+ /**
337
+ * Define a command, implemented using an action handler.
338
+ *
339
+ * @remarks
340
+ * The command description is supplied using `.description`, not as a parameter to `.command`.
341
+ *
342
+ * @example
343
+ * ```ts
344
+ * program
345
+ * .command('clone <source> [destination]')
346
+ * .description('clone a repository into a newly created directory')
347
+ * .action((source, destination) => {
348
+ * console.log('clone command called');
349
+ * });
350
+ * ```
351
+ *
352
+ * @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
353
+ * @param opts - configuration options
354
+ * @returns new command
355
+ */
356
+ command(nameAndArgs: string, opts?: CommandOptions): ReturnType<this['createCommand']>;
357
+ /**
358
+ * Define a command, implemented in a separate executable file.
359
+ *
360
+ * @remarks
361
+ * The command description is supplied as the second parameter to `.command`.
362
+ *
363
+ * @example
364
+ * ```ts
365
+ * program
366
+ * .command('start <service>', 'start named service')
367
+ * .command('stop [service]', 'stop named service, or all if no name supplied');
368
+ * ```
369
+ *
370
+ * @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
371
+ * @param description - description of executable command
372
+ * @param opts - configuration options
373
+ * @returns `this` command for chaining
374
+ */
375
+ command(nameAndArgs: string, description: string, opts?: ExecutableCommandOptions): this;
376
+ /**
377
+ * Factory routine to create a new unattached command.
378
+ *
379
+ * See .command() for creating an attached subcommand, which uses this routine to
380
+ * create the command. You can override createCommand to customise subcommands.
381
+ */
382
+ createCommand(name?: string): Command;
383
+ /**
384
+ * Add a prepared subcommand.
385
+ *
386
+ * See .command() for creating an attached subcommand which inherits settings from its parent.
387
+ *
388
+ * @returns `this` command for chaining
389
+ */
390
+ addCommand(cmd: Command, opts?: CommandOptions): this;
391
+ /**
392
+ * Factory routine to create a new unattached argument.
393
+ *
394
+ * See .argument() for creating an attached argument, which uses this routine to
395
+ * create the argument. You can override createArgument to return a custom argument.
396
+ */
397
+ createArgument(name: string, description?: string): Argument;
398
+ /**
399
+ * Define argument syntax for command.
400
+ *
401
+ * The default is that the argument is required, and you can explicitly
402
+ * indicate this with <> around the name. Put [] around the name for an optional argument.
403
+ *
404
+ * @example
405
+ * ```
406
+ * program.argument('<input-file>');
407
+ * program.argument('[output-file]');
408
+ * ```
409
+ *
410
+ * @returns `this` command for chaining
411
+ */
412
+ argument<T>(flags: string, description: string, parseArg: (value: string, previous: T) => T, defaultValue?: T): this;
413
+ argument(name: string, description?: string, defaultValue?: unknown): this;
414
+ /**
415
+ * Define argument syntax for command, adding a prepared argument.
416
+ *
417
+ * @returns `this` command for chaining
418
+ */
419
+ addArgument(arg: Argument): this;
420
+ /**
421
+ * Define argument syntax for command, adding multiple at once (without descriptions).
422
+ *
423
+ * See also .argument().
424
+ *
425
+ * @example
426
+ * ```
427
+ * program.arguments('<cmd> [env]');
428
+ * ```
429
+ *
430
+ * @returns `this` command for chaining
431
+ */
432
+ arguments(names: string): this;
433
+ /**
434
+ * Customise or override default help command. By default a help command is automatically added if your command has subcommands.
435
+ *
436
+ * @example
437
+ * ```ts
438
+ * program.helpCommand('help [cmd]');
439
+ * program.helpCommand('help [cmd]', 'show help');
440
+ * program.helpCommand(false); // suppress default help command
441
+ * program.helpCommand(true); // add help command even if no subcommands
442
+ * ```
443
+ */
444
+ helpCommand(nameAndArgs: string, description?: string): this;
445
+ helpCommand(enable: boolean): this;
446
+ /**
447
+ * Add prepared custom help command.
448
+ */
449
+ addHelpCommand(cmd: Command): this;
450
+ /** @deprecated since v12, instead use helpCommand */
451
+ addHelpCommand(nameAndArgs: string, description?: string): this;
452
+ /** @deprecated since v12, instead use helpCommand */
453
+ addHelpCommand(enable?: boolean): this;
454
+ /**
455
+ * Add hook for life cycle event.
456
+ */
457
+ hook(event: HookEvent, listener: (thisCommand: Command, actionCommand: Command) => void | Promise<void>): this;
458
+ /**
459
+ * Register callback to use as replacement for calling process.exit.
460
+ */
461
+ exitOverride(callback?: (err: CommanderError) => never | void): this;
462
+ /**
463
+ * Display error message and exit (or call exitOverride).
464
+ */
465
+ error(message: string, errorOptions?: ErrorOptions): never;
466
+ /**
467
+ * You can customise the help with a subclass of Help by overriding createHelp,
468
+ * or by overriding Help properties using configureHelp().
469
+ */
470
+ createHelp(): Help;
471
+ /**
472
+ * You can customise the help by overriding Help properties using configureHelp(),
473
+ * or with a subclass of Help by overriding createHelp().
474
+ */
475
+ configureHelp(configuration: HelpConfiguration): this;
476
+ /** Get configuration */
477
+ configureHelp(): HelpConfiguration;
478
+ /**
479
+ * The default output goes to stdout and stderr. You can customise this for special
480
+ * applications. You can also customise the display of errors by overriding outputError.
481
+ *
482
+ * The configuration properties are all functions:
483
+ * ```
484
+ * // functions to change where being written, stdout and stderr
485
+ * writeOut(str)
486
+ * writeErr(str)
487
+ * // matching functions to specify width for wrapping help
488
+ * getOutHelpWidth()
489
+ * getErrHelpWidth()
490
+ * // functions based on what is being written out
491
+ * outputError(str, write) // used for displaying errors, and not used for displaying help
492
+ * ```
493
+ */
494
+ configureOutput(configuration: OutputConfiguration): this;
495
+ /** Get configuration */
496
+ configureOutput(): OutputConfiguration;
497
+ /**
498
+ * Copy settings that are useful to have in common across root command and subcommands.
499
+ *
500
+ * (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
501
+ */
502
+ copyInheritedSettings(sourceCommand: Command): this;
503
+ /**
504
+ * Display the help or a custom message after an error occurs.
505
+ */
506
+ showHelpAfterError(displayHelp?: boolean | string): this;
507
+ /**
508
+ * Display suggestion of similar commands for unknown commands, or options for unknown options.
509
+ */
510
+ showSuggestionAfterError(displaySuggestion?: boolean): this;
511
+ /**
512
+ * Register callback `fn` for the command.
513
+ *
514
+ * @example
515
+ * ```
516
+ * program
517
+ * .command('serve')
518
+ * .description('start service')
519
+ * .action(function() {
520
+ * // do work here
521
+ * });
522
+ * ```
523
+ *
524
+ * @returns `this` command for chaining
525
+ */
526
+ action(fn: (this: this, ...args: any[]) => void | Promise<void>): this;
527
+ /**
528
+ * Define option with `flags`, `description`, and optional argument parsing function or `defaultValue` or both.
529
+ *
530
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space. A required
531
+ * option-argument is indicated by `<>` and an optional option-argument by `[]`.
532
+ *
533
+ * See the README for more details, and see also addOption() and requiredOption().
534
+ *
535
+ * @example
536
+ *
537
+ * ```js
538
+ * program
539
+ * .option('-p, --pepper', 'add pepper')
540
+ * .option('--pt, --pizza-type <TYPE>', 'type of pizza') // required option-argument
541
+ * .option('-c, --cheese [CHEESE]', 'add extra cheese', 'mozzarella') // optional option-argument with default
542
+ * .option('-t, --tip <VALUE>', 'add tip to purchase cost', parseFloat) // custom parse function
543
+ * ```
544
+ *
545
+ * @returns `this` command for chaining
546
+ */
547
+ option(flags: string, description?: string, defaultValue?: string | boolean | string[]): this;
548
+ option<T>(flags: string, description: string, parseArg: (value: string, previous: T) => T, defaultValue?: T): this;
549
+ /** @deprecated since v7, instead use choices or a custom function */
550
+ option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean | string[]): this;
551
+ /**
552
+ * Define a required option, which must have a value after parsing. This usually means
553
+ * the option must be specified on the command line. (Otherwise the same as .option().)
554
+ *
555
+ * The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
556
+ */
557
+ requiredOption(flags: string, description?: string, defaultValue?: string | boolean | string[]): this;
558
+ requiredOption<T>(flags: string, description: string, parseArg: (value: string, previous: T) => T, defaultValue?: T): this;
559
+ /** @deprecated since v7, instead use choices or a custom function */
560
+ requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean | string[]): this;
561
+ /**
562
+ * Factory routine to create a new unattached option.
563
+ *
564
+ * See .option() for creating an attached option, which uses this routine to
565
+ * create the option. You can override createOption to return a custom option.
566
+ */
567
+ createOption(flags: string, description?: string): Option;
568
+ /**
569
+ * Add a prepared Option.
570
+ *
571
+ * See .option() and .requiredOption() for creating and attaching an option in a single call.
572
+ */
573
+ addOption(option: Option): this;
574
+ /**
575
+ * Whether to store option values as properties on command object,
576
+ * or store separately (specify false). In both cases the option values can be accessed using .opts().
577
+ *
578
+ * @returns `this` command for chaining
579
+ */
580
+ storeOptionsAsProperties<T extends OptionValues>(): this & T;
581
+ storeOptionsAsProperties<T extends OptionValues>(storeAsProperties: true): this & T;
582
+ storeOptionsAsProperties(storeAsProperties?: boolean): this;
583
+ /**
584
+ * Retrieve option value.
585
+ */
586
+ getOptionValue(key: string): any;
587
+ /**
588
+ * Store option value.
589
+ */
590
+ setOptionValue(key: string, value: unknown): this;
591
+ /**
592
+ * Store option value and where the value came from.
593
+ */
594
+ setOptionValueWithSource(key: string, value: unknown, source: OptionValueSource): this;
595
+ /**
596
+ * Get source of option value.
597
+ */
598
+ getOptionValueSource(key: string): OptionValueSource | undefined;
599
+ /**
600
+ * Get source of option value. See also .optsWithGlobals().
601
+ */
602
+ getOptionValueSourceWithGlobals(key: string): OptionValueSource | undefined;
603
+ /**
604
+ * Alter parsing of short flags with optional values.
605
+ *
606
+ * @example
607
+ * ```
608
+ * // for `.option('-f,--flag [value]'):
609
+ * .combineFlagAndOptionalValue(true) // `-f80` is treated like `--flag=80`, this is the default behaviour
610
+ * .combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
611
+ * ```
612
+ *
613
+ * @returns `this` command for chaining
614
+ */
615
+ combineFlagAndOptionalValue(combine?: boolean): this;
616
+ /**
617
+ * Allow unknown options on the command line.
618
+ *
619
+ * @returns `this` command for chaining
620
+ */
621
+ allowUnknownOption(allowUnknown?: boolean): this;
622
+ /**
623
+ * Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
624
+ *
625
+ * @returns `this` command for chaining
626
+ */
627
+ allowExcessArguments(allowExcess?: boolean): this;
628
+ /**
629
+ * Enable positional options. Positional means global options are specified before subcommands which lets
630
+ * subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
631
+ *
632
+ * The default behaviour is non-positional and global options may appear anywhere on the command line.
633
+ *
634
+ * @returns `this` command for chaining
635
+ */
636
+ enablePositionalOptions(positional?: boolean): this;
637
+ /**
638
+ * Pass through options that come after command-arguments rather than treat them as command-options,
639
+ * so actual command-options come before command-arguments. Turning this on for a subcommand requires
640
+ * positional options to have been enabled on the program (parent commands).
641
+ *
642
+ * The default behaviour is non-positional and options may appear before or after command-arguments.
643
+ *
644
+ * @returns `this` command for chaining
645
+ */
646
+ passThroughOptions(passThrough?: boolean): this;
647
+ /**
648
+ * Parse `argv`, setting options and invoking commands when defined.
649
+ *
650
+ * Use parseAsync instead of parse if any of your action handlers are async.
651
+ *
652
+ * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
653
+ *
654
+ * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
655
+ * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
656
+ * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
657
+ * - `'user'`: just user arguments
658
+ *
659
+ * @example
660
+ * ```
661
+ * program.parse(); // parse process.argv and auto-detect electron and special node flags
662
+ * program.parse(process.argv); // assume argv[0] is app and argv[1] is script
663
+ * program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
664
+ * ```
665
+ *
666
+ * @returns `this` command for chaining
667
+ */
668
+ parse(argv?: readonly string[], parseOptions?: ParseOptions): this;
669
+ /**
670
+ * Parse `argv`, setting options and invoking commands when defined.
671
+ *
672
+ * Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
673
+ *
674
+ * Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
675
+ * - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
676
+ * - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
677
+ * - `'user'`: just user arguments
678
+ *
679
+ * @example
680
+ * ```
681
+ * await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
682
+ * await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
683
+ * await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
684
+ * ```
685
+ *
686
+ * @returns Promise
687
+ */
688
+ parseAsync(argv?: readonly string[], parseOptions?: ParseOptions): Promise<this>;
689
+ /**
690
+ * Called the first time parse is called to save state and allow a restore before subsequent calls to parse.
691
+ * Not usually called directly, but available for subclasses to save their custom state.
692
+ *
693
+ * This is called in a lazy way. Only commands used in parsing chain will have state saved.
694
+ */
695
+ saveStateBeforeParse(): void;
696
+ /**
697
+ * Restore state before parse for calls after the first.
698
+ * Not usually called directly, but available for subclasses to save their custom state.
699
+ *
700
+ * This is called in a lazy way. Only commands used in parsing chain will have state restored.
701
+ */
702
+ restoreStateBeforeParse(): void;
703
+ /**
704
+ * Parse options from `argv` removing known options,
705
+ * and return argv split into operands and unknown arguments.
706
+ *
707
+ * Side effects: modifies command by storing options. Does not reset state if called again.
708
+ *
709
+ * argv => operands, unknown
710
+ * --known kkk op => [op], []
711
+ * op --known kkk => [op], []
712
+ * sub --unknown uuu op => [sub], [--unknown uuu op]
713
+ * sub -- --unknown uuu op => [sub --unknown uuu op], []
714
+ */
715
+ parseOptions(argv: string[]): ParseOptionsResult;
716
+ /**
717
+ * Return an object containing local option values as key-value pairs
718
+ */
719
+ opts<T extends OptionValues>(): T;
720
+ /**
721
+ * Return an object containing merged local and global option values as key-value pairs.
722
+ */
723
+ optsWithGlobals<T extends OptionValues>(): T;
724
+ /**
725
+ * Set the description.
726
+ *
727
+ * @returns `this` command for chaining
728
+ */
729
+ description(str: string): this;
730
+ /** @deprecated since v8, instead use .argument to add command argument with description */
731
+ description(str: string, argsDescription: Record<string, string>): this;
732
+ /**
733
+ * Get the description.
734
+ */
735
+ description(): string;
736
+ /**
737
+ * Set the summary. Used when listed as subcommand of parent.
738
+ *
739
+ * @returns `this` command for chaining
740
+ */
741
+ summary(str: string): this;
742
+ /**
743
+ * Get the summary.
744
+ */
745
+ summary(): string;
746
+ /**
747
+ * Set an alias for the command.
748
+ *
749
+ * You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
750
+ *
751
+ * @returns `this` command for chaining
752
+ */
753
+ alias(alias: string): this;
754
+ /**
755
+ * Get alias for the command.
756
+ */
757
+ alias(): string;
758
+ /**
759
+ * Set aliases for the command.
760
+ *
761
+ * Only the first alias is shown in the auto-generated help.
762
+ *
763
+ * @returns `this` command for chaining
764
+ */
765
+ aliases(aliases: readonly string[]): this;
766
+ /**
767
+ * Get aliases for the command.
768
+ */
769
+ aliases(): string[];
770
+ /**
771
+ * Set the command usage.
772
+ *
773
+ * @returns `this` command for chaining
774
+ */
775
+ usage(str: string): this;
776
+ /**
777
+ * Get the command usage.
778
+ */
779
+ usage(): string;
780
+ /**
781
+ * Set the name of the command.
782
+ *
783
+ * @returns `this` command for chaining
784
+ */
785
+ name(str: string): this;
786
+ /**
787
+ * Get the name of the command.
788
+ */
789
+ name(): string;
790
+ /**
791
+ * Set the name of the command from script filename, such as process.argv[1],
792
+ * or require.main.filename, or __filename.
793
+ *
794
+ * (Used internally and public although not documented in README.)
795
+ *
796
+ * @example
797
+ * ```ts
798
+ * program.nameFromFilename(require.main.filename);
799
+ * ```
800
+ *
801
+ * @returns `this` command for chaining
802
+ */
803
+ nameFromFilename(filename: string): this;
804
+ /**
805
+ * Set the directory for searching for executable subcommands of this command.
806
+ *
807
+ * @example
808
+ * ```ts
809
+ * program.executableDir(__dirname);
810
+ * // or
811
+ * program.executableDir('subcommands');
812
+ * ```
813
+ *
814
+ * @returns `this` command for chaining
815
+ */
816
+ executableDir(path: string): this;
817
+ /**
818
+ * Get the executable search directory.
819
+ */
820
+ executableDir(): string | null;
821
+ /**
822
+ * Set the help group heading for this subcommand in parent command's help.
823
+ *
824
+ * @returns `this` command for chaining
825
+ */
826
+ helpGroup(heading: string): this;
827
+ /**
828
+ * Get the help group heading for this subcommand in parent command's help.
829
+ */
830
+ helpGroup(): string;
831
+ /**
832
+ * Set the default help group heading for subcommands added to this command.
833
+ * (This does not override a group set directly on the subcommand using .helpGroup().)
834
+ *
835
+ * @example
836
+ * program.commandsGroup('Development Commands:);
837
+ * program.command('watch')...
838
+ * program.command('lint')...
839
+ * ...
840
+ *
841
+ * @returns `this` command for chaining
842
+ */
843
+ commandsGroup(heading: string): this;
844
+ /**
845
+ * Get the default help group heading for subcommands added to this command.
846
+ */
847
+ commandsGroup(): string;
848
+ /**
849
+ * Set the default help group heading for options added to this command.
850
+ * (This does not override a group set directly on the option using .helpGroup().)
851
+ *
852
+ * @example
853
+ * program
854
+ * .optionsGroup('Development Options:')
855
+ * .option('-d, --debug', 'output extra debugging')
856
+ * .option('-p, --profile', 'output profiling information')
857
+ *
858
+ * @returns `this` command for chaining
859
+ */
860
+ optionsGroup(heading: string): this;
861
+ /**
862
+ * Get the default help group heading for options added to this command.
863
+ */
864
+ optionsGroup(): string;
865
+ /**
866
+ * Output help information for this command.
867
+ *
868
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
869
+ *
870
+ */
871
+ outputHelp(context?: HelpContext): void;
872
+ /** @deprecated since v7 */
873
+ outputHelp(cb: (str: string) => string): void;
874
+ /**
875
+ * Return command help documentation.
876
+ */
877
+ helpInformation(context?: HelpContext): string;
878
+ /**
879
+ * You can pass in flags and a description to override the help
880
+ * flags and help description for your command. Pass in false
881
+ * to disable the built-in help option.
882
+ */
883
+ helpOption(flags?: string | boolean, description?: string): this;
884
+ /**
885
+ * Supply your own option to use for the built-in help option.
886
+ * This is an alternative to using helpOption() to customise the flags and description etc.
887
+ */
888
+ addHelpOption(option: Option): this;
889
+ /**
890
+ * Output help information and exit.
891
+ *
892
+ * Outputs built-in help, and custom text added using `.addHelpText()`.
893
+ */
894
+ help(context?: HelpContext): never;
895
+ /** @deprecated since v7 */
896
+ help(cb: (str: string) => string): never;
897
+ /**
898
+ * Add additional text to be displayed with the built-in help.
899
+ *
900
+ * Position is 'before' or 'after' to affect just this command,
901
+ * and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
902
+ */
903
+ addHelpText(position: AddHelpTextPosition, text: string): this;
904
+ addHelpText(position: AddHelpTextPosition, text: (context: AddHelpTextContext) => string): this;
905
+ /**
906
+ * Add a listener (callback) for when events occur. (Implemented using EventEmitter.)
907
+ */
908
+ on(event: string | symbol, listener: (...args: any[]) => void): this;
909
+ }
910
+ interface CommandOptions {
911
+ hidden?: boolean;
912
+ isDefault?: boolean;
913
+ /** @deprecated since v7, replaced by hidden */
914
+ noHelp?: boolean;
915
+ }
916
+ interface ExecutableCommandOptions extends CommandOptions {
917
+ executableFile?: string;
918
+ }
919
+ interface ParseOptionsResult {
920
+ operands: string[];
921
+ unknown: string[];
922
+ }
923
+ //#endregion
924
+ //#region src/commands/delete.d.ts
925
+ interface DeleteOptions {
926
+ force?: boolean;
927
+ dryRun?: boolean;
928
+ verbose?: boolean;
929
+ useDefaults?: boolean;
930
+ }
931
+ interface DeleteResult {
932
+ /** 成功删除的数量 */
933
+ deletedCount: number;
934
+ /** 失败的数量 */
935
+ failedCount: number;
936
+ /** 删除的文件列表 */
937
+ deletedFiles: string[];
938
+ /** 错误信息列表 */
939
+ errors: string[];
940
+ }
941
+ /**
942
+ * 执行删除操作(编程模式)
943
+ * @param patterns - 文件或文件夹路径/模式
944
+ * @param config - CLI 配置
945
+ * @param options - 删除选项
946
+ * @returns 删除结果
947
+ * @example
948
+ * ```ts
949
+ * import { executeDelete } from '@shuiyangsuan/cli';
950
+ *
951
+ * const result = await executeDelete(['node_modules', 'dist'], config, { force: true, verbose: true });
952
+ * console.log(`删除了 ${result.deletedCount} 个文件`);
953
+ * ```
954
+ */
955
+ declare function executeDelete(patterns: string[], config: CliConfig, options?: DeleteOptions): Promise<DeleteResult>;
956
+ /**
957
+ * 注册 delete 命令到 CLI
958
+ * @param program - Commander 程序实例
959
+ * @param config - CLI 配置
960
+ */
961
+ declare function deleteCommand(program: Command, config: CliConfig): void;
962
+ /**
963
+ * 收集要删除的文件列表
964
+ * @param patterns - 文件或文件夹路径/模式
965
+ * @param options - 删除选项
966
+ * @returns 匹配的文件路径列表
967
+ */
968
+ declare function collectFilesToDelete(patterns: string[], _options: DeleteOptions): Promise<string[]>;
969
+ //#endregion
970
+ //#region src/config/index.d.ts
971
+ /**
972
+ * 读取配置文件
973
+ * @returns 配置对象
974
+ */
975
+ declare function readConfig(): Promise<CliConfig>;
976
+ //#endregion
977
+ export { CliConfig, type DeleteOptions, type DeleteResult, collectFilesToDelete, deleteCommand, executeDelete, readConfig };
16
978
  //# sourceMappingURL=index.d.ts.map