@rushstack/ts-command-line 4.17.3 → 4.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ts-command-line.d.ts +91 -28
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/parameters/CommandLineChoiceListParameter.d.ts +5 -5
- package/lib/parameters/CommandLineChoiceListParameter.d.ts.map +1 -1
- package/lib/parameters/CommandLineChoiceListParameter.js +1 -1
- package/lib/parameters/CommandLineChoiceListParameter.js.map +1 -1
- package/lib/parameters/CommandLineChoiceParameter.d.ts +14 -7
- package/lib/parameters/CommandLineChoiceParameter.d.ts.map +1 -1
- package/lib/parameters/CommandLineChoiceParameter.js +2 -2
- package/lib/parameters/CommandLineChoiceParameter.js.map +1 -1
- package/lib/parameters/CommandLineDefinition.d.ts +16 -13
- package/lib/parameters/CommandLineDefinition.d.ts.map +1 -1
- package/lib/parameters/CommandLineDefinition.js.map +1 -1
- package/lib/parameters/CommandLineIntegerParameter.d.ts +8 -1
- package/lib/parameters/CommandLineIntegerParameter.d.ts.map +1 -1
- package/lib/parameters/CommandLineIntegerParameter.js +1 -1
- package/lib/parameters/CommandLineIntegerParameter.js.map +1 -1
- package/lib/parameters/CommandLineStringParameter.d.ts +8 -1
- package/lib/parameters/CommandLineStringParameter.d.ts.map +1 -1
- package/lib/parameters/CommandLineStringParameter.js +1 -1
- package/lib/parameters/CommandLineStringParameter.js.map +1 -1
- package/lib/providers/CommandLineParameterProvider.d.ts +42 -6
- package/lib/providers/CommandLineParameterProvider.d.ts.map +1 -1
- package/lib/providers/CommandLineParameterProvider.js +0 -28
- package/lib/providers/CommandLineParameterProvider.js.map +1 -1
- package/package.json +4 -4
|
@@ -71,12 +71,12 @@ export declare abstract class CommandLineAction extends CommandLineParameterProv
|
|
|
71
71
|
* The data type returned by {@link CommandLineParameterProvider.defineChoiceListParameter}.
|
|
72
72
|
* @public
|
|
73
73
|
*/
|
|
74
|
-
export declare class CommandLineChoiceListParameter extends CommandLineParameter {
|
|
74
|
+
export declare class CommandLineChoiceListParameter<TChoice extends string = string> extends CommandLineParameter {
|
|
75
75
|
/** {@inheritDoc ICommandLineChoiceListDefinition.alternatives} */
|
|
76
|
-
readonly alternatives: ReadonlyArray<
|
|
76
|
+
readonly alternatives: ReadonlyArray<TChoice>;
|
|
77
77
|
private _values;
|
|
78
78
|
/** {@inheritDoc ICommandLineChoiceListDefinition.completions} */
|
|
79
|
-
readonly completions: (() => Promise<
|
|
79
|
+
readonly completions: (() => Promise<TChoice[]>) | undefined;
|
|
80
80
|
/* Excluded from this release type: __constructor */
|
|
81
81
|
/** {@inheritDoc CommandLineParameter.kind} */
|
|
82
82
|
get kind(): CommandLineParameterKind;
|
|
@@ -88,23 +88,23 @@ export declare class CommandLineChoiceListParameter extends CommandLineParameter
|
|
|
88
88
|
* The array will be empty if the command-line has not been parsed yet,
|
|
89
89
|
* or if the parameter was omitted and has no default value.
|
|
90
90
|
*/
|
|
91
|
-
get values(): ReadonlyArray<
|
|
91
|
+
get values(): ReadonlyArray<TChoice>;
|
|
92
92
|
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
|
93
93
|
appendToArgList(argList: string[]): void;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
-
* The data type returned by {@link CommandLineParameterProvider.defineChoiceParameter}.
|
|
97
|
+
* The data type returned by {@link CommandLineParameterProvider.(defineChoiceParameter:1)}.
|
|
98
98
|
* @public
|
|
99
99
|
*/
|
|
100
|
-
export declare class CommandLineChoiceParameter extends CommandLineParameter {
|
|
100
|
+
export declare class CommandLineChoiceParameter<TChoice extends string = string> extends CommandLineParameter {
|
|
101
101
|
/** {@inheritDoc ICommandLineChoiceDefinition.alternatives} */
|
|
102
|
-
readonly alternatives: ReadonlyArray<
|
|
102
|
+
readonly alternatives: ReadonlyArray<TChoice>;
|
|
103
103
|
/** {@inheritDoc ICommandLineStringDefinition.defaultValue} */
|
|
104
|
-
readonly defaultValue:
|
|
104
|
+
readonly defaultValue: TChoice | undefined;
|
|
105
105
|
private _value;
|
|
106
106
|
/** {@inheritDoc ICommandLineChoiceDefinition.completions} */
|
|
107
|
-
readonly completions: (() => Promise<
|
|
107
|
+
readonly completions: (() => Promise<TChoice[]>) | undefined;
|
|
108
108
|
/* Excluded from this release type: __constructor */
|
|
109
109
|
/** {@inheritDoc CommandLineParameter.kind} */
|
|
110
110
|
get kind(): CommandLineParameterKind;
|
|
@@ -117,7 +117,7 @@ export declare class CommandLineChoiceParameter extends CommandLineParameter {
|
|
|
117
117
|
* The return value will be `undefined` if the command-line has not been parsed yet,
|
|
118
118
|
* or if the parameter was omitted and has no default value.
|
|
119
119
|
*/
|
|
120
|
-
get value():
|
|
120
|
+
get value(): TChoice | undefined;
|
|
121
121
|
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
|
122
122
|
appendToArgList(argList: string[]): void;
|
|
123
123
|
}
|
|
@@ -193,7 +193,7 @@ export declare class CommandLineIntegerListParameter extends CommandLineParamete
|
|
|
193
193
|
}
|
|
194
194
|
|
|
195
195
|
/**
|
|
196
|
-
* The data type returned by {@link CommandLineParameterProvider.defineIntegerParameter}.
|
|
196
|
+
* The data type returned by {@link CommandLineParameterProvider.(defineIntegerParameter:1)}.
|
|
197
197
|
* @public
|
|
198
198
|
*/
|
|
199
199
|
export declare class CommandLineIntegerParameter extends CommandLineParameterWithArgument {
|
|
@@ -335,7 +335,19 @@ export declare abstract class CommandLineParameterProvider {
|
|
|
335
335
|
* example-tool --log-level warn
|
|
336
336
|
* ```
|
|
337
337
|
*/
|
|
338
|
-
defineChoiceParameter(definition: ICommandLineChoiceDefinition
|
|
338
|
+
defineChoiceParameter<TChoice extends string = string>(definition: ICommandLineChoiceDefinition<TChoice> & {
|
|
339
|
+
required: false | undefined;
|
|
340
|
+
}): CommandLineChoiceParameter<TChoice>;
|
|
341
|
+
/**
|
|
342
|
+
* {@inheritdoc CommandLineParameterProvider.(defineChoiceParameter:1)}
|
|
343
|
+
*/
|
|
344
|
+
defineChoiceParameter<TChoice extends string = string>(definition: ICommandLineChoiceDefinition<TChoice> & {
|
|
345
|
+
required: true;
|
|
346
|
+
}): IRequiredCommandLineChoiceParameter<TChoice>;
|
|
347
|
+
/**
|
|
348
|
+
* {@inheritdoc CommandLineParameterProvider.(defineChoiceParameter:1)}
|
|
349
|
+
*/
|
|
350
|
+
defineChoiceParameter<TChoice extends string = string>(definition: ICommandLineChoiceDefinition<TChoice>): CommandLineChoiceParameter<TChoice>;
|
|
339
351
|
/**
|
|
340
352
|
* Returns the CommandLineChoiceParameter with the specified long name.
|
|
341
353
|
* @remarks
|
|
@@ -353,7 +365,7 @@ export declare abstract class CommandLineParameterProvider {
|
|
|
353
365
|
* example-tool --allow-color red --allow-color green
|
|
354
366
|
* ```
|
|
355
367
|
*/
|
|
356
|
-
defineChoiceListParameter(definition: ICommandLineChoiceListDefinition): CommandLineChoiceListParameter
|
|
368
|
+
defineChoiceListParameter<TChoice extends string = string>(definition: ICommandLineChoiceListDefinition<TChoice>): CommandLineChoiceListParameter<TChoice>;
|
|
357
369
|
/**
|
|
358
370
|
* Returns the CommandLineChoiceListParameter with the specified long name.
|
|
359
371
|
* @remarks
|
|
@@ -386,6 +398,18 @@ export declare abstract class CommandLineParameterProvider {
|
|
|
386
398
|
* example-tool --max-attempts 5
|
|
387
399
|
* ```
|
|
388
400
|
*/
|
|
401
|
+
defineIntegerParameter(definition: ICommandLineIntegerDefinition & {
|
|
402
|
+
required: false | undefined;
|
|
403
|
+
}): CommandLineIntegerParameter;
|
|
404
|
+
/**
|
|
405
|
+
* {@inheritdoc CommandLineParameterProvider.(defineIntegerParameter:1)}
|
|
406
|
+
*/
|
|
407
|
+
defineIntegerParameter(definition: ICommandLineIntegerDefinition & {
|
|
408
|
+
required: true;
|
|
409
|
+
}): IRequiredCommandLineIntegerParameter;
|
|
410
|
+
/**
|
|
411
|
+
* {@inheritdoc CommandLineParameterProvider.(defineIntegerParameter:1)}
|
|
412
|
+
*/
|
|
389
413
|
defineIntegerParameter(definition: ICommandLineIntegerDefinition): CommandLineIntegerParameter;
|
|
390
414
|
/**
|
|
391
415
|
* Returns the CommandLineIntegerParameter with the specified long name.
|
|
@@ -419,6 +443,18 @@ export declare abstract class CommandLineParameterProvider {
|
|
|
419
443
|
* example-tool --message "Hello, world!"
|
|
420
444
|
* ```
|
|
421
445
|
*/
|
|
446
|
+
defineStringParameter(definition: ICommandLineStringDefinition & {
|
|
447
|
+
required: false | undefined;
|
|
448
|
+
}): CommandLineStringParameter;
|
|
449
|
+
/**
|
|
450
|
+
* {@inheritdoc CommandLineParameterProvider.(defineStringParameter:1)}
|
|
451
|
+
*/
|
|
452
|
+
defineStringParameter(definition: ICommandLineStringDefinition & {
|
|
453
|
+
required: true;
|
|
454
|
+
}): IRequiredCommandLineStringParameter;
|
|
455
|
+
/**
|
|
456
|
+
* {@inheritdoc CommandLineParameterProvider.(defineStringParameter:1)}
|
|
457
|
+
*/
|
|
422
458
|
defineStringParameter(definition: ICommandLineStringDefinition): CommandLineStringParameter;
|
|
423
459
|
/**
|
|
424
460
|
* Returns the CommandLineStringParameter with the specified long name.
|
|
@@ -632,7 +668,7 @@ export declare class CommandLineStringListParameter extends CommandLineParameter
|
|
|
632
668
|
}
|
|
633
669
|
|
|
634
670
|
/**
|
|
635
|
-
* The data type returned by {@link CommandLineParameterProvider.defineStringParameter}.
|
|
671
|
+
* The data type returned by {@link CommandLineParameterProvider.(defineStringParameter:1)}.
|
|
636
672
|
* @public
|
|
637
673
|
*/
|
|
638
674
|
export declare class CommandLineStringParameter extends CommandLineParameterWithArgument {
|
|
@@ -823,28 +859,29 @@ export declare interface ICommandLineActionOptions {
|
|
|
823
859
|
}
|
|
824
860
|
|
|
825
861
|
/**
|
|
826
|
-
* For use with {@link CommandLineParameterProvider.defineChoiceParameter}
|
|
827
|
-
* this interface
|
|
862
|
+
* For use with {@link CommandLineParameterProvider.(defineChoiceParameter:1)} and
|
|
863
|
+
* {@link CommandLineParameterProvider.(defineChoiceParameter:2)}, this interface
|
|
864
|
+
* defines a command line parameter which is constrained to a list of possible
|
|
828
865
|
* options.
|
|
829
866
|
*
|
|
830
867
|
* @public
|
|
831
868
|
*/
|
|
832
|
-
export declare interface ICommandLineChoiceDefinition extends IBaseCommandLineDefinition {
|
|
869
|
+
export declare interface ICommandLineChoiceDefinition<TChoice extends string = string> extends IBaseCommandLineDefinition {
|
|
833
870
|
/**
|
|
834
871
|
* A list of strings (which contain no spaces), of possible options which can be selected
|
|
835
872
|
*/
|
|
836
|
-
alternatives:
|
|
873
|
+
alternatives: TChoice[];
|
|
837
874
|
/**
|
|
838
875
|
* {@inheritDoc ICommandLineStringDefinition.defaultValue}
|
|
839
876
|
*/
|
|
840
|
-
defaultValue?:
|
|
877
|
+
defaultValue?: TChoice;
|
|
841
878
|
/**
|
|
842
879
|
* An optional callback that provides a list of custom choices for tab completion.
|
|
843
880
|
* @remarks
|
|
844
881
|
* This option is only used when `ICommandLineParserOptions.enableTabCompletionAction`
|
|
845
882
|
* is enabled.
|
|
846
883
|
*/
|
|
847
|
-
completions?: () => Promise<
|
|
884
|
+
completions?: () => Promise<TChoice[]>;
|
|
848
885
|
}
|
|
849
886
|
|
|
850
887
|
/**
|
|
@@ -854,18 +891,18 @@ export declare interface ICommandLineChoiceDefinition extends IBaseCommandLineDe
|
|
|
854
891
|
*
|
|
855
892
|
* @public
|
|
856
893
|
*/
|
|
857
|
-
export declare interface ICommandLineChoiceListDefinition extends IBaseCommandLineDefinition {
|
|
894
|
+
export declare interface ICommandLineChoiceListDefinition<TChoice extends string = string> extends IBaseCommandLineDefinition {
|
|
858
895
|
/**
|
|
859
896
|
* A list of strings (which contain no spaces), of possible options which can be selected
|
|
860
897
|
*/
|
|
861
|
-
alternatives:
|
|
898
|
+
alternatives: TChoice[];
|
|
862
899
|
/**
|
|
863
900
|
* An optional callback that provides a list of custom choices for tab completion.
|
|
864
901
|
* @remarks
|
|
865
902
|
* This option is only used when `ICommandLineParserOptions.enableTabCompletionAction`
|
|
866
903
|
* is enabled.
|
|
867
904
|
*/
|
|
868
|
-
completions?: () => Promise<
|
|
905
|
+
completions?: () => Promise<TChoice[]>;
|
|
869
906
|
}
|
|
870
907
|
|
|
871
908
|
/**
|
|
@@ -878,8 +915,9 @@ export declare interface ICommandLineFlagDefinition extends IBaseCommandLineDefi
|
|
|
878
915
|
}
|
|
879
916
|
|
|
880
917
|
/**
|
|
881
|
-
* For use with {@link CommandLineParameterProvider.defineIntegerParameter},
|
|
882
|
-
* this interface
|
|
918
|
+
* For use with {@link CommandLineParameterProvider.(defineIntegerParameter:1)},
|
|
919
|
+
* {@link CommandLineParameterProvider.(defineIntegerParameter:2)}, this interface
|
|
920
|
+
* defines a command line parameter whose argument is an integer value.
|
|
883
921
|
*
|
|
884
922
|
* @public
|
|
885
923
|
*/
|
|
@@ -941,8 +979,9 @@ export declare interface ICommandLineRemainderDefinition {
|
|
|
941
979
|
}
|
|
942
980
|
|
|
943
981
|
/**
|
|
944
|
-
* For use with {@link CommandLineParameterProvider.defineStringParameter}
|
|
945
|
-
* this interface
|
|
982
|
+
* For use with {@link CommandLineParameterProvider.(defineStringParameter:1)} and
|
|
983
|
+
* {@link CommandLineParameterProvider.(defineStringParameter:2)}, this interface
|
|
984
|
+
* defines a command line parameter whose argument is a string value.
|
|
946
985
|
*
|
|
947
986
|
* @public
|
|
948
987
|
*/
|
|
@@ -971,7 +1010,31 @@ export declare interface ICommandLineStringListDefinition extends IBaseCommandLi
|
|
|
971
1010
|
/* Excluded from this release type: _IRegisterDefinedParametersState */
|
|
972
1011
|
|
|
973
1012
|
/**
|
|
974
|
-
* The
|
|
1013
|
+
* The data type returned by {@link CommandLineParameterProvider.(defineChoiceParameter:2)}.
|
|
1014
|
+
* @public
|
|
1015
|
+
*/
|
|
1016
|
+
export declare interface IRequiredCommandLineChoiceParameter<TChoice extends string = string> extends CommandLineChoiceParameter<TChoice> {
|
|
1017
|
+
value: TChoice;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* The data type returned by {@link CommandLineParameterProvider.(defineIntegerParameter:2)}.
|
|
1022
|
+
* @public
|
|
1023
|
+
*/
|
|
1024
|
+
export declare interface IRequiredCommandLineIntegerParameter extends CommandLineIntegerParameter {
|
|
1025
|
+
value: number;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* The data type returned by {@link CommandLineParameterProvider.(defineStringParameter:2)}.
|
|
1030
|
+
* @public
|
|
1031
|
+
*/
|
|
1032
|
+
export declare interface IRequiredCommandLineStringParameter extends CommandLineStringParameter {
|
|
1033
|
+
value: string;
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
/**
|
|
1037
|
+
* The result containing the parsed parameter long name and scope. Returned when calling
|
|
975
1038
|
* {@link CommandLineParameterProvider.parseScopedLongName}.
|
|
976
1039
|
*
|
|
977
1040
|
* @public
|
package/dist/tsdoc-metadata.json
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -10,11 +10,11 @@ export { AliasCommandLineAction, type IAliasCommandLineActionOptions } from './p
|
|
|
10
10
|
export type { IBaseCommandLineDefinition, IBaseCommandLineDefinitionWithArgument, ICommandLineFlagDefinition, ICommandLineStringDefinition, ICommandLineStringListDefinition, ICommandLineIntegerDefinition, ICommandLineIntegerListDefinition, ICommandLineChoiceDefinition, ICommandLineChoiceListDefinition, ICommandLineRemainderDefinition } from './parameters/CommandLineDefinition';
|
|
11
11
|
export { CommandLineParameterKind, CommandLineParameter, CommandLineParameterWithArgument } from './parameters/BaseClasses';
|
|
12
12
|
export { CommandLineFlagParameter } from './parameters/CommandLineFlagParameter';
|
|
13
|
-
export { CommandLineStringParameter } from './parameters/CommandLineStringParameter';
|
|
13
|
+
export { CommandLineStringParameter, type IRequiredCommandLineStringParameter } from './parameters/CommandLineStringParameter';
|
|
14
14
|
export { CommandLineStringListParameter } from './parameters/CommandLineStringListParameter';
|
|
15
|
-
export { CommandLineIntegerParameter } from './parameters/CommandLineIntegerParameter';
|
|
15
|
+
export { CommandLineIntegerParameter, type IRequiredCommandLineIntegerParameter } from './parameters/CommandLineIntegerParameter';
|
|
16
16
|
export { CommandLineIntegerListParameter } from './parameters/CommandLineIntegerListParameter';
|
|
17
|
-
export { CommandLineChoiceParameter } from './parameters/CommandLineChoiceParameter';
|
|
17
|
+
export { CommandLineChoiceParameter, type IRequiredCommandLineChoiceParameter } from './parameters/CommandLineChoiceParameter';
|
|
18
18
|
export { CommandLineChoiceListParameter } from './parameters/CommandLineChoiceListParameter';
|
|
19
19
|
export { CommandLineRemainder } from './parameters/CommandLineRemainder';
|
|
20
20
|
export { CommandLineParameterProvider, type IScopedLongNameParseResult, type ICommandLineParserData as _ICommandLineParserData, type IRegisterDefinedParametersState as _IRegisterDefinedParametersState } from './providers/CommandLineParameterProvider';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,KAAK,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAC9E,OAAO,EACL,sBAAsB,EACtB,KAAK,8BAA8B,EACpC,MAAM,oCAAoC,CAAC;AAE5C,YAAY,EACV,0BAA0B,EAC1B,sCAAsC,EACtC,0BAA0B,EAC1B,4BAA4B,EAC5B,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,EACjC,4BAA4B,EAC5B,gCAAgC,EAChC,+BAA+B,EAChC,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,gCAAgC,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,0BAA0B,EAC/B,KAAK,sBAAsB,IAAI,uBAAuB,EACtD,KAAK,+BAA+B,IAAI,gCAAgC,EACzE,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,KAAK,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAEhF,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
|
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,mEAAkG;AAAzF,sHAAA,iBAAiB,OAAA;AAC1B,iFAAgF;AAAvE,oIAAA,wBAAwB,OAAA;AACjC,+EAA8E;AAArE,kIAAA,uBAAuB,OAAA;AAChC,6EAG4C;AAF1C,gIAAA,sBAAsB,OAAA;AAiBxB,wDAIkC;AAHhC,uHAAA,wBAAwB,OAAA;AACxB,mHAAA,oBAAoB,OAAA;AACpB,+HAAA,gCAAgC,OAAA;AAGlC,kFAAiF;AAAxE,oIAAA,wBAAwB,OAAA;AACjC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;GAIG;AAEH,mEAAkG;AAAzF,sHAAA,iBAAiB,OAAA;AAC1B,iFAAgF;AAAvE,oIAAA,wBAAwB,OAAA;AACjC,+EAA8E;AAArE,kIAAA,uBAAuB,OAAA;AAChC,6EAG4C;AAF1C,gIAAA,sBAAsB,OAAA;AAiBxB,wDAIkC;AAHhC,uHAAA,wBAAwB,OAAA;AACxB,mHAAA,oBAAoB,OAAA;AACpB,+HAAA,gCAAgC,OAAA;AAGlC,kFAAiF;AAAxE,oIAAA,wBAAwB,OAAA;AACjC,sFAGiD;AAF/C,wIAAA,0BAA0B,OAAA;AAG5B,8FAA6F;AAApF,gJAAA,8BAA8B,OAAA;AACvC,wFAGkD;AAFhD,0IAAA,2BAA2B,OAAA;AAG7B,gGAA+F;AAAtF,kJAAA,+BAA+B,OAAA;AACxC,sFAGiD;AAF/C,wIAAA,0BAA0B,OAAA;AAG5B,8FAA6F;AAApF,gJAAA,8BAA8B,OAAA;AACvC,0EAAyE;AAAhE,4HAAA,oBAAoB,OAAA;AAE7B,yFAKkD;AAJhD,4IAAA,4BAA4B,OAAA;AAM9B,mEAAkG;AAAzF,sHAAA,iBAAiB,OAAA;AAC1B,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.\n// See LICENSE in the project root for license information.\n\n/**\n * An object-oriented command-line parser for TypeScript projects.\n *\n * @packageDocumentation\n */\n\nexport { CommandLineAction, type ICommandLineActionOptions } from './providers/CommandLineAction';\nexport { DynamicCommandLineAction } from './providers/DynamicCommandLineAction';\nexport { ScopedCommandLineAction } from './providers/ScopedCommandLineAction';\nexport {\n AliasCommandLineAction,\n type IAliasCommandLineActionOptions\n} from './providers/AliasCommandLineAction';\n\nexport type {\n IBaseCommandLineDefinition,\n IBaseCommandLineDefinitionWithArgument,\n ICommandLineFlagDefinition,\n ICommandLineStringDefinition,\n ICommandLineStringListDefinition,\n ICommandLineIntegerDefinition,\n ICommandLineIntegerListDefinition,\n ICommandLineChoiceDefinition,\n ICommandLineChoiceListDefinition,\n ICommandLineRemainderDefinition\n} from './parameters/CommandLineDefinition';\n\nexport {\n CommandLineParameterKind,\n CommandLineParameter,\n CommandLineParameterWithArgument\n} from './parameters/BaseClasses';\n\nexport { CommandLineFlagParameter } from './parameters/CommandLineFlagParameter';\nexport {\n CommandLineStringParameter,\n type IRequiredCommandLineStringParameter\n} from './parameters/CommandLineStringParameter';\nexport { CommandLineStringListParameter } from './parameters/CommandLineStringListParameter';\nexport {\n CommandLineIntegerParameter,\n type IRequiredCommandLineIntegerParameter\n} from './parameters/CommandLineIntegerParameter';\nexport { CommandLineIntegerListParameter } from './parameters/CommandLineIntegerListParameter';\nexport {\n CommandLineChoiceParameter,\n type IRequiredCommandLineChoiceParameter\n} from './parameters/CommandLineChoiceParameter';\nexport { CommandLineChoiceListParameter } from './parameters/CommandLineChoiceListParameter';\nexport { CommandLineRemainder } from './parameters/CommandLineRemainder';\n\nexport {\n CommandLineParameterProvider,\n type IScopedLongNameParseResult,\n type ICommandLineParserData as _ICommandLineParserData,\n type IRegisterDefinedParametersState as _IRegisterDefinedParametersState\n} from './providers/CommandLineParameterProvider';\n\nexport { CommandLineParser, type ICommandLineParserOptions } from './providers/CommandLineParser';\nexport { DynamicCommandLineParser } from './providers/DynamicCommandLineParser';\n\nexport { CommandLineConstants } from './Constants';\n\nexport { CommandLineHelper } from './CommandLineHelper';\n"]}
|
|
@@ -4,14 +4,14 @@ import { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';
|
|
|
4
4
|
* The data type returned by {@link CommandLineParameterProvider.defineChoiceListParameter}.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export declare class CommandLineChoiceListParameter extends CommandLineParameter {
|
|
7
|
+
export declare class CommandLineChoiceListParameter<TChoice extends string = string> extends CommandLineParameter {
|
|
8
8
|
/** {@inheritDoc ICommandLineChoiceListDefinition.alternatives} */
|
|
9
|
-
readonly alternatives: ReadonlyArray<
|
|
9
|
+
readonly alternatives: ReadonlyArray<TChoice>;
|
|
10
10
|
private _values;
|
|
11
11
|
/** {@inheritDoc ICommandLineChoiceListDefinition.completions} */
|
|
12
|
-
readonly completions: (() => Promise<
|
|
12
|
+
readonly completions: (() => Promise<TChoice[]>) | undefined;
|
|
13
13
|
/** @internal */
|
|
14
|
-
constructor(definition: ICommandLineChoiceListDefinition);
|
|
14
|
+
constructor(definition: ICommandLineChoiceListDefinition<TChoice>);
|
|
15
15
|
/** {@inheritDoc CommandLineParameter.kind} */
|
|
16
16
|
get kind(): CommandLineParameterKind;
|
|
17
17
|
/**
|
|
@@ -26,7 +26,7 @@ export declare class CommandLineChoiceListParameter extends CommandLineParameter
|
|
|
26
26
|
* The array will be empty if the command-line has not been parsed yet,
|
|
27
27
|
* or if the parameter was omitted and has no default value.
|
|
28
28
|
*/
|
|
29
|
-
get values(): ReadonlyArray<
|
|
29
|
+
get values(): ReadonlyArray<TChoice>;
|
|
30
30
|
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
|
31
31
|
appendToArgList(argList: string[]): void;
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandLineChoiceListParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceListParameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAG/E;;;GAGG;AACH,qBAAa,
|
|
1
|
+
{"version":3,"file":"CommandLineChoiceListParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceListParameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAG/E;;;GAGG;AACH,qBAAa,8BAA8B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,oBAAoB;IACvG,kEAAkE;IAClE,SAAgB,YAAY,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAErD,OAAO,CAAC,OAAO,CAAiB;IAEhC,iEAAiE;IACjE,SAAgB,WAAW,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAEpE,gBAAgB;gBACG,UAAU,EAAE,gCAAgC,CAAC,OAAO,CAAC;IAaxE,8CAA8C;IAC9C,IAAW,IAAI,IAAI,wBAAwB,CAE1C;IAED;;;OAGG;IAEI,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAsCjC;;;;;;OAMG;IACH,IAAW,MAAM,IAAI,aAAa,CAAC,OAAO,CAAC,CAE1C;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;CAQhD"}
|
|
@@ -47,7 +47,7 @@ class CommandLineChoiceListParameter extends BaseClasses_1.CommandLineParameter
|
|
|
47
47
|
const values = EnvironmentVariableParser_1.EnvironmentVariableParser.parseAsList(this.environmentVariable);
|
|
48
48
|
if (values) {
|
|
49
49
|
for (const value of values) {
|
|
50
|
-
if (this.alternatives.
|
|
50
|
+
if (!this.alternatives.includes(value)) {
|
|
51
51
|
const choices = '"' + this.alternatives.join('", "') + '"';
|
|
52
52
|
throw new Error(`Invalid value "${value}" for the environment variable` +
|
|
53
53
|
` ${this.environmentVariable}. Valid choices are: ${choices}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandLineChoiceListParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceListParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA+E;AAC/E,2EAAwE;AAExE;;;GAGG;AACH,MAAa,
|
|
1
|
+
{"version":3,"file":"CommandLineChoiceListParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceListParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA+E;AAC/E,2EAAwE;AAExE;;;GAGG;AACH,MAAa,8BAAgE,SAAQ,kCAAoB;IASvG,gBAAgB;IAChB,YAAmB,UAAqD;QACtE,KAAK,CAAC,UAAU,CAAC,CAAC;QAPZ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AAC,MAAM,CAAC,GAAG,GAAG,CAAC;wBACnE,MAAM,IAAI,KAAK,CACb,kBAAkB,KAAK,gCAAgC;4BACrD,IAAI,IAAI,CAAC,mBAAmB,yBAAyB,OAAO,EAAE,CACjE,CAAC;oBACJ,CAAC;gBACH,CAAC;gBAED,IAAI,CAAC,OAAO,GAAG,MAAmB,CAAC;gBACnC,OAAO;YACT,CAAC;QACH,CAAC;QAED,sCAAsC;QAEtC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA3FD,wEA2FC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineChoiceListDefinition } from './CommandLineDefinition';\nimport { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';\nimport { EnvironmentVariableParser } from './EnvironmentVariableParser';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineChoiceListParameter}.\n * @public\n */\nexport class CommandLineChoiceListParameter<TChoice extends string = string> extends CommandLineParameter {\n /** {@inheritDoc ICommandLineChoiceListDefinition.alternatives} */\n public readonly alternatives: ReadonlyArray<TChoice>;\n\n private _values: TChoice[] = [];\n\n /** {@inheritDoc ICommandLineChoiceListDefinition.completions} */\n public readonly completions: (() => Promise<TChoice[]>) | undefined;\n\n /** @internal */\n public constructor(definition: ICommandLineChoiceListDefinition<TChoice>) {\n super(definition);\n\n if (definition.alternatives.length < 1) {\n throw new Error(\n `When defining a choice list parameter, the alternatives list must contain at least one value.`\n );\n }\n\n this.alternatives = definition.alternatives;\n this.completions = definition.completions;\n }\n\n /** {@inheritDoc CommandLineParameter.kind} */\n public get kind(): CommandLineParameterKind {\n return CommandLineParameterKind.ChoiceList;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // If argparse passed us a value, confirm it is valid\n if (data !== null && data !== undefined) {\n if (!Array.isArray(data)) {\n this.reportInvalidData(data);\n }\n for (const arrayItem of data) {\n if (typeof arrayItem !== 'string') {\n this.reportInvalidData(data);\n }\n }\n this._values = data;\n return;\n }\n\n if (this.environmentVariable !== undefined) {\n const values: string[] | undefined = EnvironmentVariableParser.parseAsList(this.environmentVariable);\n if (values) {\n for (const value of values) {\n if (!this.alternatives.includes(value as TChoice)) {\n const choices: string = '\"' + this.alternatives.join('\", \"') + '\"';\n throw new Error(\n `Invalid value \"${value}\" for the environment variable` +\n ` ${this.environmentVariable}. Valid choices are: ${choices}`\n );\n }\n }\n\n this._values = values as TChoice[];\n return;\n }\n }\n\n // (No default value for choice lists)\n\n this._values = [];\n }\n\n /**\n * Returns the string arguments for a choice list parameter that was parsed from the command line.\n *\n * @remarks\n * The array will be empty if the command-line has not been parsed yet,\n * or if the parameter was omitted and has no default value.\n */\n public get values(): ReadonlyArray<TChoice> {\n return this._values;\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.values.length > 0) {\n for (const value of this.values) {\n argList.push(this.longName);\n argList.push(value);\n }\n }\n }\n}\n"]}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import type { ICommandLineChoiceDefinition } from './CommandLineDefinition';
|
|
2
2
|
import { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';
|
|
3
3
|
/**
|
|
4
|
-
* The data type returned by {@link CommandLineParameterProvider.defineChoiceParameter}.
|
|
4
|
+
* The data type returned by {@link CommandLineParameterProvider.(defineChoiceParameter:2)}.
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export interface IRequiredCommandLineChoiceParameter<TChoice extends string = string> extends CommandLineChoiceParameter<TChoice> {
|
|
8
|
+
value: TChoice;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The data type returned by {@link CommandLineParameterProvider.(defineChoiceParameter:1)}.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export declare class CommandLineChoiceParameter<TChoice extends string = string> extends CommandLineParameter {
|
|
8
15
|
/** {@inheritDoc ICommandLineChoiceDefinition.alternatives} */
|
|
9
|
-
readonly alternatives: ReadonlyArray<
|
|
16
|
+
readonly alternatives: ReadonlyArray<TChoice>;
|
|
10
17
|
/** {@inheritDoc ICommandLineStringDefinition.defaultValue} */
|
|
11
|
-
readonly defaultValue:
|
|
18
|
+
readonly defaultValue: TChoice | undefined;
|
|
12
19
|
private _value;
|
|
13
20
|
/** {@inheritDoc ICommandLineChoiceDefinition.completions} */
|
|
14
|
-
readonly completions: (() => Promise<
|
|
21
|
+
readonly completions: (() => Promise<TChoice[]>) | undefined;
|
|
15
22
|
/** @internal */
|
|
16
|
-
constructor(definition: ICommandLineChoiceDefinition);
|
|
23
|
+
constructor(definition: ICommandLineChoiceDefinition<TChoice>);
|
|
17
24
|
/** {@inheritDoc CommandLineParameter.kind} */
|
|
18
25
|
get kind(): CommandLineParameterKind;
|
|
19
26
|
/**
|
|
@@ -33,7 +40,7 @@ export declare class CommandLineChoiceParameter extends CommandLineParameter {
|
|
|
33
40
|
* The return value will be `undefined` if the command-line has not been parsed yet,
|
|
34
41
|
* or if the parameter was omitted and has no default value.
|
|
35
42
|
*/
|
|
36
|
-
get value():
|
|
43
|
+
get value(): TChoice | undefined;
|
|
37
44
|
/** {@inheritDoc CommandLineParameter.appendToArgList} @override */
|
|
38
45
|
appendToArgList(argList: string[]): void;
|
|
39
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandLineChoiceParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceParameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE/E;;;GAGG;AACH,qBAAa,
|
|
1
|
+
{"version":3,"file":"CommandLineChoiceParameter.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceParameter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAE/E;;;GAGG;AACH,MAAM,WAAW,mCAAmC,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,CAClF,SAAQ,0BAA0B,CAAC,OAAO,CAAC;IAC3C,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,qBAAa,0BAA0B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,oBAAoB;IACnG,8DAA8D;IAC9D,SAAgB,YAAY,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAErD,8DAA8D;IAC9D,SAAgB,YAAY,EAAE,OAAO,GAAG,SAAS,CAAC;IAElD,OAAO,CAAC,MAAM,CAAkC;IAEhD,6DAA6D;IAC7D,SAAgB,WAAW,EAAE,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC;IAEpE,gBAAgB;gBACG,UAAU,EAAE,4BAA4B,CAAC,OAAO,CAAC;IAqBpE,8CAA8C;IAC9C,IAAW,IAAI,IAAI,wBAAwB,CAE1C;IAED;;;OAGG;IAEI,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAmCjC;;;OAGG;IACI,sBAAsB,CAAC,kBAAkB,EAAE,MAAM,EAAE,GAAG,IAAI;IAQjE;;;;;;OAMG;IACH,IAAW,KAAK,IAAI,OAAO,GAAG,SAAS,CAEtC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;CAMhD"}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
exports.CommandLineChoiceParameter = void 0;
|
|
6
6
|
const BaseClasses_1 = require("./BaseClasses");
|
|
7
7
|
/**
|
|
8
|
-
* The data type returned by {@link CommandLineParameterProvider.defineChoiceParameter}.
|
|
8
|
+
* The data type returned by {@link CommandLineParameterProvider.(defineChoiceParameter:1)}.
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
11
|
class CommandLineChoiceParameter extends BaseClasses_1.CommandLineParameter {
|
|
@@ -47,7 +47,7 @@ class CommandLineChoiceParameter extends BaseClasses_1.CommandLineParameter {
|
|
|
47
47
|
// Try reading the environment variable
|
|
48
48
|
const environmentValue = process.env[this.environmentVariable];
|
|
49
49
|
if (environmentValue !== undefined && environmentValue !== '') {
|
|
50
|
-
if (this.alternatives.
|
|
50
|
+
if (!this.alternatives.includes(environmentValue)) {
|
|
51
51
|
const choices = '"' + this.alternatives.join('", "') + '"';
|
|
52
52
|
throw new Error(`Invalid value "${environmentValue}" for the environment variable` +
|
|
53
53
|
` ${this.environmentVariable}. Valid choices are: ${choices}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandLineChoiceParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA+E;
|
|
1
|
+
{"version":3,"file":"CommandLineChoiceParameter.js","sourceRoot":"","sources":["../../src/parameters/Comm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,OAAiB;QACtC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;CACF;AA7GD,gEA6GC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineChoiceDefinition } from './CommandLineDefinition';\nimport { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.(defineChoiceParameter:2)}.\n * @public\n */\nexport interface IRequiredCommandLineChoiceParameter<TChoice extends string = string>\n extends CommandLineChoiceParameter<TChoice> {\n value: TChoice;\n}\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.(defineChoiceParameter:1)}.\n * @public\n */\nexport class CommandLineChoiceParameter<TChoice extends string = string> extends CommandLineParameter {\n /** {@inheritDoc ICommandLineChoiceDefinition.alternatives} */\n public readonly alternatives: ReadonlyArray<TChoice>;\n\n /** {@inheritDoc ICommandLineStringDefinition.defaultValue} */\n public readonly defaultValue: TChoice | undefined;\n\n private _value: TChoice | undefined = undefined;\n\n /** {@inheritDoc ICommandLineChoiceDefinition.completions} */\n public readonly completions: (() => Promise<TChoice[]>) | undefined;\n\n /** @internal */\n public constructor(definition: ICommandLineChoiceDefinition<TChoice>) {\n super(definition);\n\n if (definition.alternatives.length < 1) {\n throw new Error(\n `When defining a choice parameter, the alternatives list must contain at least one value.`\n );\n }\n if (definition.defaultValue && definition.alternatives.indexOf(definition.defaultValue) === -1) {\n throw new Error(\n `The specified default value \"${definition.defaultValue}\"` +\n ` is not one of the available options: ${definition.alternatives.toString()}`\n );\n }\n\n this.alternatives = definition.alternatives;\n this.defaultValue = definition.defaultValue;\n this.validateDefaultValue(!!this.defaultValue);\n this.completions = definition.completions;\n }\n\n /** {@inheritDoc CommandLineParameter.kind} */\n public get kind(): CommandLineParameterKind {\n return CommandLineParameterKind.Choice;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // abstract\n if (data !== null && data !== undefined) {\n if (typeof data !== 'string') {\n this.reportInvalidData(data);\n }\n this._value = data as TChoice;\n return;\n }\n\n if (this.environmentVariable !== undefined) {\n // Try reading the environment variable\n const environmentValue: string | undefined = process.env[this.environmentVariable];\n if (environmentValue !== undefined && environmentValue !== '') {\n if (!this.alternatives.includes(environmentValue as TChoice)) {\n const choices: string = '\"' + this.alternatives.join('\", \"') + '\"';\n throw new Error(\n `Invalid value \"${environmentValue}\" for the environment variable` +\n ` ${this.environmentVariable}. Valid choices are: ${choices}`\n );\n }\n\n this._value = environmentValue as TChoice;\n return;\n }\n }\n\n if (this.defaultValue !== undefined) {\n this._value = this.defaultValue;\n return;\n }\n\n this._value = undefined;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._getSupplementaryNotes}\n * @internal\n */\n public _getSupplementaryNotes(supplementaryNotes: string[]): void {\n // virtual\n super._getSupplementaryNotes(supplementaryNotes);\n if (this.defaultValue !== undefined) {\n supplementaryNotes.push(`The default value is \"${this.defaultValue}\".`);\n }\n }\n\n /**\n * Returns the argument value for a choice parameter that was parsed from the command line.\n *\n * @remarks\n * The return value will be `undefined` if the command-line has not been parsed yet,\n * or if the parameter was omitted and has no default value.\n */\n public get value(): TChoice | undefined {\n return this._value;\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.value !== undefined) {\n argList.push(this.longName);\n argList.push(this.value);\n }\n }\n}\n"]}
|
|
@@ -105,28 +105,29 @@ export interface IBaseCommandLineDefinitionWithArgument extends IBaseCommandLine
|
|
|
105
105
|
completions?: () => Promise<string[]>;
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
|
-
* For use with {@link CommandLineParameterProvider.defineChoiceParameter}
|
|
109
|
-
* this interface
|
|
108
|
+
* For use with {@link CommandLineParameterProvider.(defineChoiceParameter:1)} and
|
|
109
|
+
* {@link CommandLineParameterProvider.(defineChoiceParameter:2)}, this interface
|
|
110
|
+
* defines a command line parameter which is constrained to a list of possible
|
|
110
111
|
* options.
|
|
111
112
|
*
|
|
112
113
|
* @public
|
|
113
114
|
*/
|
|
114
|
-
export interface ICommandLineChoiceDefinition extends IBaseCommandLineDefinition {
|
|
115
|
+
export interface ICommandLineChoiceDefinition<TChoice extends string = string> extends IBaseCommandLineDefinition {
|
|
115
116
|
/**
|
|
116
117
|
* A list of strings (which contain no spaces), of possible options which can be selected
|
|
117
118
|
*/
|
|
118
|
-
alternatives:
|
|
119
|
+
alternatives: TChoice[];
|
|
119
120
|
/**
|
|
120
121
|
* {@inheritDoc ICommandLineStringDefinition.defaultValue}
|
|
121
122
|
*/
|
|
122
|
-
defaultValue?:
|
|
123
|
+
defaultValue?: TChoice;
|
|
123
124
|
/**
|
|
124
125
|
* An optional callback that provides a list of custom choices for tab completion.
|
|
125
126
|
* @remarks
|
|
126
127
|
* This option is only used when `ICommandLineParserOptions.enableTabCompletionAction`
|
|
127
128
|
* is enabled.
|
|
128
129
|
*/
|
|
129
|
-
completions?: () => Promise<
|
|
130
|
+
completions?: () => Promise<TChoice[]>;
|
|
130
131
|
}
|
|
131
132
|
/**
|
|
132
133
|
* For use with {@link CommandLineParameterProvider.defineChoiceListParameter},
|
|
@@ -135,18 +136,18 @@ export interface ICommandLineChoiceDefinition extends IBaseCommandLineDefinition
|
|
|
135
136
|
*
|
|
136
137
|
* @public
|
|
137
138
|
*/
|
|
138
|
-
export interface ICommandLineChoiceListDefinition extends IBaseCommandLineDefinition {
|
|
139
|
+
export interface ICommandLineChoiceListDefinition<TChoice extends string = string> extends IBaseCommandLineDefinition {
|
|
139
140
|
/**
|
|
140
141
|
* A list of strings (which contain no spaces), of possible options which can be selected
|
|
141
142
|
*/
|
|
142
|
-
alternatives:
|
|
143
|
+
alternatives: TChoice[];
|
|
143
144
|
/**
|
|
144
145
|
* An optional callback that provides a list of custom choices for tab completion.
|
|
145
146
|
* @remarks
|
|
146
147
|
* This option is only used when `ICommandLineParserOptions.enableTabCompletionAction`
|
|
147
148
|
* is enabled.
|
|
148
149
|
*/
|
|
149
|
-
completions?: () => Promise<
|
|
150
|
+
completions?: () => Promise<TChoice[]>;
|
|
150
151
|
}
|
|
151
152
|
/**
|
|
152
153
|
* For use with {@link CommandLineParameterProvider.defineFlagParameter},
|
|
@@ -157,8 +158,9 @@ export interface ICommandLineChoiceListDefinition extends IBaseCommandLineDefini
|
|
|
157
158
|
export interface ICommandLineFlagDefinition extends IBaseCommandLineDefinition {
|
|
158
159
|
}
|
|
159
160
|
/**
|
|
160
|
-
* For use with {@link CommandLineParameterProvider.defineIntegerParameter},
|
|
161
|
-
* this interface
|
|
161
|
+
* For use with {@link CommandLineParameterProvider.(defineIntegerParameter:1)},
|
|
162
|
+
* {@link CommandLineParameterProvider.(defineIntegerParameter:2)}, this interface
|
|
163
|
+
* defines a command line parameter whose argument is an integer value.
|
|
162
164
|
*
|
|
163
165
|
* @public
|
|
164
166
|
*/
|
|
@@ -178,8 +180,9 @@ export interface ICommandLineIntegerDefinition extends IBaseCommandLineDefinitio
|
|
|
178
180
|
export interface ICommandLineIntegerListDefinition extends IBaseCommandLineDefinitionWithArgument {
|
|
179
181
|
}
|
|
180
182
|
/**
|
|
181
|
-
* For use with {@link CommandLineParameterProvider.defineStringParameter}
|
|
182
|
-
* this interface
|
|
183
|
+
* For use with {@link CommandLineParameterProvider.(defineStringParameter:1)} and
|
|
184
|
+
* {@link CommandLineParameterProvider.(defineStringParameter:2)}, this interface
|
|
185
|
+
* defines a command line parameter whose argument is a string value.
|
|
183
186
|
*
|
|
184
187
|
* @public
|
|
185
188
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandLineDefinition.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineDefinition.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,uBAAuB,CAAC;IAEzD;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,sCAAuC,SAAQ,0BAA0B;IACxF;;;;;;;OAOG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACvC;AAED
|
|
1
|
+
{"version":3,"file":"CommandLineDefinition.d.ts","sourceRoot":"","sources":["../../src/parameters/CommandLineDefinition.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,uBAAuB,CAAC;IAEzD;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MA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