@rushstack/ts-command-line 4.6.10 → 4.7.3
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/CHANGELOG.json +63 -0
- package/CHANGELOG.md +29 -1
- package/README.md +7 -3
- package/dist/ts-command-line.d.ts +15 -15
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/CommandLineHelper.js +1 -0
- package/lib/CommandLineHelper.js.map +1 -1
- package/lib/index.js +15 -15
- package/lib/index.js.map +1 -1
- package/lib/parameters/BaseClasses.d.ts +2 -2
- package/lib/parameters/BaseClasses.d.ts.map +1 -1
- package/lib/parameters/BaseClasses.js +3 -2
- package/lib/parameters/BaseClasses.js.map +1 -1
- package/lib/parameters/CommandLineChoiceParameter.d.ts +2 -2
- package/lib/parameters/CommandLineChoiceParameter.d.ts.map +1 -1
- package/lib/parameters/CommandLineChoiceParameter.js +1 -0
- package/lib/parameters/CommandLineChoiceParameter.js.map +1 -1
- package/lib/parameters/CommandLineFlagParameter.d.ts +2 -2
- package/lib/parameters/CommandLineFlagParameter.d.ts.map +1 -1
- package/lib/parameters/CommandLineFlagParameter.js +1 -0
- package/lib/parameters/CommandLineFlagParameter.js.map +1 -1
- package/lib/parameters/CommandLineIntegerParameter.d.ts +2 -2
- package/lib/parameters/CommandLineIntegerParameter.d.ts.map +1 -1
- package/lib/parameters/CommandLineIntegerParameter.js +1 -0
- package/lib/parameters/CommandLineIntegerParameter.js.map +1 -1
- package/lib/parameters/CommandLineRemainder.d.ts +1 -1
- package/lib/parameters/CommandLineRemainder.d.ts.map +1 -1
- package/lib/parameters/CommandLineRemainder.js +1 -0
- package/lib/parameters/CommandLineRemainder.js.map +1 -1
- package/lib/parameters/CommandLineStringListParameter.d.ts +2 -2
- package/lib/parameters/CommandLineStringListParameter.d.ts.map +1 -1
- package/lib/parameters/CommandLineStringListParameter.js +1 -0
- package/lib/parameters/CommandLineStringListParameter.js.map +1 -1
- package/lib/parameters/CommandLineStringParameter.d.ts +2 -2
- package/lib/parameters/CommandLineStringParameter.d.ts.map +1 -1
- package/lib/parameters/CommandLineStringParameter.js +1 -0
- package/lib/parameters/CommandLineStringParameter.js.map +1 -1
- package/lib/providers/CommandLineAction.js +2 -1
- package/lib/providers/CommandLineAction.js.map +1 -1
- package/lib/providers/CommandLineParameterProvider.d.ts +2 -2
- package/lib/providers/CommandLineParameterProvider.d.ts.map +1 -1
- package/lib/providers/CommandLineParameterProvider.js +23 -3
- package/lib/providers/CommandLineParameterProvider.js.map +1 -1
- package/lib/providers/CommandLineParser.d.ts +1 -1
- package/lib/providers/CommandLineParser.d.ts.map +1 -1
- package/lib/providers/CommandLineParser.js +7 -3
- package/lib/providers/CommandLineParser.js.map +1 -1
- package/lib/providers/CommandLineParserExitError.js +21 -1
- package/lib/providers/CommandLineParserExitError.js.map +1 -1
- package/lib/providers/DynamicCommandLineAction.js +1 -0
- package/lib/providers/DynamicCommandLineAction.js.map +1 -1
- package/lib/providers/DynamicCommandLineParser.js +1 -0
- package/lib/providers/DynamicCommandLineParser.js.map +1 -1
- package/lib/providers/TabCompletionAction.d.ts.map +1 -1
- package/lib/providers/TabCompletionAction.js +5 -1
- package/lib/providers/TabCompletionAction.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/ts-command-line",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "4.7.3",
|
|
6
|
+
"tag": "@rushstack/ts-command-line_v4.7.3",
|
|
7
|
+
"date": "Tue, 06 Oct 2020 00:24:06 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"dependency": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Updating dependency \"@rushstack/eslint-config\" to `2.2.1`"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"version": "4.7.2",
|
|
18
|
+
"tag": "@rushstack/ts-command-line_v4.7.2",
|
|
19
|
+
"date": "Mon, 05 Oct 2020 22:36:57 GMT",
|
|
20
|
+
"comments": {
|
|
21
|
+
"dependency": [
|
|
22
|
+
{
|
|
23
|
+
"comment": "Updating dependency \"@rushstack/eslint-config\" to `2.2.0`"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"version": "4.7.1",
|
|
30
|
+
"tag": "@rushstack/ts-command-line_v4.7.1",
|
|
31
|
+
"date": "Wed, 30 Sep 2020 18:39:17 GMT",
|
|
32
|
+
"comments": {
|
|
33
|
+
"patch": [
|
|
34
|
+
{
|
|
35
|
+
"comment": "Update to build with @rushstack/heft-node-rig"
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"dependency": [
|
|
39
|
+
{
|
|
40
|
+
"comment": "Updating dependency \"@rushstack/eslint-config\" to `2.1.3`"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"version": "4.7.0",
|
|
47
|
+
"tag": "@rushstack/ts-command-line_v4.7.0",
|
|
48
|
+
"date": "Wed, 30 Sep 2020 06:53:53 GMT",
|
|
49
|
+
"comments": {
|
|
50
|
+
"patch": [
|
|
51
|
+
{
|
|
52
|
+
"comment": "Update README.md"
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"minor": [
|
|
56
|
+
{
|
|
57
|
+
"comment": "Upgrade compiler; the API now requires TypeScript 3.9 or newer"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"dependency": [
|
|
61
|
+
{
|
|
62
|
+
"comment": "Updating dependency \"@rushstack/eslint-config\" to `2.1.2`"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
},
|
|
4
67
|
{
|
|
5
68
|
"version": "4.6.10",
|
|
6
69
|
"tag": "@rushstack/ts-command-line_v4.6.10",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
# Change Log - @rushstack/ts-command-line
|
|
2
2
|
|
|
3
|
-
This log was last generated on Tue,
|
|
3
|
+
This log was last generated on Tue, 06 Oct 2020 00:24:06 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 4.7.3
|
|
6
|
+
Tue, 06 Oct 2020 00:24:06 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 4.7.2
|
|
11
|
+
Mon, 05 Oct 2020 22:36:57 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
14
|
+
|
|
15
|
+
## 4.7.1
|
|
16
|
+
Wed, 30 Sep 2020 18:39:17 GMT
|
|
17
|
+
|
|
18
|
+
### Patches
|
|
19
|
+
|
|
20
|
+
- Update to build with @rushstack/heft-node-rig
|
|
21
|
+
|
|
22
|
+
## 4.7.0
|
|
23
|
+
Wed, 30 Sep 2020 06:53:53 GMT
|
|
24
|
+
|
|
25
|
+
### Minor changes
|
|
26
|
+
|
|
27
|
+
- Upgrade compiler; the API now requires TypeScript 3.9 or newer
|
|
28
|
+
|
|
29
|
+
### Patches
|
|
30
|
+
|
|
31
|
+
- Update README.md
|
|
4
32
|
|
|
5
33
|
## 4.6.10
|
|
6
34
|
Tue, 22 Sep 2020 05:45:57 GMT
|
package/README.md
CHANGED
|
@@ -235,13 +235,17 @@ commandLineParser.execute(process.argv).then(() => {
|
|
|
235
235
|
You can also mix the two models. For example, we could augment the `WidgetCommandLine` from the original model by adding `DynamicAction` objects to it.
|
|
236
236
|
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
## Links
|
|
239
239
|
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
- [CHANGELOG.md](
|
|
241
|
+
https://github.com/microsoft/rushstack/blob/master/libraries/ts-command-line/CHANGELOG.md) - Find
|
|
242
|
+
out what's new in the latest version
|
|
243
|
+
- [API Reference](https://rushstack.io/pages/api/ts-command-line/)
|
|
242
244
|
|
|
243
245
|
Here are some real world GitHub projects that illustrate different use cases for **ts-command-line**:
|
|
244
246
|
|
|
245
247
|
- [@microsoft/rush](https://www.npmjs.com/package/@microsoft/rush)
|
|
246
248
|
- [@microsoft/api-extractor](https://www.npmjs.com/package/@microsoft/api-extractor)
|
|
247
249
|
- [@microsoft/api-documenter](https://www.npmjs.com/package/@microsoft/api-documenter)
|
|
250
|
+
|
|
251
|
+
`@rushstack/ts-command-line` is part of the [Rush Stack](https://rushstack.io/) family of projects.
|
|
@@ -57,7 +57,7 @@ export declare class CommandLineChoiceParameter extends CommandLineParameter {
|
|
|
57
57
|
readonly completions: (() => Promise<string[]>) | undefined;
|
|
58
58
|
/* Excluded from this release type: __constructor */
|
|
59
59
|
/** {@inheritDoc CommandLineParameter.kind} */
|
|
60
|
-
|
|
60
|
+
get kind(): CommandLineParameterKind;
|
|
61
61
|
/* Excluded from this release type: _setValue */
|
|
62
62
|
/* Excluded from this release type: _getSupplementaryNotes */
|
|
63
63
|
/**
|
|
@@ -67,7 +67,7 @@ export declare class CommandLineChoiceParameter extends CommandLineParameter {
|
|
|
67
67
|
* The return value will be `undefined` if the command-line has not been parsed yet,
|
|
68
68
|
* or if the parameter was omitted and has no default value.
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
get value(): string | undefined;
|
|
71
71
|
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
|
72
72
|
appendToArgList(argList: string[]): void;
|
|
73
73
|
}
|
|
@@ -92,7 +92,7 @@ export declare class CommandLineFlagParameter extends CommandLineParameter {
|
|
|
92
92
|
private _value;
|
|
93
93
|
/* Excluded from this release type: __constructor */
|
|
94
94
|
/** {@inheritDoc CommandLineParameter.kind} */
|
|
95
|
-
|
|
95
|
+
get kind(): CommandLineParameterKind;
|
|
96
96
|
/* Excluded from this release type: _setValue */
|
|
97
97
|
/**
|
|
98
98
|
* Returns a boolean indicating whether the parameter was included in the command line.
|
|
@@ -101,7 +101,7 @@ export declare class CommandLineFlagParameter extends CommandLineParameter {
|
|
|
101
101
|
* The return value will be false if the command-line has not been parsed yet,
|
|
102
102
|
* or if the flag was not used.
|
|
103
103
|
*/
|
|
104
|
-
|
|
104
|
+
get value(): boolean;
|
|
105
105
|
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
|
106
106
|
appendToArgList(argList: string[]): void;
|
|
107
107
|
}
|
|
@@ -130,7 +130,7 @@ export declare class CommandLineIntegerParameter extends CommandLineParameterWit
|
|
|
130
130
|
private _value;
|
|
131
131
|
/* Excluded from this release type: __constructor */
|
|
132
132
|
/** {@inheritDoc CommandLineParameter.kind} */
|
|
133
|
-
|
|
133
|
+
get kind(): CommandLineParameterKind;
|
|
134
134
|
/* Excluded from this release type: _setValue */
|
|
135
135
|
/* Excluded from this release type: _getSupplementaryNotes */
|
|
136
136
|
/**
|
|
@@ -140,7 +140,7 @@ export declare class CommandLineIntegerParameter extends CommandLineParameterWit
|
|
|
140
140
|
* The return value will be undefined if the command-line has not been parsed yet,
|
|
141
141
|
* or if the parameter was omitted and has no default value.
|
|
142
142
|
*/
|
|
143
|
-
|
|
143
|
+
get value(): number | undefined;
|
|
144
144
|
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
|
145
145
|
appendToArgList(argList: string[]): void;
|
|
146
146
|
}
|
|
@@ -172,7 +172,7 @@ export declare abstract class CommandLineParameter {
|
|
|
172
172
|
/**
|
|
173
173
|
* Indicates the type of parameter.
|
|
174
174
|
*/
|
|
175
|
-
abstract
|
|
175
|
+
abstract get kind(): CommandLineParameterKind;
|
|
176
176
|
/**
|
|
177
177
|
* Append the parsed values to the provided string array.
|
|
178
178
|
* @remarks
|
|
@@ -226,12 +226,12 @@ export declare abstract class CommandLineParameterProvider {
|
|
|
226
226
|
/**
|
|
227
227
|
* Returns a collection of the parameters that were defined for this object.
|
|
228
228
|
*/
|
|
229
|
-
|
|
229
|
+
get parameters(): ReadonlyArray<CommandLineParameter>;
|
|
230
230
|
/**
|
|
231
231
|
* If {@link CommandLineParameterProvider.defineCommandLineRemainder} was called,
|
|
232
232
|
* this object captures any remaining command line arguments after the recognized portion.
|
|
233
233
|
*/
|
|
234
|
-
|
|
234
|
+
get remainder(): CommandLineRemainder | undefined;
|
|
235
235
|
/**
|
|
236
236
|
* Defines a command-line parameter whose value must be a string from a fixed set of
|
|
237
237
|
* allowable choices (similar to an enum).
|
|
@@ -392,7 +392,7 @@ export declare abstract class CommandLineParser extends CommandLineParameterProv
|
|
|
392
392
|
/**
|
|
393
393
|
* Returns the list of actions that were defined for this CommandLineParser object.
|
|
394
394
|
*/
|
|
395
|
-
|
|
395
|
+
get actions(): ReadonlyArray<CommandLineAction>;
|
|
396
396
|
/**
|
|
397
397
|
* Defines a new action that can be used with the CommandLineParser instance.
|
|
398
398
|
*/
|
|
@@ -455,7 +455,7 @@ export declare class CommandLineRemainder {
|
|
|
455
455
|
* @remarks
|
|
456
456
|
* The array will be empty if the command-line has not been parsed yet.
|
|
457
457
|
*/
|
|
458
|
-
|
|
458
|
+
get values(): ReadonlyArray<string>;
|
|
459
459
|
/* Excluded from this release type: _setValue */
|
|
460
460
|
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
|
461
461
|
appendToArgList(argList: string[]): void;
|
|
@@ -469,7 +469,7 @@ export declare class CommandLineStringListParameter extends CommandLineParameter
|
|
|
469
469
|
private _values;
|
|
470
470
|
/* Excluded from this release type: __constructor */
|
|
471
471
|
/** {@inheritDoc CommandLineParameter.kind} */
|
|
472
|
-
|
|
472
|
+
get kind(): CommandLineParameterKind;
|
|
473
473
|
/* Excluded from this release type: _setValue */
|
|
474
474
|
/**
|
|
475
475
|
* Returns the string arguments for a string list parameter that was parsed from the command line.
|
|
@@ -478,7 +478,7 @@ export declare class CommandLineStringListParameter extends CommandLineParameter
|
|
|
478
478
|
* The array will be empty if the command-line has not been parsed yet,
|
|
479
479
|
* or if the parameter was omitted and has no default value.
|
|
480
480
|
*/
|
|
481
|
-
|
|
481
|
+
get values(): ReadonlyArray<string>;
|
|
482
482
|
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
|
483
483
|
appendToArgList(argList: string[]): void;
|
|
484
484
|
}
|
|
@@ -493,7 +493,7 @@ export declare class CommandLineStringParameter extends CommandLineParameterWith
|
|
|
493
493
|
private _value;
|
|
494
494
|
/* Excluded from this release type: __constructor */
|
|
495
495
|
/** {@inheritDoc CommandLineParameter.kind} */
|
|
496
|
-
|
|
496
|
+
get kind(): CommandLineParameterKind;
|
|
497
497
|
/* Excluded from this release type: _setValue */
|
|
498
498
|
/* Excluded from this release type: _getSupplementaryNotes */
|
|
499
499
|
/**
|
|
@@ -503,7 +503,7 @@ export declare class CommandLineStringParameter extends CommandLineParameterWith
|
|
|
503
503
|
* The return value will be undefined if the command-line has not been parsed yet,
|
|
504
504
|
* or if the parameter was omitted and has no default value.
|
|
505
505
|
*/
|
|
506
|
-
|
|
506
|
+
get value(): string | undefined;
|
|
507
507
|
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
|
508
508
|
appendToArgList(argList: string[]): void;
|
|
509
509
|
}
|
package/dist/tsdoc-metadata.json
CHANGED
package/lib/CommandLineHelper.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
3
|
// See LICENSE in the project root for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.CommandLineHelper = void 0;
|
|
5
6
|
/**
|
|
6
7
|
* Helpers for working with the ts-command-line API.
|
|
7
8
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandLineHelper.js","sourceRoot":"","sources":["../src/CommandLineHelper.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D
|
|
1
|
+
{"version":3,"file":"CommandLineHelper.js","sourceRoot":"","sources":["../src/CommandLineHelper.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D;;;;GAIG;AACH,MAAa,iBAAiB;IAC5B;;;;OAIG;IACI,MAAM,CAAC,4BAA4B,CAAC,IAAc;QACvD,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,iDAAiD,CAAC;IAC7F,CAAC;CACF;AATD,8CASC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { CommandLineConstants } from './Constants';\r\n\r\n/**\r\n * Helpers for working with the ts-command-line API.\r\n *\r\n * @public\r\n */\r\nexport class CommandLineHelper {\r\n /**\r\n * Returns true if the current command line action is tab-complete.\r\n *\r\n * @public\r\n */\r\n public static isTabCompletionActionRequest(argv: string[]): boolean {\r\n return argv && argv.length > 2 && argv[2] === CommandLineConstants.TabCompletionActionName;\r\n }\r\n}\r\n"]}
|
package/lib/index.js
CHANGED
|
@@ -8,31 +8,31 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
10
|
var CommandLineAction_1 = require("./providers/CommandLineAction");
|
|
11
|
-
exports
|
|
11
|
+
Object.defineProperty(exports, "CommandLineAction", { enumerable: true, get: function () { return CommandLineAction_1.CommandLineAction; } });
|
|
12
12
|
var BaseClasses_1 = require("./parameters/BaseClasses");
|
|
13
|
-
exports
|
|
14
|
-
exports
|
|
15
|
-
exports
|
|
13
|
+
Object.defineProperty(exports, "CommandLineParameterKind", { enumerable: true, get: function () { return BaseClasses_1.CommandLineParameterKind; } });
|
|
14
|
+
Object.defineProperty(exports, "CommandLineParameter", { enumerable: true, get: function () { return BaseClasses_1.CommandLineParameter; } });
|
|
15
|
+
Object.defineProperty(exports, "CommandLineParameterWithArgument", { enumerable: true, get: function () { return BaseClasses_1.CommandLineParameterWithArgument; } });
|
|
16
16
|
var CommandLineFlagParameter_1 = require("./parameters/CommandLineFlagParameter");
|
|
17
|
-
exports
|
|
17
|
+
Object.defineProperty(exports, "CommandLineFlagParameter", { enumerable: true, get: function () { return CommandLineFlagParameter_1.CommandLineFlagParameter; } });
|
|
18
18
|
var CommandLineStringParameter_1 = require("./parameters/CommandLineStringParameter");
|
|
19
|
-
exports
|
|
19
|
+
Object.defineProperty(exports, "CommandLineStringParameter", { enumerable: true, get: function () { return CommandLineStringParameter_1.CommandLineStringParameter; } });
|
|
20
20
|
var CommandLineStringListParameter_1 = require("./parameters/CommandLineStringListParameter");
|
|
21
|
-
exports
|
|
21
|
+
Object.defineProperty(exports, "CommandLineStringListParameter", { enumerable: true, get: function () { return CommandLineStringListParameter_1.CommandLineStringListParameter; } });
|
|
22
22
|
var CommandLineIntegerParameter_1 = require("./parameters/CommandLineIntegerParameter");
|
|
23
|
-
exports
|
|
23
|
+
Object.defineProperty(exports, "CommandLineIntegerParameter", { enumerable: true, get: function () { return CommandLineIntegerParameter_1.CommandLineIntegerParameter; } });
|
|
24
24
|
var CommandLineChoiceParameter_1 = require("./parameters/CommandLineChoiceParameter");
|
|
25
|
-
exports
|
|
25
|
+
Object.defineProperty(exports, "CommandLineChoiceParameter", { enumerable: true, get: function () { return CommandLineChoiceParameter_1.CommandLineChoiceParameter; } });
|
|
26
26
|
var CommandLineRemainder_1 = require("./parameters/CommandLineRemainder");
|
|
27
|
-
exports
|
|
27
|
+
Object.defineProperty(exports, "CommandLineRemainder", { enumerable: true, get: function () { return CommandLineRemainder_1.CommandLineRemainder; } });
|
|
28
28
|
var CommandLineParameterProvider_1 = require("./providers/CommandLineParameterProvider");
|
|
29
|
-
exports
|
|
29
|
+
Object.defineProperty(exports, "CommandLineParameterProvider", { enumerable: true, get: function () { return CommandLineParameterProvider_1.CommandLineParameterProvider; } });
|
|
30
30
|
var CommandLineParser_1 = require("./providers/CommandLineParser");
|
|
31
|
-
exports
|
|
31
|
+
Object.defineProperty(exports, "CommandLineParser", { enumerable: true, get: function () { return CommandLineParser_1.CommandLineParser; } });
|
|
32
32
|
var DynamicCommandLineAction_1 = require("./providers/DynamicCommandLineAction");
|
|
33
|
-
exports
|
|
33
|
+
Object.defineProperty(exports, "DynamicCommandLineAction", { enumerable: true, get: function () { return DynamicCommandLineAction_1.DynamicCommandLineAction; } });
|
|
34
34
|
var DynamicCommandLineParser_1 = require("./providers/DynamicCommandLineParser");
|
|
35
|
-
exports
|
|
35
|
+
Object.defineProperty(exports, "DynamicCommandLineParser", { enumerable: true, get: function () { return DynamicCommandLineParser_1.DynamicCommandLineParser; } });
|
|
36
36
|
var CommandLineHelper_1 = require("./CommandLineHelper");
|
|
37
|
-
exports
|
|
37
|
+
Object.defineProperty(exports, "CommandLineHelper", { enumerable: true, get: function () { return CommandLineHelper_1.CommandLineHelper; } });
|
|
38
38
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D;;;;GAIG;AAEH,mEAA6F;AAApF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAE3D;;;;GAIG;AAEH,mEAA6F;AAApF,sHAAA,iBAAiB,OAAA;AAa1B,wDAIkC;AAHhC,uHAAA,wBAAwB,OAAA;AACxB,mHAAA,oBAAoB,OAAA;AACpB,+HAAA,gCAAgC,OAAA;AAGlC,kFAAiF;AAAxE,oIAAA,wBAAwB,OAAA;AACjC,sFAAqF;AAA5E,wIAAA,0BAA0B,OAAA;AACnC,8FAA6F;AAApF,gJAAA,8BAA8B,OAAA;AACvC,wFAAuF;AAA9E,0IAAA,2BAA2B,OAAA;AACpC,sFAAqF;AAA5E,wIAAA,0BAA0B,OAAA;AACnC,0EAAyE;AAAhE,4HAAA,oBAAoB,OAAA;AAE7B,yFAGkD;AAFhD,4IAAA,4BAA4B,OAAA;AAI9B,mEAA6F;AAAzD,sHAAA,iBAAiB,OAAA;AAErD,iFAAgF;AAAvE,oIAAA,wBAAwB,OAAA;AAEjC,iFAAgF;AAAvE,oIAAA,wBAAwB,OAAA;AAIjC,yDAAwD;AAA/C,sHAAA,iBAAiB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/**\r\n * An object-oriented command-line parser for TypeScript projects.\r\n *\r\n * @packageDocumentation\r\n */\r\n\r\nexport { CommandLineAction, ICommandLineActionOptions } from './providers/CommandLineAction';\r\n\r\nexport {\r\n IBaseCommandLineDefinition,\r\n IBaseCommandLineDefinitionWithArgument,\r\n ICommandLineFlagDefinition,\r\n ICommandLineStringDefinition,\r\n ICommandLineStringListDefinition,\r\n ICommandLineIntegerDefinition,\r\n ICommandLineChoiceDefinition,\r\n ICommandLineRemainderDefinition\r\n} from './parameters/CommandLineDefinition';\r\n\r\nexport {\r\n CommandLineParameterKind,\r\n CommandLineParameter,\r\n CommandLineParameterWithArgument\r\n} from './parameters/BaseClasses';\r\n\r\nexport { CommandLineFlagParameter } from './parameters/CommandLineFlagParameter';\r\nexport { CommandLineStringParameter } from './parameters/CommandLineStringParameter';\r\nexport { CommandLineStringListParameter } from './parameters/CommandLineStringListParameter';\r\nexport { CommandLineIntegerParameter } from './parameters/CommandLineIntegerParameter';\r\nexport { CommandLineChoiceParameter } from './parameters/CommandLineChoiceParameter';\r\nexport { CommandLineRemainder } from './parameters/CommandLineRemainder';\r\n\r\nexport {\r\n CommandLineParameterProvider,\r\n ICommandLineParserData as _ICommandLineParserData\r\n} from './providers/CommandLineParameterProvider';\r\n\r\nexport { ICommandLineParserOptions, CommandLineParser } from './providers/CommandLineParser';\r\n\r\nexport { DynamicCommandLineAction } from './providers/DynamicCommandLineAction';\r\n\r\nexport { DynamicCommandLineParser } from './providers/DynamicCommandLineParser';\r\n\r\nexport { CommandLineConstants } from './Constants';\r\n\r\nexport { CommandLineHelper } from './CommandLineHelper';\r\n"]}
|
|
@@ -27,7 +27,7 @@ export declare abstract class CommandLineParameter {
|
|
|
27
27
|
* A unique internal key used to retrieve the value from the parser's dictionary.
|
|
28
28
|
* @internal
|
|
29
29
|
*/
|
|
30
|
-
_parserKey: string;
|
|
30
|
+
_parserKey: string | undefined;
|
|
31
31
|
/** {@inheritDoc IBaseCommandLineDefinition.parameterLongName} */
|
|
32
32
|
readonly longName: string;
|
|
33
33
|
/** {@inheritDoc IBaseCommandLineDefinition.parameterShortName} */
|
|
@@ -55,7 +55,7 @@ export declare abstract class CommandLineParameter {
|
|
|
55
55
|
/**
|
|
56
56
|
* Indicates the type of parameter.
|
|
57
57
|
*/
|
|
58
|
-
abstract
|
|
58
|
+
abstract get kind(): CommandLineParameterKind;
|
|
59
59
|
/**
|
|
60
60
|
* Append the parsed values to the provided string array.
|
|
61
61
|
* @remarks
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseClasses.d.ts","sourceRoot":"","sources":["../../src/parameters/BaseClasses.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,sCAAsC,EAAE,MAAM,yBAAyB,CAAC;AAE7G;;;GAGG;AACH,oBAAY,wBAAwB;IAClC,6CAA6C;IAC7C,MAAM,IAAA;IACN,2CAA2C;IAC3C,IAAI,IAAA;IACJ,8CAA8C;IAC9C,OAAO,IAAA;IACP,6CAA6C;IAC7C,MAAM,IAAA;IACN,iDAAiD;IACjD,UAAU,IAAA;CACX;AAED;;;GAGG;AACH,8BAAsB,oBAAoB;IAExC,OAAO,CAAC,MAAM,CAAC,eAAe,CAA8B;IAG5D,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAyB;IAMxD,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAgC;IAEzE;;;OAGG;IACI,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseClasses.d.ts","sourceR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AEG;IAEH,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,GAAG,GAAG,KAAK;IAI7C,SAAS,CAAC,oBAAoB,CAAC,eAAe,EAAE,OAAO,GAAG,IAAI;CAY/D;AAED;;;;;;;GAOG;AACH,8BAAsB,gCAAiC,SAAQ,oBAAoB;IAEjF,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAwB;IAEjE,wEAAwE;IACxE,SAAgB,YAAY,EAAE,MAAM,CAAC;IAErC,uEAAuE;IACvE,SAAgB,WAAW,EAAE,CAAC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAEnE,gBAAgB;gBACG,UAAU,EAAE,sCAAsC;CAyBtE"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
3
|
// See LICENSE in the project root for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.CommandLineParameterWithArgument = exports.CommandLineParameter = exports.CommandLineParameterKind = void 0;
|
|
5
6
|
/**
|
|
6
7
|
* Identifies the kind of a CommandLineParameter.
|
|
7
8
|
* @public
|
|
@@ -100,6 +101,7 @@ class CommandLineParameter {
|
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
}
|
|
104
|
+
exports.CommandLineParameter = CommandLineParameter;
|
|
103
105
|
// Example: "--do-something"
|
|
104
106
|
CommandLineParameter._longNameRegExp = /^-(-[a-z0-9]+)+$/;
|
|
105
107
|
// Example: "-d"
|
|
@@ -109,7 +111,6 @@ CommandLineParameter._shortNameRegExp = /^-[a-zA-Z]$/;
|
|
|
109
111
|
// from the characters defined in Portable Character Set and do not begin with a digit."
|
|
110
112
|
// Example: "THE_SETTING"
|
|
111
113
|
CommandLineParameter._environmentVariableRegExp = /^[A-Z_][A-Z0-9_]*$/;
|
|
112
|
-
exports.CommandLineParameter = CommandLineParameter;
|
|
113
114
|
/**
|
|
114
115
|
* The common base class for parameters types that receive an argument.
|
|
115
116
|
*
|
|
@@ -137,7 +138,7 @@ class CommandLineParameterWithArgument extends CommandLineParameter {
|
|
|
137
138
|
this.completions = definition.completions;
|
|
138
139
|
}
|
|
139
140
|
}
|
|
141
|
+
exports.CommandLineParameterWithArgument = CommandLineParameterWithArgument;
|
|
140
142
|
// Matches the first character that *isn't* part of a valid upper-case argument name such as "URL_2"
|
|
141
143
|
CommandLineParameterWithArgument._invalidArgumentNameRegExp = /[^A-Z_0-9]/;
|
|
142
|
-
exports.CommandLineParameterWithArgument = CommandLineParameterWithArgument;
|
|
143
144
|
//# sourceMappingURL=BaseClasses.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseClasses.js","sourceRoot":"","sources":["../../src/parameters/BaseClasses.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAI3D;;;GAGG;AACH,IAAY,wBAWX;AAXD,WAAY,wBAAwB;IAClC,6CAA6C;IAC7C,2EAAM,CAAA;IACN,2CAA2C;IAC3C,uEAAI,CAAA;IACJ,8CAA8C;IAC9C,6EAAO,CAAA;IACP,6CAA6C;IAC7C,2EAAM,CAAA;IACN,iDAAiD;IACjD,mFAAU,CAAA;AACZ,CAAC,EAXW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAWnC;AAED;;;GAGG;AACH,MAAsB,oBAAoB;IAqCxC,gBAAgB;IAChB,YAAmB,UAAsC;QACvD,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,iBAAiB,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,kBAAkB,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;QACtC,IAAI,CAAC,mBAAmB,GAAG,UAAU,CAAC,mBAAmB,CAAC;QAC1D,IAAI,CAAC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,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;SACH;QACD,IAAI,UAAU,CAAC,YAAY,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,YAAY,EAAE;YACrE,MAAM,IAAI,KAAK,CACb,kBAAkB,UAAU,CAAC,YAAY,8CAA8C,CACxF,CAAC;SACH;QACD,MAAM,KAAK,GAA4B,UAAU,CAAC,YAAY,CAAC,KAAK,CAClE,gCAAgC,CAAC,0BAA0B,CAC5D,CAAC;QACF,IAAI,KAAK,EAAE;YACT,MAAM,IAAI,KAAK,CACb,sBAAsB,UAAU,CAAC,YAAY,oCAAoC,KAAK,CAAC,CAAC,CAAC,IAAI;gBAC3F,iEAAiE,CACpE,CAAC;SACH;QACD,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;QAC5C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;IAC5C,CAAC;;AAlCD,oGAAoG;AACrF,2DAA0B,GAAW,YAAY,CAAC;AAFnE,4EAoCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { IBaseCommandLineDefinition, IBaseCommandLineDefinitionWithArgument } from './CommandLineDefinition';\r\n\r\n/**\r\n * Identifies the kind of a CommandLineParameter.\r\n * @public\r\n */\r\nexport enum CommandLineParameterKind {\r\n /** Indicates a CommandLineChoiceParameter */\r\n Choice,\r\n /** Indicates a CommandLineFlagParameter */\r\n Flag,\r\n /** Indicates a CommandLineIntegerParameter */\r\n Integer,\r\n /** Indicates a CommandLineStringParameter */\r\n String,\r\n /** Indicates a CommandLineStringListParameter */\r\n StringList\r\n}\r\n\r\n/**\r\n * The base class for the various command-line parameter types.\r\n * @public\r\n */\r\nexport abstract class CommandLineParameter {\r\n // Example: \"--do-something\"\r\n private static _longNameRegExp: RegExp = /^-(-[a-z0-9]+)+$/;\r\n\r\n // Example: \"-d\"\r\n private static _shortNameRegExp: RegExp = /^-[a-zA-Z]$/;\r\n\r\n // \"Environment variable names used by the utilities in the Shell and Utilities volume of\r\n // IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore)\r\n // from the characters defined in Portable Character Set and do not begin with a digit.\"\r\n // Example: \"THE_SETTING\"\r\n private static _environmentVariableRegExp: RegExp = /^[A-Z_][A-Z0-9_]*$/;\r\n\r\n /**\r\n * A unique internal key used to retrieve the value from the parser's dictionary.\r\n * @internal\r\n */\r\n public _parserKey: string;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.parameterLongName} */\r\n public readonly longName: string;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.parameterShortName} */\r\n public readonly shortName: string | undefined;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.description} */\r\n public readonly description: string;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.required} */\r\n public readonly required: boolean;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.environmentVariable} */\r\n public readonly environmentVariable: string | undefined;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.undocumentedSynonyms } */\r\n public readonly undocumentedSynonyms: string[] | undefined;\r\n\r\n /** @internal */\r\n public constructor(definition: IBaseCommandLineDefinition) {\r\n this.longName = definition.parameterLongName;\r\n this.shortName = definition.parameterShortName;\r\n this.description = definition.description;\r\n this.required = !!definition.required;\r\n this.environmentVariable = definition.environmentVariable;\r\n this.undocumentedSynonyms = definition.undocumentedSynonyms;\r\n\r\n if (!CommandLineParameter._longNameRegExp.test(this.longName)) {\r\n throw new Error(\r\n `Invalid name: \"${this.longName}\". The parameter long name must be` +\r\n ` lower-case and use dash delimiters (e.g. \"--do-a-thing\")`\r\n );\r\n }\r\n\r\n if (this.shortName) {\r\n if (!CommandLineParameter._shortNameRegExp.test(this.shortName)) {\r\n throw new Error(\r\n `Invalid name: \"${this.shortName}\". The parameter short name must be` +\r\n ` a dash followed by a single upper-case or lower-case letter (e.g. \"-a\")`\r\n );\r\n }\r\n }\r\n\r\n if (this.environmentVariable) {\r\n if (this.required) {\r\n // TODO: This constraint is imposed only because argparse enforces \"required\" parameters, but\r\n // it does not know about ts-command-line environment variable mappings. We should fix this.\r\n throw new Error(\r\n `An \"environmentVariable\" cannot be specified for \"${this.longName}\"` +\r\n ` because it is a required parameter`\r\n );\r\n }\r\n\r\n if (!CommandLineParameter._environmentVariableRegExp.test(this.environmentVariable)) {\r\n throw new Error(\r\n `Invalid environment variable name: \"${this.environmentVariable}\". The name must` +\r\n ` consist only of upper-case letters, numbers, and underscores. It may not start with a number.`\r\n );\r\n }\r\n }\r\n\r\n if (this.undocumentedSynonyms && this.undocumentedSynonyms.length > 0) {\r\n if (this.required) {\r\n throw new Error('Undocumented synonyms are not allowed on required parameters.');\r\n }\r\n\r\n for (const undocumentedSynonym of this.undocumentedSynonyms) {\r\n if (this.longName === undocumentedSynonym) {\r\n throw new Error(\r\n `Invalid name: \"${undocumentedSynonym}\". Undocumented Synonyms must not be the same` +\r\n ` as the the long name.`\r\n );\r\n } else if (!CommandLineParameter._longNameRegExp.test(undocumentedSynonym)) {\r\n throw new Error(\r\n `Invalid name: \"${undocumentedSynonym}\". All undocumented Synonyms name must be` +\r\n ` lower-case and use dash delimiters (e.g. \"--do-a-thing\")`\r\n );\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Called internally by CommandLineParameterProvider._processParsedData()\r\n * @internal\r\n */\r\n public abstract _setValue(data: any): void; // eslint-disable-line @typescript-eslint/no-explicit-any\r\n\r\n /**\r\n * Returns additional text used by the help formatter.\r\n * @internal\r\n */\r\n public _getSupplementaryNotes(supplementaryNotes: string[]): void {\r\n // virtual\r\n if (this.environmentVariable !== undefined) {\r\n supplementaryNotes.push(\r\n 'This parameter may alternatively be specified via the ' +\r\n this.environmentVariable +\r\n ' environment variable.'\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Indicates the type of parameter.\r\n */\r\n public abstract get kind(): CommandLineParameterKind;\r\n\r\n /**\r\n * Append the parsed values to the provided string array.\r\n * @remarks\r\n * Sometimes a command line parameter is not used directly, but instead gets passed through to another\r\n * tool that will use it. For example if our parameter comes in as \"--max-count 3\", then we might want to\r\n * call `child_process.spawn()` and append [\"--max-count\", \"3\"] to the args array for that tool.\r\n * appendToArgList() appends zero or more strings to the provided array, based on the input command-line\r\n * that we parsed.\r\n *\r\n * If the parameter was omitted from our command-line and has no default value, then\r\n * nothing will be appended. If the short name was used, the long name will be appended instead.\r\n * @param argList - the parsed strings will be appended to this string array\r\n */\r\n public abstract appendToArgList(argList: string[]): void;\r\n\r\n /**\r\n * Internal usage only. Used to report unexpected output from the argparse library.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n protected reportInvalidData(data: any): never {\r\n throw new Error(`Unexpected data object for parameter \"${this.longName}\": ` + JSON.stringify(data));\r\n }\r\n\r\n protected validateDefaultValue(hasDefaultValue: boolean): void {\r\n if (this.required && hasDefaultValue) {\r\n // If a parameter is \"required\", then the user understands that they always need to\r\n // specify a value for this parameter (either via the command line or via an environment variable).\r\n // It would be confusing to allow a default value that sometimes allows the \"required\" parameter\r\n // to be omitted. If you sometimes don't have a suitable default value, then the better approach\r\n // is to throw a custom error explaining why the parameter is required in that case.\r\n throw new Error(\r\n `A default value cannot be specified for \"${this.longName}\" because it is a \"required\" parameter`\r\n );\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * The common base class for parameters types that receive an argument.\r\n *\r\n * @remarks\r\n * An argument is an accompanying command-line token, such as \"123\" in the\r\n * example \"--max-count 123\".\r\n * @public\r\n */\r\nexport abstract class CommandLineParameterWithArgument extends CommandLineParameter {\r\n // Matches the first character that *isn't* part of a valid upper-case argument name such as \"URL_2\"\r\n private static _invalidArgumentNameRegExp: RegExp = /[^A-Z_0-9]/;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinitionWithArgument.argumentName} */\r\n public readonly argumentName: string;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinitionWithArgument.completions} */\r\n public readonly completions: (() => Promise<string[]>) | undefined;\r\n\r\n /** @internal */\r\n public constructor(definition: IBaseCommandLineDefinitionWithArgument) {\r\n super(definition);\r\n\r\n if (definition.argumentName === '') {\r\n throw new Error(\r\n 'The argument name cannot be an empty string. (For the default name, specify undefined.)'\r\n );\r\n }\r\n if (definition.argumentName.toUpperCase() !== definition.argumentName) {\r\n throw new Error(\r\n `Invalid name: \"${definition.argumentName}\". The argument name must be all upper case.`\r\n );\r\n }\r\n const match: RegExpMatchArray | null = definition.argumentName.match(\r\n CommandLineParameterWithArgument._invalidArgumentNameRegExp\r\n );\r\n if (match) {\r\n throw new Error(\r\n `The argument name \"${definition.argumentName}\" contains an invalid character \"${match[0]}\".` +\r\n ` Only upper-case letters, numbers, and underscores are allowed.`\r\n );\r\n }\r\n this.argumentName = definition.argumentName;\r\n this.completions = definition.completions;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"BaseClasses.js","sourceRoot":"","sources":["../../src/parameters/BaseClasses.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D;;;GAGG;AACH,IAAY,wBAWX;AAXD,WAAY,wBAAwB;IAClC,6CAA6C;IAC7C,2EAAM,CAAA;IACN,2CAA2C;IAC3C,uEAAI,CAAA;IACJ,8CAA8C;IAC9C,6EAAO,CAAA;IACP,6CAA6C;IAC7C,2EAAM,CAAA;IACN,iDAAiD;IACjD,mFAAU,CAAA;AACZ,CAAC,EAXW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAWnC;AAED;;;GAGG;AACH,MAAsB,oBAAoB;IAqCxC,gBAAgB;IAChB,YAAmB,UAAsC;QACvD,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,iBAAiB,CAAC;QAC7C,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,kBAAkB,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG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F,gBAAgB;IAChB,YAAmB,UAAkD;QACnE,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,UAAU,CAAC,YAAY,KAAK,EAAE,EAAE;YAClC,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;SACH;QACD,IAAI,UAAU,CAAC,YAAY,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,YAAY,EAAE;YACrE,MAAM,IAAI,KAAK,CACb,kBAAkB,UAAU,CAAC,YAAY,8CAA8C,CACxF,CAAC;SACH;QACD,MAAM,KAAK,GAA4B,UAAU,CAAC,YAAY,CAAC,KAAK,CAClE,gCAAgC,CAAC,0BAA0B,CAC5D,CAAC;QACF,IAAI,KAAK,EAAE;YACT,MAAM,IAAI,KAAK,CACb,sBAAsB,UAAU,CAAC,YAAY,oCAAoC,KAAK,CAAC,CAAC,CAAC,IAAI;gBAC3F,iEAAiE,CACpE,CAAC;SACH;QACD,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;QAC5C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;IAC5C,CAAC;;AAnCH,4EAoCC;AAnCC,oGAAoG;AACrF,2DAA0B,GAAW,YAAY,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { IBaseCommandLineDefinition, IBaseCommandLineDefinitionWithArgument } from './CommandLineDefinition';\r\n\r\n/**\r\n * Identifies the kind of a CommandLineParameter.\r\n * @public\r\n */\r\nexport enum CommandLineParameterKind {\r\n /** Indicates a CommandLineChoiceParameter */\r\n Choice,\r\n /** Indicates a CommandLineFlagParameter */\r\n Flag,\r\n /** Indicates a CommandLineIntegerParameter */\r\n Integer,\r\n /** Indicates a CommandLineStringParameter */\r\n String,\r\n /** Indicates a CommandLineStringListParameter */\r\n StringList\r\n}\r\n\r\n/**\r\n * The base class for the various command-line parameter types.\r\n * @public\r\n */\r\nexport abstract class CommandLineParameter {\r\n // Example: \"--do-something\"\r\n private static _longNameRegExp: RegExp = /^-(-[a-z0-9]+)+$/;\r\n\r\n // Example: \"-d\"\r\n private static _shortNameRegExp: RegExp = /^-[a-zA-Z]$/;\r\n\r\n // \"Environment variable names used by the utilities in the Shell and Utilities volume of\r\n // IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore)\r\n // from the characters defined in Portable Character Set and do not begin with a digit.\"\r\n // Example: \"THE_SETTING\"\r\n private static _environmentVariableRegExp: RegExp = /^[A-Z_][A-Z0-9_]*$/;\r\n\r\n /**\r\n * A unique internal key used to retrieve the value from the parser's dictionary.\r\n * @internal\r\n */\r\n public _parserKey: string | undefined;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.parameterLongName} */\r\n public readonly longName: string;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.parameterShortName} */\r\n public readonly shortName: string | undefined;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.description} */\r\n public readonly description: string;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.required} */\r\n public readonly required: boolean;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.environmentVariable} */\r\n public readonly environmentVariable: string | undefined;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.undocumentedSynonyms } */\r\n public readonly undocumentedSynonyms: string[] | undefined;\r\n\r\n /** @internal */\r\n public constructor(definition: IBaseCommandLineDefinition) {\r\n this.longName = definition.parameterLongName;\r\n this.shortName = definition.parameterShortName;\r\n this.description = definition.description;\r\n this.required = !!definition.required;\r\n this.environmentVariable = definition.environmentVariable;\r\n this.undocumentedSynonyms = definition.undocumentedSynonyms;\r\n\r\n if (!CommandLineParameter._longNameRegExp.test(this.longName)) {\r\n throw new Error(\r\n `Invalid name: \"${this.longName}\". The parameter long name must be` +\r\n ` lower-case and use dash delimiters (e.g. \"--do-a-thing\")`\r\n );\r\n }\r\n\r\n if (this.shortName) {\r\n if (!CommandLineParameter._shortNameRegExp.test(this.shortName)) {\r\n throw new Error(\r\n `Invalid name: \"${this.shortName}\". The parameter short name must be` +\r\n ` a dash followed by a single upper-case or lower-case letter (e.g. \"-a\")`\r\n );\r\n }\r\n }\r\n\r\n if (this.environmentVariable) {\r\n if (this.required) {\r\n // TODO: This constraint is imposed only because argparse enforces \"required\" parameters, but\r\n // it does not know about ts-command-line environment variable mappings. We should fix this.\r\n throw new Error(\r\n `An \"environmentVariable\" cannot be specified for \"${this.longName}\"` +\r\n ` because it is a required parameter`\r\n );\r\n }\r\n\r\n if (!CommandLineParameter._environmentVariableRegExp.test(this.environmentVariable)) {\r\n throw new Error(\r\n `Invalid environment variable name: \"${this.environmentVariable}\". The name must` +\r\n ` consist only of upper-case letters, numbers, and underscores. It may not start with a number.`\r\n );\r\n }\r\n }\r\n\r\n if (this.undocumentedSynonyms && this.undocumentedSynonyms.length > 0) {\r\n if (this.required) {\r\n throw new Error('Undocumented synonyms are not allowed on required parameters.');\r\n }\r\n\r\n for (const undocumentedSynonym of this.undocumentedSynonyms) {\r\n if (this.longName === undocumentedSynonym) {\r\n throw new Error(\r\n `Invalid name: \"${undocumentedSynonym}\". Undocumented Synonyms must not be the same` +\r\n ` as the the long name.`\r\n );\r\n } else if (!CommandLineParameter._longNameRegExp.test(undocumentedSynonym)) {\r\n throw new Error(\r\n `Invalid name: \"${undocumentedSynonym}\". All undocumented Synonyms name must be` +\r\n ` lower-case and use dash delimiters (e.g. \"--do-a-thing\")`\r\n );\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Called internally by CommandLineParameterProvider._processParsedData()\r\n * @internal\r\n */\r\n public abstract _setValue(data: any): void; // eslint-disable-line @typescript-eslint/no-explicit-any\r\n\r\n /**\r\n * Returns additional text used by the help formatter.\r\n * @internal\r\n */\r\n public _getSupplementaryNotes(supplementaryNotes: string[]): void {\r\n // virtual\r\n if (this.environmentVariable !== undefined) {\r\n supplementaryNotes.push(\r\n 'This parameter may alternatively be specified via the ' +\r\n this.environmentVariable +\r\n ' environment variable.'\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Indicates the type of parameter.\r\n */\r\n public abstract get kind(): CommandLineParameterKind;\r\n\r\n /**\r\n * Append the parsed values to the provided string array.\r\n * @remarks\r\n * Sometimes a command line parameter is not used directly, but instead gets passed through to another\r\n * tool that will use it. For example if our parameter comes in as \"--max-count 3\", then we might want to\r\n * call `child_process.spawn()` and append [\"--max-count\", \"3\"] to the args array for that tool.\r\n * appendToArgList() appends zero or more strings to the provided array, based on the input command-line\r\n * that we parsed.\r\n *\r\n * If the parameter was omitted from our command-line and has no default value, then\r\n * nothing will be appended. If the short name was used, the long name will be appended instead.\r\n * @param argList - the parsed strings will be appended to this string array\r\n */\r\n public abstract appendToArgList(argList: string[]): void;\r\n\r\n /**\r\n * Internal usage only. Used to report unexpected output from the argparse library.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n protected reportInvalidData(data: any): never {\r\n throw new Error(`Unexpected data object for parameter \"${this.longName}\": ` + JSON.stringify(data));\r\n }\r\n\r\n protected validateDefaultValue(hasDefaultValue: boolean): void {\r\n if (this.required && hasDefaultValue) {\r\n // If a parameter is \"required\", then the user understands that they always need to\r\n // specify a value for this parameter (either via the command line or via an environment variable).\r\n // It would be confusing to allow a default value that sometimes allows the \"required\" parameter\r\n // to be omitted. If you sometimes don't have a suitable default value, then the better approach\r\n // is to throw a custom error explaining why the parameter is required in that case.\r\n throw new Error(\r\n `A default value cannot be specified for \"${this.longName}\" because it is a \"required\" parameter`\r\n );\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * The common base class for parameters types that receive an argument.\r\n *\r\n * @remarks\r\n * An argument is an accompanying command-line token, such as \"123\" in the\r\n * example \"--max-count 123\".\r\n * @public\r\n */\r\nexport abstract class CommandLineParameterWithArgument extends CommandLineParameter {\r\n // Matches the first character that *isn't* part of a valid upper-case argument name such as \"URL_2\"\r\n private static _invalidArgumentNameRegExp: RegExp = /[^A-Z_0-9]/;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinitionWithArgument.argumentName} */\r\n public readonly argumentName: string;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinitionWithArgument.completions} */\r\n public readonly completions: (() => Promise<string[]>) | undefined;\r\n\r\n /** @internal */\r\n public constructor(definition: IBaseCommandLineDefinitionWithArgument) {\r\n super(definition);\r\n\r\n if (definition.argumentName === '') {\r\n throw new Error(\r\n 'The argument name cannot be an empty string. (For the default name, specify undefined.)'\r\n );\r\n }\r\n if (definition.argumentName.toUpperCase() !== definition.argumentName) {\r\n throw new Error(\r\n `Invalid name: \"${definition.argumentName}\". The argument name must be all upper case.`\r\n );\r\n }\r\n const match: RegExpMatchArray | null = definition.argumentName.match(\r\n CommandLineParameterWithArgument._invalidArgumentNameRegExp\r\n );\r\n if (match) {\r\n throw new Error(\r\n `The argument name \"${definition.argumentName}\" contains an invalid character \"${match[0]}\".` +\r\n ` Only upper-case letters, numbers, and underscores are allowed.`\r\n );\r\n }\r\n this.argumentName = definition.argumentName;\r\n this.completions = definition.completions;\r\n }\r\n}\r\n"]}
|
|
@@ -15,7 +15,7 @@ export declare class CommandLineChoiceParameter extends CommandLineParameter {
|
|
|
15
15
|
/** @internal */
|
|
16
16
|
constructor(definition: ICommandLineChoiceDefinition);
|
|
17
17
|
/** {@inheritDoc CommandLineParameter.kind} */
|
|
18
|
-
|
|
18
|
+
get kind(): CommandLineParameterKind;
|
|
19
19
|
/**
|
|
20
20
|
* {@inheritDoc CommandLineParameter._setValue}
|
|
21
21
|
* @internal
|
|
@@ -33,7 +33,7 @@ export declare class CommandLineChoiceParameter extends CommandLineParameter {
|
|
|
33
33
|
* The return value will be `undefined` if the command-line has not been parsed yet,
|
|
34
34
|
* or if the parameter was omitted and has no default value.
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
get value(): string | undefined;
|
|
37
37
|
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
|
38
38
|
appendToArgList(argList: string[]): void;
|
|
39
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandLineChoiceParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceParameter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE/E;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,oBAAoB;IAClE,8DAA8D;IAC9D,SAAgB,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAEpD,8DAA8D;IAC9D,SAAgB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjD,OAAO,CAAC,MAAM,CAAiC;IAE/C,6DAA6D;IAC7D,SAAgB,WAAW,EAAE,CAAC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAEnE,gBAAgB;gBACG,UAAU,EAAE,4BAA4B;IAqB3D,8CAA8C;
|
|
1
|
+
{"version":3,"file":"CommandLineChoiceParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceParameter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE/E;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,oBAAoB;IAClE,8DAA8D;IAC9D,SAAgB,YAAY,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAEpD,8DAA8D;IAC9D,SAAgB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjD,OAAO,CAAC,MAAM,CAAiC;IAE/C,6DAA6D;IAC7D,SAAgB,WAAW,EAAE,CAAC,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAEnE,gBAAgB;gBACG,UAAU,EAAE,4BAA4B;IAqB3D,8CAA8C;IAC9C,IAAW,IAAI,IAAI,wBAAwB,CAE1C;IAED;;;OAGG;IAEI,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAkCjC;;;OAGG;IACI,sBAAsB,CAAC,kBAAkB,EAAE,MAAM,EAAE,GAAG,IAAI;IAQjE;;;;;;OAMG;IACH,IAAW,KAAK,IAAI,MAAM,GAAG,SAAS,CAErC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;CAMhD"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
3
|
// See LICENSE in the project root for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.CommandLineChoiceParameter = void 0;
|
|
5
6
|
const BaseClasses_1 = require("./BaseClasses");
|
|
6
7
|
/**
|
|
7
8
|
* The data type returned by {@link CommandLineParameterProvider.defineChoiceParameter}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandLineChoiceParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D
|
|
1
|
+
{"version":3,"file":"CommandLineChoiceParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA+E;AAE/E;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,kCAAoB;IAYlE,gBAAgB;IAChB,YAAmB,UAAwC;QACzD,KAAK,CAAC,UAAU,CAAC,CAAC;QAPZ,WAAM,GAAuB,SAAS,CAAC;QAS7C,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;YACtC,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;SACH;QACD,IAAI,UAAU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AM,CAAC,GAAG,GAAG,CAAC;oBACnE,MAAM,IAAI,KAAK,CACb,kBAAkB,gBAAgB,gCAAgC;wBAChE,IAAI,IAAI,CAAC,mBAAmB,yBAAyB,OAAO,EAAE,CACjE,CAAC;iBACH;gBACD,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC;gBAC/B,OAAO;aACR;SACF;QAED,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;YACnC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;YAChC,OAAO;SACR;QAED,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,sBAAsB,CAAC,kBAA4B;QACxD,UAAU;QACV,KAAK,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;YACnC,kBAAkB,CAAC,IAAI,CAAC,yBAAyB,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC;SACzE;IACH,CAAC;IAED;;;;;;OAMG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1B;IACH,CAAC;CACF;AA5GD,gEA4GC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { ICommandLineChoiceDefinition } from './CommandLineDefinition';\r\nimport { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';\r\n\r\n/**\r\n * The data type returned by {@link CommandLineParameterProvider.defineChoiceParameter}.\r\n * @public\r\n */\r\nexport class CommandLineChoiceParameter extends CommandLineParameter {\r\n /** {@inheritDoc ICommandLineChoiceDefinition.alternatives} */\r\n public readonly alternatives: ReadonlyArray<string>;\r\n\r\n /** {@inheritDoc ICommandLineStringDefinition.defaultValue} */\r\n public readonly defaultValue: string | undefined;\r\n\r\n private _value: string | undefined = undefined;\r\n\r\n /** {@inheritDoc ICommandLineChoiceDefinition.completions} */\r\n public readonly completions: (() => Promise<string[]>) | undefined;\r\n\r\n /** @internal */\r\n public constructor(definition: ICommandLineChoiceDefinition) {\r\n super(definition);\r\n\r\n if (definition.alternatives.length < 1) {\r\n throw new Error(\r\n `When defining a choice parameter, the alternatives list must contain at least one value.`\r\n );\r\n }\r\n if (definition.defaultValue && definition.alternatives.indexOf(definition.defaultValue) === -1) {\r\n throw new Error(\r\n `The specified default value \"${definition.defaultValue}\"` +\r\n ` is not one of the available options: ${definition.alternatives.toString()}`\r\n );\r\n }\r\n\r\n this.alternatives = definition.alternatives;\r\n this.defaultValue = definition.defaultValue;\r\n this.validateDefaultValue(!!this.defaultValue);\r\n this.completions = definition.completions;\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.kind} */\r\n public get kind(): CommandLineParameterKind {\r\n return CommandLineParameterKind.Choice;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._setValue}\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n public _setValue(data: any): void {\r\n // abstract\r\n if (data !== null && data !== undefined) {\r\n if (typeof data !== 'string') {\r\n this.reportInvalidData(data);\r\n }\r\n this._value = data;\r\n return;\r\n }\r\n\r\n if (this.environmentVariable !== undefined) {\r\n // Try reading the environment variable\r\n const environmentValue: string | undefined = process.env[this.environmentVariable];\r\n if (environmentValue !== undefined && environmentValue !== '') {\r\n if (this.alternatives.indexOf(environmentValue) < 0) {\r\n const choices: string = '\"' + this.alternatives.join('\", \"') + '\"';\r\n throw new Error(\r\n `Invalid value \"${environmentValue}\" for the environment variable` +\r\n ` ${this.environmentVariable}. Valid choices are: ${choices}`\r\n );\r\n }\r\n this._value = environmentValue;\r\n return;\r\n }\r\n }\r\n\r\n if (this.defaultValue !== undefined) {\r\n this._value = this.defaultValue;\r\n return;\r\n }\r\n\r\n this._value = undefined;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._getSupplementaryNotes}\r\n * @internal\r\n */\r\n public _getSupplementaryNotes(supplementaryNotes: string[]): void {\r\n // virtual\r\n super._getSupplementaryNotes(supplementaryNotes);\r\n if (this.defaultValue !== undefined) {\r\n supplementaryNotes.push(`The default value is \"${this.defaultValue}\".`);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the argument value for a choice parameter that was parsed from the command line.\r\n *\r\n * @remarks\r\n * The return value will be `undefined` if the command-line has not been parsed yet,\r\n * or if the parameter was omitted and has no default value.\r\n */\r\n public get value(): string | undefined {\r\n return this._value;\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\r\n public appendToArgList(argList: string[]): void {\r\n if (this.value !== undefined) {\r\n argList.push(this.longName);\r\n argList.push(this.value);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -9,7 +9,7 @@ export declare class CommandLineFlagParameter extends CommandLineParameter {
|
|
|
9
9
|
/** @internal */
|
|
10
10
|
constructor(definition: ICommandLineFlagDefinition);
|
|
11
11
|
/** {@inheritDoc CommandLineParameter.kind} */
|
|
12
|
-
|
|
12
|
+
get kind(): CommandLineParameterKind;
|
|
13
13
|
/**
|
|
14
14
|
* {@inheritDoc CommandLineParameter._setValue}
|
|
15
15
|
* @internal
|
|
@@ -22,7 +22,7 @@ export declare class CommandLineFlagParameter extends CommandLineParameter {
|
|
|
22
22
|
* The return value will be false if the command-line has not been parsed yet,
|
|
23
23
|
* or if the flag was not used.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
get value(): boolean;
|
|
26
26
|
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
|
27
27
|
appendToArgList(argList: string[]): void;
|
|
28
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandLineFlagParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineFlagParameter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE/E;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,oBAAoB;IAChE,OAAO,CAAC,MAAM,CAAkB;IAEhC,gBAAgB;gBACG,UAAU,EAAE,0BAA0B;IAIzD,8CAA8C;
|
|
1
|
+
{"version":3,"file":"CommandLineFlagParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineFlagParameter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE/E;;;GAGG;AACH,qBAAa,wBAAyB,SAAQ,oBAAoB;IAChE,OAAO,CAAC,MAAM,CAAkB;IAEhC,gBAAgB;gBACG,UAAU,EAAE,0BAA0B;IAIzD,8CAA8C;IAC9C,IAAW,IAAI,IAAI,wBAAwB,CAE1C;IAED;;;OAGG;IAEI,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAkCjC;;;;;;OAMG;IACH,IAAW,KAAK,IAAI,OAAO,CAE1B;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;CAKhD"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
3
3
|
// See LICENSE in the project root for license information.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.CommandLineFlagParameter = void 0;
|
|
5
6
|
const BaseClasses_1 = require("./BaseClasses");
|
|
6
7
|
/**
|
|
7
8
|
* The data type returned by {@link CommandLineParameterProvider.defineFlagParameter}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandLineFlagParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineFlagParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D
|
|
1
|
+
{"version":3,"file":"CommandLineFlagParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineFlagParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA+E;AAE/E;;;GAGG;AACH,MAAa,wBAAyB,SAAQ,kCAAoB;IAGhE,gBAAgB;IAChB,YAAmB,UAAsC;QACvD,KAAK,CAAC,UAAU,CAAC,CAAC;QAJZ,WAAM,GAAY,KAAK,CAAC;IAKhC,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,IAAI,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,WAAW;QACX,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACvC,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE;gBAC7B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC9B;YAED,yFAAyF;YACzF,uGAAuG;YACvG,qFAAqF;YACrF,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;gBACnB,OAAO;aACR;SACF;QAED,IAAI,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE;YAC1C,uCAAuC;YACvC,MAAM,gBAAgB,GAAuB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACnF,IAAI,gBAAgB,KAAK,SAAS,IAAI,gBAAgB,KAAK,EAAE,EAAE;gBAC7D,IAAI,gBAAgB,KAAK,GAAG,IAAI,gBAAgB,KAAK,GAAG,EAAE;oBACxD,MAAM,IAAI,KAAK,CACb,kBAAkB,gBAAgB,gCAAgC;wBAChE,IAAI,IAAI,CAAC,mBAAmB,8BAA8B,CAC7D,CAAC;iBACH;gBACD,IAAI,CAAC,MAAM,GAAG,gBAAgB,KAAK,GAAG,CAAC;gBACvC,OAAO;aACR;SACF;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC7B;IACH,CAAC;CACF;AArED,4DAqEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { ICommandLineFlagDefinition } from './CommandLineDefinition';\r\nimport { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';\r\n\r\n/**\r\n * The data type returned by {@link CommandLineParameterProvider.defineFlagParameter}.\r\n * @public\r\n */\r\nexport class CommandLineFlagParameter extends CommandLineParameter {\r\n private _value: boolean = false;\r\n\r\n /** @internal */\r\n public constructor(definition: ICommandLineFlagDefinition) {\r\n super(definition);\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.kind} */\r\n public get kind(): CommandLineParameterKind {\r\n return CommandLineParameterKind.Flag;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._setValue}\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n public _setValue(data: any): void {\r\n // abstract\r\n if (data !== null && data !== undefined) {\r\n if (typeof data !== 'boolean') {\r\n this.reportInvalidData(data);\r\n }\r\n\r\n // If the flag is omitted, then argparse sets the data to \"false\" instead of \"undefined\".\r\n // This design prevents a syntax such as \"--flag=false\", probably because argparse prefers \"--no-flag\".\r\n // If we switch to a new CLI parser, we should try to add support for \"--flag=false\".\r\n if (data) {\r\n this._value = data;\r\n return;\r\n }\r\n }\r\n\r\n if (this.environmentVariable !== undefined) {\r\n // Try reading the environment variable\r\n const environmentValue: string | undefined = process.env[this.environmentVariable];\r\n if (environmentValue !== undefined && environmentValue !== '') {\r\n if (environmentValue !== '0' && environmentValue !== '1') {\r\n throw new Error(\r\n `Invalid value \"${environmentValue}\" for the environment variable` +\r\n ` ${this.environmentVariable}. Valid choices are 0 or 1.`\r\n );\r\n }\r\n this._value = environmentValue === '1';\r\n return;\r\n }\r\n }\r\n\r\n this._value = false;\r\n }\r\n\r\n /**\r\n * Returns a boolean indicating whether the parameter was included in the command line.\r\n *\r\n * @remarks\r\n * The return value will be false if the command-line has not been parsed yet,\r\n * or if the flag was not used.\r\n */\r\n public get value(): boolean {\r\n return this._value;\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\r\n public appendToArgList(argList: string[]): void {\r\n if (this.value) {\r\n argList.push(this.longName);\r\n }\r\n }\r\n}\r\n"]}
|