@modern-js/utils 1.3.6 → 1.3.8-canary.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.js +9 -0
- package/CHANGELOG.md +6 -0
- package/compiled/browserslist/index.d.ts +178 -0
- package/compiled/browserslist/index.js +1 -0
- package/compiled/browserslist/license +20 -0
- package/compiled/browserslist/package.json +1 -0
- package/compiled/chalk/index.d.ts +415 -0
- package/compiled/chalk/index.js +1 -0
- package/compiled/chalk/license +9 -0
- package/compiled/chalk/package.json +1 -0
- package/compiled/chokidar/anymatch/index.d.ts +19 -0
- package/compiled/chokidar/fsevents.node +0 -0
- package/compiled/chokidar/index.js +40 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/compiled/chokidar/types/index.d.ts +188 -0
- package/compiled/commander/index.js +1 -0
- package/compiled/commander/license +22 -0
- package/compiled/commander/package.json +1 -0
- package/compiled/commander/typings/index.d.ts +774 -0
- package/compiled/debug/index.d.ts +54 -0
- package/compiled/debug/index.js +1 -0
- package/compiled/debug/license +20 -0
- package/compiled/debug/ms/index.d.ts +25 -0
- package/compiled/debug/package.json +1 -0
- package/compiled/execa/index.d.ts +564 -0
- package/compiled/execa/index.js +1 -0
- package/compiled/execa/license +9 -0
- package/compiled/execa/package.json +1 -0
- package/compiled/filesize/filesize.d.ts +131 -0
- package/compiled/filesize/index.js +9 -0
- package/compiled/filesize/license +28 -0
- package/compiled/filesize/package.json +1 -0
- package/compiled/fs-extra/index.d.ts +563 -0
- package/compiled/fs-extra/index.js +1 -0
- package/compiled/fs-extra/license +15 -0
- package/compiled/fs-extra/package.json +1 -0
- package/compiled/glob/index.d.ts +91 -0
- package/compiled/glob/index.js +1 -0
- package/compiled/glob/license +21 -0
- package/compiled/glob/minimatch/index.d.ts +204 -0
- package/compiled/glob/package.json +1 -0
- package/compiled/gzip-size/index.d.ts +96 -0
- package/compiled/gzip-size/index.js +1 -0
- package/compiled/gzip-size/license +9 -0
- package/compiled/gzip-size/package.json +1 -0
- package/compiled/import-lazy/index.d.ts +26 -0
- package/compiled/import-lazy/index.js +1 -0
- package/compiled/import-lazy/license +9 -0
- package/compiled/import-lazy/package.json +1 -0
- package/compiled/js-yaml/index.d.ts +154 -0
- package/compiled/js-yaml/index.js +1 -0
- package/compiled/js-yaml/license +21 -0
- package/compiled/js-yaml/package.json +1 -0
- package/compiled/lodash/common/array.d.ts +2126 -0
- package/compiled/lodash/common/collection.d.ts +1930 -0
- package/compiled/lodash/common/common.d.ts +280 -0
- package/compiled/lodash/common/date.d.ts +23 -0
- package/compiled/lodash/common/function.d.ts +1446 -0
- package/compiled/lodash/common/lang.d.ts +1693 -0
- package/compiled/lodash/common/math.d.ts +405 -0
- package/compiled/lodash/common/number.d.ts +131 -0
- package/compiled/lodash/common/object.d.ts +2519 -0
- package/compiled/lodash/common/seq.d.ts +210 -0
- package/compiled/lodash/common/string.d.ts +788 -0
- package/compiled/lodash/common/util.d.ts +1220 -0
- package/compiled/lodash/index.d.ts +46 -0
- package/compiled/lodash/index.js +9 -0
- package/compiled/lodash/license +47 -0
- package/compiled/lodash/package.json +1 -0
- package/compiled/pkg-up/index.d.ts +48 -0
- package/compiled/pkg-up/index.js +1 -0
- package/compiled/pkg-up/license +9 -0
- package/compiled/pkg-up/package.json +1 -0
- package/compiled/recursive-readdir/index.d.ts +21 -0
- package/compiled/recursive-readdir/index.js +1 -0
- package/compiled/recursive-readdir/license +21 -0
- package/compiled/recursive-readdir/package.json +1 -0
- package/compiled/signale/index.d.ts +162 -0
- package/compiled/signale/index.js +1 -0
- package/compiled/signale/package.json +1 -0
- package/compiled/strip-ansi/index.d.ts +17 -0
- package/compiled/strip-ansi/index.js +1 -0
- package/compiled/strip-ansi/license +9 -0
- package/compiled/strip-ansi/package.json +1 -0
- package/compiled/upath/index.js +1 -0
- package/compiled/upath/license +22 -0
- package/compiled/upath/package.json +1 -0
- package/compiled/upath/upath.d.ts +241 -0
- package/dist/FileSizeReporter.d.ts +16 -0
- package/dist/FileSizeReporter.js +151 -0
- package/dist/alias.d.ts +21 -0
- package/dist/alias.js +62 -0
- package/dist/applyOptionsChain.d.ts +6 -0
- package/dist/applyOptionsChain.js +30 -0
- package/dist/clearConsole.d.ts +1 -0
- package/dist/clearConsole.js +9 -0
- package/dist/compatRequire.d.ts +8 -0
- package/dist/compatRequire.js +28 -0
- package/dist/compiled.d.ts +21 -0
- package/dist/compiled.js +33 -0
- package/dist/constants.d.ts +222 -0
- package/dist/constants.js +277 -0
- package/dist/{js/modern/debug.js → debug.d.ts} +1 -3
- package/dist/debug.js +11 -0
- package/dist/emptyDir.d.ts +1 -0
- package/dist/emptyDir.js +19 -0
- package/dist/{js/modern/ensureAbsolutePath.js → ensureAbsolutePath.d.ts} +1 -3
- package/dist/ensureAbsolutePath.js +15 -0
- package/dist/findExists.d.ts +6 -0
- package/dist/findExists.js +21 -0
- package/dist/format.d.ts +16 -0
- package/dist/format.js +113 -0
- package/dist/generateMetaTags.d.ts +16 -0
- package/dist/generateMetaTags.js +48 -0
- package/dist/getBrowserslist.d.ts +2 -0
- package/dist/getBrowserslist.js +7 -0
- package/dist/getCacheIdentifier.d.ts +7 -0
- package/dist/getCacheIdentifier.js +24 -0
- package/dist/getEntryOptions.d.ts +1 -0
- package/dist/getEntryOptions.js +26 -0
- package/dist/getPackageManager.d.ts +1 -0
- package/dist/getPackageManager.js +47 -0
- package/dist/getPort.d.ts +7 -0
- package/dist/getPort.js +62 -0
- package/dist/getServerConfig.d.ts +1 -0
- package/dist/getServerConfig.js +39 -0
- package/dist/import.d.ts +5 -0
- package/dist/import.js +10 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +45 -0
- package/dist/is/index.d.ts +34 -0
- package/dist/is/index.js +82 -0
- package/dist/is/node-env.d.ts +4 -0
- package/dist/is/node-env.js +12 -0
- package/dist/is/platform.d.ts +2 -0
- package/dist/is/platform.js +10 -0
- package/dist/is/type.d.ts +8 -0
- package/dist/is/type.js +38 -0
- package/dist/js/modern/monorepo.js +4 -5
- package/dist/js/node/monorepo.js +5 -7
- package/dist/js/treeshaking/monorepo.js +7 -6
- package/dist/logger.d.ts +63 -0
- package/dist/logger.js +128 -0
- package/dist/monorepo.d.ts +11 -0
- package/dist/monorepo.js +80 -0
- package/dist/nodeEnv.d.ts +3 -0
- package/dist/nodeEnv.js +49 -0
- package/dist/path.d.ts +3 -0
- package/dist/path.js +14 -0
- package/dist/{types/pkgUp.d.ts → pkgUp.d.ts} +1 -1
- package/dist/pkgUp.js +8 -0
- package/dist/prettyInstructions.d.ts +6 -0
- package/dist/prettyInstructions.js +64 -0
- package/dist/printBuildError.d.ts +8 -0
- package/dist/printBuildError.js +43 -0
- package/dist/readTsConfig.d.ts +2 -0
- package/dist/readTsConfig.js +19 -0
- package/dist/removeSlash.d.ts +3 -0
- package/dist/removeSlash.js +9 -0
- package/dist/runtimeExports.d.ts +4 -0
- package/dist/runtimeExports.js +53 -0
- package/dist/ssrHelpers.d.ts +4 -0
- package/dist/ssrHelpers.js +7 -0
- package/dist/storage.d.ts +5 -0
- package/dist/storage.js +61 -0
- package/dist/types/FileSizeReporter.d.ts +5 -5
- package/dist/types/alias.d.ts +12 -14
- package/dist/types/applyOptionsChain.d.ts +5 -5
- package/dist/types/clearConsole.d.ts +1 -1
- package/dist/types/compatRequire.d.ts +1 -1
- package/dist/types/compiled.d.ts +17 -0
- package/dist/types/constants.d.ts +165 -162
- package/dist/types/debug.d.ts +1 -3
- package/dist/types/emptyDir.d.ts +1 -1
- package/dist/types/ensureAbsolutePath.d.ts +1 -1
- package/dist/types/findExists.d.ts +1 -1
- package/dist/types/format.d.ts +5 -5
- package/dist/types/generateMetaTags.d.ts +3 -3
- package/dist/types/getBrowserslist.d.ts +1 -1
- package/dist/types/getCacheIdentifier.d.ts +3 -3
- package/dist/types/getEntryOptions.d.ts +1 -1
- package/dist/types/getPackageManager.d.ts +1 -1
- package/dist/types/getPort.d.ts +1 -1
- package/dist/types/getServerConfig.d.ts +1 -0
- package/dist/types/import.d.ts +2 -2
- package/dist/types/index.d.ts +3 -4
- package/dist/types/is/index.d.ts +1 -4
- package/dist/types/is/node-env.d.ts +1 -1
- package/dist/types/is/platform.d.ts +1 -1
- package/dist/types/is/type.d.ts +1 -1
- package/dist/types/logger.d.ts +49 -49
- package/dist/types/monorepo.d.ts +3 -3
- package/dist/types/nodeEnv.d.ts +1 -1
- package/dist/types/path.d.ts +1 -1
- package/dist/types/prettyInstructions.d.ts +2 -2
- package/dist/types/printBuildError.d.ts +1 -1
- package/dist/types/readTsConfig.d.ts +1 -1
- package/dist/types/removeSlash.d.ts +1 -1
- package/dist/types/runtimeExports.d.ts +3 -3
- package/dist/types/wait.d.ts +1 -1
- package/dist/types/watch.d.ts +4 -4
- package/dist/wait.d.ts +2 -0
- package/dist/wait.js +7 -0
- package/dist/watch.d.ts +8 -0
- package/dist/watch.js +64 -0
- package/jest.config.js +0 -1
- package/package.json +57 -40
- package/tests/debug.test.ts +2 -2
- package/tests/is.test.ts +27 -0
- package/tests/isPlatform.test.ts +19 -0
- package/tests/prettyInstructions.test.ts +1 -1
- package/tsconfig.json +3 -5
- package/dist/js/modern/FileSizeReporter.js +0 -156
- package/dist/js/modern/alias.js +0 -74
- package/dist/js/modern/applyOptionsChain.js +0 -27
- package/dist/js/modern/chalk.js +0 -2
- package/dist/js/modern/clearConsole.js +0 -5
- package/dist/js/modern/compatRequire.js +0 -26
- package/dist/js/modern/constants.js +0 -333
- package/dist/js/modern/emptyDir.js +0 -6
- package/dist/js/modern/findExists.js +0 -16
- package/dist/js/modern/format.js +0 -137
- package/dist/js/modern/generateMetaTags.js +0 -49
- package/dist/js/modern/getBrowserslist.js +0 -5
- package/dist/js/modern/getCacheIdentifier.js +0 -20
- package/dist/js/modern/getEntryOptions.js +0 -24
- package/dist/js/modern/getPackageManager.js +0 -37
- package/dist/js/modern/getPort.js +0 -52
- package/dist/js/modern/import.js +0 -11
- package/dist/js/modern/index.js +0 -34
- package/dist/js/modern/is/index.js +0 -77
- package/dist/js/modern/is/node-env.js +0 -5
- package/dist/js/modern/is/platform.js +0 -2
- package/dist/js/modern/is/type.js +0 -27
- package/dist/js/modern/logger.js +0 -152
- package/dist/js/modern/nodeEnv.js +0 -31
- package/dist/js/modern/path.js +0 -5
- package/dist/js/modern/pkgUp.js +0 -2
- package/dist/js/modern/prettyInstructions.js +0 -79
- package/dist/js/modern/printBuildError.js +0 -40
- package/dist/js/modern/readTsConfig.js +0 -13
- package/dist/js/modern/removeSlash.js +0 -3
- package/dist/js/modern/runtimeExports.js +0 -52
- package/dist/js/modern/wait.js +0 -5
- package/dist/js/modern/watch.js +0 -43
- package/dist/js/node/FileSizeReporter.js +0 -175
- package/dist/js/node/alias.js +0 -97
- package/dist/js/node/applyOptionsChain.js +0 -37
- package/dist/js/node/chalk.js +0 -15
- package/dist/js/node/clearConsole.js +0 -14
- package/dist/js/node/compatRequire.js +0 -41
- package/dist/js/node/constants.js +0 -353
- package/dist/js/node/debug.js +0 -19
- package/dist/js/node/emptyDir.js +0 -18
- package/dist/js/node/ensureAbsolutePath.js +0 -20
- package/dist/js/node/findExists.js +0 -27
- package/dist/js/node/format.js +0 -141
- package/dist/js/node/generateMetaTags.js +0 -58
- package/dist/js/node/getBrowserslist.js +0 -17
- package/dist/js/node/getCacheIdentifier.js +0 -27
- package/dist/js/node/getEntryOptions.js +0 -35
- package/dist/js/node/getPackageManager.js +0 -51
- package/dist/js/node/getPort.js +0 -67
- package/dist/js/node/import.js +0 -19
- package/dist/js/node/index.js +0 -465
- package/dist/js/node/is/index.js +0 -150
- package/dist/js/node/is/node-env.js +0 -23
- package/dist/js/node/is/platform.js +0 -14
- package/dist/js/node/is/type.js +0 -48
- package/dist/js/node/logger.js +0 -162
- package/dist/js/node/nodeEnv.js +0 -45
- package/dist/js/node/path.js +0 -24
- package/dist/js/node/pkgUp.js +0 -15
- package/dist/js/node/prettyInstructions.js +0 -95
- package/dist/js/node/printBuildError.js +0 -52
- package/dist/js/node/readTsConfig.js +0 -28
- package/dist/js/node/removeSlash.js +0 -18
- package/dist/js/node/runtimeExports.js +0 -68
- package/dist/js/node/wait.js +0 -12
- package/dist/js/node/watch.js +0 -61
- package/dist/js/treeshaking/FileSizeReporter.js +0 -185
- package/dist/js/treeshaking/alias.js +0 -72
- package/dist/js/treeshaking/applyOptionsChain.js +0 -31
- package/dist/js/treeshaking/chalk.js +0 -2
- package/dist/js/treeshaking/clearConsole.js +0 -5
- package/dist/js/treeshaking/compatRequire.js +0 -29
- package/dist/js/treeshaking/constants.js +0 -333
- package/dist/js/treeshaking/debug.js +0 -10
- package/dist/js/treeshaking/emptyDir.js +0 -37
- package/dist/js/treeshaking/ensureAbsolutePath.js +0 -11
- package/dist/js/treeshaking/findExists.js +0 -33
- package/dist/js/treeshaking/format.js +0 -167
- package/dist/js/treeshaking/generateMetaTags.js +0 -55
- package/dist/js/treeshaking/getBrowserslist.js +0 -7
- package/dist/js/treeshaking/getCacheIdentifier.js +0 -35
- package/dist/js/treeshaking/getEntryOptions.js +0 -26
- package/dist/js/treeshaking/getPackageManager.js +0 -101
- package/dist/js/treeshaking/getPort.js +0 -103
- package/dist/js/treeshaking/import.js +0 -11
- package/dist/js/treeshaking/index.js +0 -34
- package/dist/js/treeshaking/is/index.js +0 -81
- package/dist/js/treeshaking/is/node-env.js +0 -13
- package/dist/js/treeshaking/is/platform.js +0 -6
- package/dist/js/treeshaking/is/type.js +0 -29
- package/dist/js/treeshaking/logger.js +0 -188
- package/dist/js/treeshaking/nodeEnv.js +0 -108
- package/dist/js/treeshaking/path.js +0 -11
- package/dist/js/treeshaking/pkgUp.js +0 -2
- package/dist/js/treeshaking/prettyInstructions.js +0 -100
- package/dist/js/treeshaking/printBuildError.js +0 -40
- package/dist/js/treeshaking/readTsConfig.js +0 -13
- package/dist/js/treeshaking/removeSlash.js +0 -9
- package/dist/js/treeshaking/runtimeExports.js +0 -61
- package/dist/js/treeshaking/wait.js +0 -8
- package/dist/js/treeshaking/watch.js +0 -112
- package/dist/types/chalk.d.ts +0 -2
@@ -0,0 +1,774 @@
|
|
1
|
+
// Type definitions for commander
|
2
|
+
// 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>
|
3
|
+
|
4
|
+
// Using method rather than property for method-signature-style, to document method overloads separately. Allow either.
|
5
|
+
/* eslint-disable @typescript-eslint/method-signature-style */
|
6
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
7
|
+
|
8
|
+
export class CommanderError extends Error {
|
9
|
+
code: string;
|
10
|
+
exitCode: number;
|
11
|
+
message: string;
|
12
|
+
nestedError?: string;
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Constructs the CommanderError class
|
16
|
+
* @param exitCode - suggested exit code which could be used with process.exit
|
17
|
+
* @param code - an id string representing the error
|
18
|
+
* @param message - human-readable description of the error
|
19
|
+
* @constructor
|
20
|
+
*/
|
21
|
+
constructor(exitCode: number, code: string, message: string);
|
22
|
+
}
|
23
|
+
|
24
|
+
export class InvalidArgumentError extends CommanderError {
|
25
|
+
/**
|
26
|
+
* Constructs the InvalidArgumentError class
|
27
|
+
* @param message - explanation of why argument is invalid
|
28
|
+
* @constructor
|
29
|
+
*/
|
30
|
+
constructor(message: string);
|
31
|
+
}
|
32
|
+
export { InvalidArgumentError as InvalidOptionArgumentError }; // deprecated old name
|
33
|
+
|
34
|
+
export class Argument {
|
35
|
+
description: string;
|
36
|
+
required: boolean;
|
37
|
+
variadic: boolean;
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Initialize a new command argument with the given name and description.
|
41
|
+
* The default is that the argument is required, and you can explicitly
|
42
|
+
* indicate this with <> around the name. Put [] around the name for an optional argument.
|
43
|
+
*/
|
44
|
+
constructor(arg: string, description?: string);
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Return argument name.
|
48
|
+
*/
|
49
|
+
name(): string;
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Set the default value, and optionally supply the description to be displayed in the help.
|
53
|
+
*/
|
54
|
+
default(value: unknown, description?: string): this;
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Set the custom handler for processing CLI command arguments into argument values.
|
58
|
+
*/
|
59
|
+
argParser<T>(fn: (value: string, previous: T) => T): this;
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Only allow argument value to be one of choices.
|
63
|
+
*/
|
64
|
+
choices(values: string[]): this;
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Make option-argument required.
|
68
|
+
*/
|
69
|
+
argRequired(): this;
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Make option-argument optional.
|
73
|
+
*/
|
74
|
+
argOptional(): this;
|
75
|
+
}
|
76
|
+
|
77
|
+
export class Option {
|
78
|
+
flags: string;
|
79
|
+
description: string;
|
80
|
+
|
81
|
+
required: boolean; // A value must be supplied when the option is specified.
|
82
|
+
optional: boolean; // A value is optional when the option is specified.
|
83
|
+
variadic: boolean;
|
84
|
+
mandatory: boolean; // The option must have a value after parsing, which usually means it must be specified on command line.
|
85
|
+
optionFlags: string;
|
86
|
+
short?: string;
|
87
|
+
long?: string;
|
88
|
+
negate: boolean;
|
89
|
+
defaultValue?: any;
|
90
|
+
defaultValueDescription?: string;
|
91
|
+
parseArg?: <T>(value: string, previous: T) => T;
|
92
|
+
hidden: boolean;
|
93
|
+
argChoices?: string[];
|
94
|
+
|
95
|
+
constructor(flags: string, description?: string);
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Set the default value, and optionally supply the description to be displayed in the help.
|
99
|
+
*/
|
100
|
+
default(value: unknown, description?: string): this;
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Set environment variable to check for option value.
|
104
|
+
* Priority order of option values is default < env < cli
|
105
|
+
*/
|
106
|
+
env(name: string): this;
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Calculate the full description, including defaultValue etc.
|
110
|
+
*/
|
111
|
+
fullDescription(): string;
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Set the custom handler for processing CLI option arguments into option values.
|
115
|
+
*/
|
116
|
+
argParser<T>(fn: (value: string, previous: T) => T): this;
|
117
|
+
|
118
|
+
/**
|
119
|
+
* Whether the option is mandatory and must have a value after parsing.
|
120
|
+
*/
|
121
|
+
makeOptionMandatory(mandatory?: boolean): this;
|
122
|
+
|
123
|
+
/**
|
124
|
+
* Hide option in help.
|
125
|
+
*/
|
126
|
+
hideHelp(hide?: boolean): this;
|
127
|
+
|
128
|
+
/**
|
129
|
+
* Only allow option value to be one of choices.
|
130
|
+
*/
|
131
|
+
choices(values: string[]): this;
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Return option name.
|
135
|
+
*/
|
136
|
+
name(): string;
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Return option name, in a camelcase format that can be used
|
140
|
+
* as a object attribute key.
|
141
|
+
*/
|
142
|
+
attributeName(): string;
|
143
|
+
}
|
144
|
+
|
145
|
+
export class Help {
|
146
|
+
/** output helpWidth, long lines are wrapped to fit */
|
147
|
+
helpWidth?: number;
|
148
|
+
sortSubcommands: boolean;
|
149
|
+
sortOptions: boolean;
|
150
|
+
|
151
|
+
constructor();
|
152
|
+
|
153
|
+
/** Get the command term to show in the list of subcommands. */
|
154
|
+
subcommandTerm(cmd: Command): string;
|
155
|
+
/** Get the command description to show in the list of subcommands. */
|
156
|
+
subcommandDescription(cmd: Command): string;
|
157
|
+
/** Get the option term to show in the list of options. */
|
158
|
+
optionTerm(option: Option): string;
|
159
|
+
/** Get the option description to show in the list of options. */
|
160
|
+
optionDescription(option: Option): string;
|
161
|
+
/** Get the argument term to show in the list of arguments. */
|
162
|
+
argumentTerm(argument: Argument): string;
|
163
|
+
/** Get the argument description to show in the list of arguments. */
|
164
|
+
argumentDescription(argument: Argument): string;
|
165
|
+
|
166
|
+
/** Get the command usage to be displayed at the top of the built-in help. */
|
167
|
+
commandUsage(cmd: Command): string;
|
168
|
+
/** Get the description for the command. */
|
169
|
+
commandDescription(cmd: Command): string;
|
170
|
+
|
171
|
+
/** Get an array of the visible subcommands. Includes a placeholder for the implicit help command, if there is one. */
|
172
|
+
visibleCommands(cmd: Command): Command[];
|
173
|
+
/** Get an array of the visible options. Includes a placeholder for the implicit help option, if there is one. */
|
174
|
+
visibleOptions(cmd: Command): Option[];
|
175
|
+
/** Get an array of the arguments which have descriptions. */
|
176
|
+
visibleArguments(cmd: Command): Argument[];
|
177
|
+
|
178
|
+
/** Get the longest command term length. */
|
179
|
+
longestSubcommandTermLength(cmd: Command, helper: Help): number;
|
180
|
+
/** Get the longest option term length. */
|
181
|
+
longestOptionTermLength(cmd: Command, helper: Help): number;
|
182
|
+
/** Get the longest argument term length. */
|
183
|
+
longestArgumentTermLength(cmd: Command, helper: Help): number;
|
184
|
+
/** Calculate the pad width from the maximum term length. */
|
185
|
+
padWidth(cmd: Command, helper: Help): number;
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Wrap the given string to width characters per line, with lines after the first indented.
|
189
|
+
* Do not wrap if insufficient room for wrapping (minColumnWidth), or string is manually formatted.
|
190
|
+
*/
|
191
|
+
wrap(str: string, width: number, indent: number, minColumnWidth?: number): string;
|
192
|
+
|
193
|
+
/** Generate the built-in help text. */
|
194
|
+
formatHelp(cmd: Command, helper: Help): string;
|
195
|
+
}
|
196
|
+
export type HelpConfiguration = Partial<Help>;
|
197
|
+
|
198
|
+
export interface ParseOptions {
|
199
|
+
from: 'node' | 'electron' | 'user';
|
200
|
+
}
|
201
|
+
export interface HelpContext { // optional parameter for .help() and .outputHelp()
|
202
|
+
error: boolean;
|
203
|
+
}
|
204
|
+
export interface AddHelpTextContext { // passed to text function used with .addHelpText()
|
205
|
+
error: boolean;
|
206
|
+
command: Command;
|
207
|
+
}
|
208
|
+
export interface OutputConfiguration {
|
209
|
+
writeOut?(str: string): void;
|
210
|
+
writeErr?(str: string): void;
|
211
|
+
getOutHelpWidth?(): number;
|
212
|
+
getErrHelpWidth?(): number;
|
213
|
+
outputError?(str: string, write: (str: string) => void): void;
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
export type AddHelpTextPosition = 'beforeAll' | 'before' | 'after' | 'afterAll';
|
218
|
+
export type HookEvent = 'preAction' | 'postAction';
|
219
|
+
export type OptionValueSource = 'default' | 'env' | 'config' | 'cli';
|
220
|
+
|
221
|
+
export interface OptionValues {
|
222
|
+
[key: string]: any;
|
223
|
+
}
|
224
|
+
|
225
|
+
export class Command {
|
226
|
+
args: string[];
|
227
|
+
processedArgs: any[];
|
228
|
+
commands: Command[];
|
229
|
+
parent: Command | null;
|
230
|
+
|
231
|
+
constructor(name?: string);
|
232
|
+
|
233
|
+
/**
|
234
|
+
* Set the program version to `str`.
|
235
|
+
*
|
236
|
+
* This method auto-registers the "-V, --version" flag
|
237
|
+
* which will print the version number when passed.
|
238
|
+
*
|
239
|
+
* You can optionally supply the flags and description to override the defaults.
|
240
|
+
*/
|
241
|
+
version(str: string, flags?: string, description?: string): this;
|
242
|
+
|
243
|
+
/**
|
244
|
+
* Define a command, implemented using an action handler.
|
245
|
+
*
|
246
|
+
* @remarks
|
247
|
+
* The command description is supplied using `.description`, not as a parameter to `.command`.
|
248
|
+
*
|
249
|
+
* @example
|
250
|
+
* ```ts
|
251
|
+
* program
|
252
|
+
* .command('clone <source> [destination]')
|
253
|
+
* .description('clone a repository into a newly created directory')
|
254
|
+
* .action((source, destination) => {
|
255
|
+
* console.log('clone command called');
|
256
|
+
* });
|
257
|
+
* ```
|
258
|
+
*
|
259
|
+
* @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
260
|
+
* @param opts - configuration options
|
261
|
+
* @returns new command
|
262
|
+
*/
|
263
|
+
command(nameAndArgs: string, opts?: CommandOptions): ReturnType<this['createCommand']>;
|
264
|
+
/**
|
265
|
+
* Define a command, implemented in a separate executable file.
|
266
|
+
*
|
267
|
+
* @remarks
|
268
|
+
* The command description is supplied as the second parameter to `.command`.
|
269
|
+
*
|
270
|
+
* @example
|
271
|
+
* ```ts
|
272
|
+
* program
|
273
|
+
* .command('start <service>', 'start named service')
|
274
|
+
* .command('stop [service]', 'stop named service, or all if no name supplied');
|
275
|
+
* ```
|
276
|
+
*
|
277
|
+
* @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`
|
278
|
+
* @param description - description of executable command
|
279
|
+
* @param opts - configuration options
|
280
|
+
* @returns `this` command for chaining
|
281
|
+
*/
|
282
|
+
command(nameAndArgs: string, description: string, opts?: ExecutableCommandOptions): this;
|
283
|
+
|
284
|
+
/**
|
285
|
+
* Factory routine to create a new unattached command.
|
286
|
+
*
|
287
|
+
* See .command() for creating an attached subcommand, which uses this routine to
|
288
|
+
* create the command. You can override createCommand to customise subcommands.
|
289
|
+
*/
|
290
|
+
createCommand(name?: string): Command;
|
291
|
+
|
292
|
+
/**
|
293
|
+
* Add a prepared subcommand.
|
294
|
+
*
|
295
|
+
* See .command() for creating an attached subcommand which inherits settings from its parent.
|
296
|
+
*
|
297
|
+
* @returns `this` command for chaining
|
298
|
+
*/
|
299
|
+
addCommand(cmd: Command, opts?: CommandOptions): this;
|
300
|
+
|
301
|
+
/**
|
302
|
+
* Factory routine to create a new unattached argument.
|
303
|
+
*
|
304
|
+
* See .argument() for creating an attached argument, which uses this routine to
|
305
|
+
* create the argument. You can override createArgument to return a custom argument.
|
306
|
+
*/
|
307
|
+
createArgument(name: string, description?: string): Argument;
|
308
|
+
|
309
|
+
/**
|
310
|
+
* Define argument syntax for command.
|
311
|
+
*
|
312
|
+
* The default is that the argument is required, and you can explicitly
|
313
|
+
* indicate this with <> around the name. Put [] around the name for an optional argument.
|
314
|
+
*
|
315
|
+
* @example
|
316
|
+
* ```
|
317
|
+
* program.argument('<input-file>');
|
318
|
+
* program.argument('[output-file]');
|
319
|
+
* ```
|
320
|
+
*
|
321
|
+
* @returns `this` command for chaining
|
322
|
+
*/
|
323
|
+
argument<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
|
324
|
+
argument(name: string, description?: string, defaultValue?: unknown): this;
|
325
|
+
|
326
|
+
/**
|
327
|
+
* Define argument syntax for command, adding a prepared argument.
|
328
|
+
*
|
329
|
+
* @returns `this` command for chaining
|
330
|
+
*/
|
331
|
+
addArgument(arg: Argument): this;
|
332
|
+
|
333
|
+
/**
|
334
|
+
* Define argument syntax for command, adding multiple at once (without descriptions).
|
335
|
+
*
|
336
|
+
* See also .argument().
|
337
|
+
*
|
338
|
+
* @example
|
339
|
+
* ```
|
340
|
+
* program.arguments('<cmd> [env]');
|
341
|
+
* ```
|
342
|
+
*
|
343
|
+
* @returns `this` command for chaining
|
344
|
+
*/
|
345
|
+
arguments(names: string): this;
|
346
|
+
|
347
|
+
/**
|
348
|
+
* Override default decision whether to add implicit help command.
|
349
|
+
*
|
350
|
+
* @example
|
351
|
+
* ```
|
352
|
+
* addHelpCommand() // force on
|
353
|
+
* addHelpCommand(false); // force off
|
354
|
+
* addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details
|
355
|
+
* ```
|
356
|
+
*
|
357
|
+
* @returns `this` command for chaining
|
358
|
+
*/
|
359
|
+
addHelpCommand(enableOrNameAndArgs?: string | boolean, description?: string): this;
|
360
|
+
|
361
|
+
/**
|
362
|
+
* Add hook for life cycle event.
|
363
|
+
*/
|
364
|
+
hook(event: HookEvent, listener: (thisCommand: Command, actionCommand: Command) => void | Promise<void>): this;
|
365
|
+
|
366
|
+
/**
|
367
|
+
* Register callback to use as replacement for calling process.exit.
|
368
|
+
*/
|
369
|
+
exitOverride(callback?: (err: CommanderError) => never|void): this;
|
370
|
+
|
371
|
+
/**
|
372
|
+
* You can customise the help with a subclass of Help by overriding createHelp,
|
373
|
+
* or by overriding Help properties using configureHelp().
|
374
|
+
*/
|
375
|
+
createHelp(): Help;
|
376
|
+
|
377
|
+
/**
|
378
|
+
* You can customise the help by overriding Help properties using configureHelp(),
|
379
|
+
* or with a subclass of Help by overriding createHelp().
|
380
|
+
*/
|
381
|
+
configureHelp(configuration: HelpConfiguration): this;
|
382
|
+
/** Get configuration */
|
383
|
+
configureHelp(): HelpConfiguration;
|
384
|
+
|
385
|
+
/**
|
386
|
+
* The default output goes to stdout and stderr. You can customise this for special
|
387
|
+
* applications. You can also customise the display of errors by overriding outputError.
|
388
|
+
*
|
389
|
+
* The configuration properties are all functions:
|
390
|
+
* ```
|
391
|
+
* // functions to change where being written, stdout and stderr
|
392
|
+
* writeOut(str)
|
393
|
+
* writeErr(str)
|
394
|
+
* // matching functions to specify width for wrapping help
|
395
|
+
* getOutHelpWidth()
|
396
|
+
* getErrHelpWidth()
|
397
|
+
* // functions based on what is being written out
|
398
|
+
* outputError(str, write) // used for displaying errors, and not used for displaying help
|
399
|
+
* ```
|
400
|
+
*/
|
401
|
+
configureOutput(configuration: OutputConfiguration): this;
|
402
|
+
/** Get configuration */
|
403
|
+
configureOutput(): OutputConfiguration;
|
404
|
+
|
405
|
+
/**
|
406
|
+
* Copy settings that are useful to have in common across root command and subcommands.
|
407
|
+
*
|
408
|
+
* (Used internally when adding a command using `.command()` so subcommands inherit parent settings.)
|
409
|
+
*/
|
410
|
+
copyInheritedSettings(sourceCommand: Command): this;
|
411
|
+
|
412
|
+
/**
|
413
|
+
* Display the help or a custom message after an error occurs.
|
414
|
+
*/
|
415
|
+
showHelpAfterError(displayHelp?: boolean | string): this;
|
416
|
+
|
417
|
+
/**
|
418
|
+
* Display suggestion of similar commands for unknown commands, or options for unknown options.
|
419
|
+
*/
|
420
|
+
showSuggestionAfterError(displaySuggestion?: boolean): this;
|
421
|
+
|
422
|
+
/**
|
423
|
+
* Register callback `fn` for the command.
|
424
|
+
*
|
425
|
+
* @example
|
426
|
+
* ```
|
427
|
+
* program
|
428
|
+
* .command('serve')
|
429
|
+
* .description('start service')
|
430
|
+
* .action(function() {
|
431
|
+
* // do work here
|
432
|
+
* });
|
433
|
+
* ```
|
434
|
+
*
|
435
|
+
* @returns `this` command for chaining
|
436
|
+
*/
|
437
|
+
action(fn: (...args: any[]) => void | Promise<void>): this;
|
438
|
+
|
439
|
+
/**
|
440
|
+
* Define option with `flags`, `description` and optional
|
441
|
+
* coercion `fn`.
|
442
|
+
*
|
443
|
+
* The `flags` string contains the short and/or long flags,
|
444
|
+
* separated by comma, a pipe or space. The following are all valid
|
445
|
+
* all will output this way when `--help` is used.
|
446
|
+
*
|
447
|
+
* "-p, --pepper"
|
448
|
+
* "-p|--pepper"
|
449
|
+
* "-p --pepper"
|
450
|
+
*
|
451
|
+
* @example
|
452
|
+
* ```
|
453
|
+
* // simple boolean defaulting to false
|
454
|
+
* program.option('-p, --pepper', 'add pepper');
|
455
|
+
*
|
456
|
+
* --pepper
|
457
|
+
* program.pepper
|
458
|
+
* // => Boolean
|
459
|
+
*
|
460
|
+
* // simple boolean defaulting to true
|
461
|
+
* program.option('-C, --no-cheese', 'remove cheese');
|
462
|
+
*
|
463
|
+
* program.cheese
|
464
|
+
* // => true
|
465
|
+
*
|
466
|
+
* --no-cheese
|
467
|
+
* program.cheese
|
468
|
+
* // => false
|
469
|
+
*
|
470
|
+
* // required argument
|
471
|
+
* program.option('-C, --chdir <path>', 'change the working directory');
|
472
|
+
*
|
473
|
+
* --chdir /tmp
|
474
|
+
* program.chdir
|
475
|
+
* // => "/tmp"
|
476
|
+
*
|
477
|
+
* // optional argument
|
478
|
+
* program.option('-c, --cheese [type]', 'add cheese [marble]');
|
479
|
+
* ```
|
480
|
+
*
|
481
|
+
* @returns `this` command for chaining
|
482
|
+
*/
|
483
|
+
option(flags: string, description?: string, defaultValue?: string | boolean): this;
|
484
|
+
option<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
|
485
|
+
/** @deprecated since v7, instead use choices or a custom function */
|
486
|
+
option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this;
|
487
|
+
|
488
|
+
/**
|
489
|
+
* Define a required option, which must have a value after parsing. This usually means
|
490
|
+
* the option must be specified on the command line. (Otherwise the same as .option().)
|
491
|
+
*
|
492
|
+
* The `flags` string contains the short and/or long flags, separated by comma, a pipe or space.
|
493
|
+
*/
|
494
|
+
requiredOption(flags: string, description?: string, defaultValue?: string | boolean): this;
|
495
|
+
requiredOption<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
|
496
|
+
/** @deprecated since v7, instead use choices or a custom function */
|
497
|
+
requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean): this;
|
498
|
+
|
499
|
+
/**
|
500
|
+
* Factory routine to create a new unattached option.
|
501
|
+
*
|
502
|
+
* See .option() for creating an attached option, which uses this routine to
|
503
|
+
* create the option. You can override createOption to return a custom option.
|
504
|
+
*/
|
505
|
+
|
506
|
+
createOption(flags: string, description?: string): Option;
|
507
|
+
|
508
|
+
/**
|
509
|
+
* Add a prepared Option.
|
510
|
+
*
|
511
|
+
* See .option() and .requiredOption() for creating and attaching an option in a single call.
|
512
|
+
*/
|
513
|
+
addOption(option: Option): this;
|
514
|
+
|
515
|
+
/**
|
516
|
+
* Whether to store option values as properties on command object,
|
517
|
+
* or store separately (specify false). In both cases the option values can be accessed using .opts().
|
518
|
+
*
|
519
|
+
* @returns `this` command for chaining
|
520
|
+
*/
|
521
|
+
storeOptionsAsProperties<T extends OptionValues>(): this & T;
|
522
|
+
storeOptionsAsProperties<T extends OptionValues>(storeAsProperties: true): this & T;
|
523
|
+
storeOptionsAsProperties(storeAsProperties?: boolean): this;
|
524
|
+
|
525
|
+
/**
|
526
|
+
* Retrieve option value.
|
527
|
+
*/
|
528
|
+
getOptionValue(key: string): any;
|
529
|
+
|
530
|
+
/**
|
531
|
+
* Store option value.
|
532
|
+
*/
|
533
|
+
setOptionValue(key: string, value: unknown): this;
|
534
|
+
|
535
|
+
/**
|
536
|
+
* Store option value and where the value came from.
|
537
|
+
*/
|
538
|
+
setOptionValueWithSource(key: string, value: unknown, source: OptionValueSource): this;
|
539
|
+
|
540
|
+
/**
|
541
|
+
* Retrieve option value source.
|
542
|
+
*/
|
543
|
+
getOptionValueSource(key: string): OptionValueSource;
|
544
|
+
|
545
|
+
/**
|
546
|
+
* Alter parsing of short flags with optional values.
|
547
|
+
*
|
548
|
+
* @example
|
549
|
+
* ```
|
550
|
+
* // for `.option('-f,--flag [value]'):
|
551
|
+
* .combineFlagAndOptionalValue(true) // `-f80` is treated like `--flag=80`, this is the default behaviour
|
552
|
+
* .combineFlagAndOptionalValue(false) // `-fb` is treated like `-f -b`
|
553
|
+
* ```
|
554
|
+
*
|
555
|
+
* @returns `this` command for chaining
|
556
|
+
*/
|
557
|
+
combineFlagAndOptionalValue(combine?: boolean): this;
|
558
|
+
|
559
|
+
/**
|
560
|
+
* Allow unknown options on the command line.
|
561
|
+
*
|
562
|
+
* @returns `this` command for chaining
|
563
|
+
*/
|
564
|
+
allowUnknownOption(allowUnknown?: boolean): this;
|
565
|
+
|
566
|
+
/**
|
567
|
+
* Allow excess command-arguments on the command line. Pass false to make excess arguments an error.
|
568
|
+
*
|
569
|
+
* @returns `this` command for chaining
|
570
|
+
*/
|
571
|
+
allowExcessArguments(allowExcess?: boolean): this;
|
572
|
+
|
573
|
+
/**
|
574
|
+
* Enable positional options. Positional means global options are specified before subcommands which lets
|
575
|
+
* subcommands reuse the same option names, and also enables subcommands to turn on passThroughOptions.
|
576
|
+
*
|
577
|
+
* The default behaviour is non-positional and global options may appear anywhere on the command line.
|
578
|
+
*
|
579
|
+
* @returns `this` command for chaining
|
580
|
+
*/
|
581
|
+
enablePositionalOptions(positional?: boolean): this;
|
582
|
+
|
583
|
+
/**
|
584
|
+
* Pass through options that come after command-arguments rather than treat them as command-options,
|
585
|
+
* so actual command-options come before command-arguments. Turning this on for a subcommand requires
|
586
|
+
* positional options to have been enabled on the program (parent commands).
|
587
|
+
*
|
588
|
+
* The default behaviour is non-positional and options may appear before or after command-arguments.
|
589
|
+
*
|
590
|
+
* @returns `this` command for chaining
|
591
|
+
*/
|
592
|
+
passThroughOptions(passThrough?: boolean): this;
|
593
|
+
|
594
|
+
/**
|
595
|
+
* Parse `argv`, setting options and invoking commands when defined.
|
596
|
+
*
|
597
|
+
* The default expectation is that the arguments are from node and have the application as argv[0]
|
598
|
+
* and the script being run in argv[1], with user parameters after that.
|
599
|
+
*
|
600
|
+
* @example
|
601
|
+
* ```
|
602
|
+
* program.parse(process.argv);
|
603
|
+
* program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
|
604
|
+
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
605
|
+
* ```
|
606
|
+
*
|
607
|
+
* @returns `this` command for chaining
|
608
|
+
*/
|
609
|
+
parse(argv?: string[], options?: ParseOptions): this;
|
610
|
+
|
611
|
+
/**
|
612
|
+
* Parse `argv`, setting options and invoking commands when defined.
|
613
|
+
*
|
614
|
+
* Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
|
615
|
+
*
|
616
|
+
* The default expectation is that the arguments are from node and have the application as argv[0]
|
617
|
+
* and the script being run in argv[1], with user parameters after that.
|
618
|
+
*
|
619
|
+
* @example
|
620
|
+
* ```
|
621
|
+
* program.parseAsync(process.argv);
|
622
|
+
* program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
|
623
|
+
* program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
|
624
|
+
* ```
|
625
|
+
*
|
626
|
+
* @returns Promise
|
627
|
+
*/
|
628
|
+
parseAsync(argv?: string[], options?: ParseOptions): Promise<this>;
|
629
|
+
|
630
|
+
/**
|
631
|
+
* Parse options from `argv` removing known options,
|
632
|
+
* and return argv split into operands and unknown arguments.
|
633
|
+
*
|
634
|
+
* argv => operands, unknown
|
635
|
+
* --known kkk op => [op], []
|
636
|
+
* op --known kkk => [op], []
|
637
|
+
* sub --unknown uuu op => [sub], [--unknown uuu op]
|
638
|
+
* sub -- --unknown uuu op => [sub --unknown uuu op], []
|
639
|
+
*/
|
640
|
+
parseOptions(argv: string[]): ParseOptionsResult;
|
641
|
+
|
642
|
+
/**
|
643
|
+
* Return an object containing options as key-value pairs
|
644
|
+
*/
|
645
|
+
opts<T extends OptionValues>(): T;
|
646
|
+
|
647
|
+
/**
|
648
|
+
* Set the description.
|
649
|
+
*
|
650
|
+
* @returns `this` command for chaining
|
651
|
+
*/
|
652
|
+
|
653
|
+
description(str: string): this;
|
654
|
+
/** @deprecated since v8, instead use .argument to add command argument with description */
|
655
|
+
description(str: string, argsDescription: {[argName: string]: string}): this;
|
656
|
+
/**
|
657
|
+
* Get the description.
|
658
|
+
*/
|
659
|
+
description(): string;
|
660
|
+
|
661
|
+
/**
|
662
|
+
* Set an alias for the command.
|
663
|
+
*
|
664
|
+
* You may call more than once to add multiple aliases. Only the first alias is shown in the auto-generated help.
|
665
|
+
*
|
666
|
+
* @returns `this` command for chaining
|
667
|
+
*/
|
668
|
+
alias(alias: string): this;
|
669
|
+
/**
|
670
|
+
* Get alias for the command.
|
671
|
+
*/
|
672
|
+
alias(): string;
|
673
|
+
|
674
|
+
/**
|
675
|
+
* Set aliases for the command.
|
676
|
+
*
|
677
|
+
* Only the first alias is shown in the auto-generated help.
|
678
|
+
*
|
679
|
+
* @returns `this` command for chaining
|
680
|
+
*/
|
681
|
+
aliases(aliases: string[]): this;
|
682
|
+
/**
|
683
|
+
* Get aliases for the command.
|
684
|
+
*/
|
685
|
+
aliases(): string[];
|
686
|
+
|
687
|
+
/**
|
688
|
+
* Set the command usage.
|
689
|
+
*
|
690
|
+
* @returns `this` command for chaining
|
691
|
+
*/
|
692
|
+
usage(str: string): this;
|
693
|
+
/**
|
694
|
+
* Get the command usage.
|
695
|
+
*/
|
696
|
+
usage(): string;
|
697
|
+
|
698
|
+
/**
|
699
|
+
* Set the name of the command.
|
700
|
+
*
|
701
|
+
* @returns `this` command for chaining
|
702
|
+
*/
|
703
|
+
name(str: string): this;
|
704
|
+
/**
|
705
|
+
* Get the name of the command.
|
706
|
+
*/
|
707
|
+
name(): string;
|
708
|
+
|
709
|
+
/**
|
710
|
+
* Output help information for this command.
|
711
|
+
*
|
712
|
+
* Outputs built-in help, and custom text added using `.addHelpText()`.
|
713
|
+
*
|
714
|
+
*/
|
715
|
+
outputHelp(context?: HelpContext): void;
|
716
|
+
/** @deprecated since v7 */
|
717
|
+
outputHelp(cb?: (str: string) => string): void;
|
718
|
+
|
719
|
+
/**
|
720
|
+
* Return command help documentation.
|
721
|
+
*/
|
722
|
+
helpInformation(context?: HelpContext): string;
|
723
|
+
|
724
|
+
/**
|
725
|
+
* You can pass in flags and a description to override the help
|
726
|
+
* flags and help description for your command. Pass in false
|
727
|
+
* to disable the built-in help option.
|
728
|
+
*/
|
729
|
+
helpOption(flags?: string | boolean, description?: string): this;
|
730
|
+
|
731
|
+
/**
|
732
|
+
* Output help information and exit.
|
733
|
+
*
|
734
|
+
* Outputs built-in help, and custom text added using `.addHelpText()`.
|
735
|
+
*/
|
736
|
+
help(context?: HelpContext): never;
|
737
|
+
/** @deprecated since v7 */
|
738
|
+
help(cb?: (str: string) => string): never;
|
739
|
+
|
740
|
+
/**
|
741
|
+
* Add additional text to be displayed with the built-in help.
|
742
|
+
*
|
743
|
+
* Position is 'before' or 'after' to affect just this command,
|
744
|
+
* and 'beforeAll' or 'afterAll' to affect this command and all its subcommands.
|
745
|
+
*/
|
746
|
+
addHelpText(position: AddHelpTextPosition, text: string): this;
|
747
|
+
addHelpText(position: AddHelpTextPosition, text: (context: AddHelpTextContext) => string): this;
|
748
|
+
|
749
|
+
/**
|
750
|
+
* Add a listener (callback) for when events occur. (Implemented using EventEmitter.)
|
751
|
+
*/
|
752
|
+
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
753
|
+
}
|
754
|
+
|
755
|
+
export interface CommandOptions {
|
756
|
+
hidden?: boolean;
|
757
|
+
isDefault?: boolean;
|
758
|
+
/** @deprecated since v7, replaced by hidden */
|
759
|
+
noHelp?: boolean;
|
760
|
+
}
|
761
|
+
export interface ExecutableCommandOptions extends CommandOptions {
|
762
|
+
executableFile?: string;
|
763
|
+
}
|
764
|
+
|
765
|
+
export interface ParseOptionsResult {
|
766
|
+
operands: string[];
|
767
|
+
unknown: string[];
|
768
|
+
}
|
769
|
+
|
770
|
+
export function createCommand(name?: string): Command;
|
771
|
+
export function createOption(flags: string, description?: string): Option;
|
772
|
+
export function createArgument(name: string, description?: string): Argument;
|
773
|
+
|
774
|
+
export const program: Command;
|