@rushstack/ts-command-line 4.20.1 → 4.21.1
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/README.md +8 -12
- package/dist/ts-command-line.d.ts +2 -10
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/providers/CommandLineParameterProvider.d.ts +1 -2
- package/lib/providers/CommandLineParameterProvider.d.ts.map +1 -1
- package/lib/providers/CommandLineParameterProvider.js.map +1 -1
- package/lib/providers/ScopedCommandLineAction.d.ts +1 -8
- package/lib/providers/ScopedCommandLineAction.d.ts.map +1 -1
- package/lib/providers/ScopedCommandLineAction.js +14 -23
- package/lib/providers/ScopedCommandLineAction.js.map +1 -1
- package/lib/providers/TabCompletionAction.js +2 -2
- package/lib/providers/TabCompletionAction.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -74,13 +74,7 @@ export class PushAction extends CommandLineAction {
|
|
|
74
74
|
summary: 'Pushes a widget to the service',
|
|
75
75
|
documentation: 'Here we provide a longer description of how our action works.'
|
|
76
76
|
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
protected onExecute(): Promise<void> { // abstract
|
|
80
|
-
return BusinessLogic.doTheWork(this._force.value, this._protocol.value || "(none)");
|
|
81
|
-
}
|
|
82
77
|
|
|
83
|
-
protected onDefineParameters(): void { // abstract
|
|
84
78
|
this._force = this.defineFlagParameter({
|
|
85
79
|
parameterLongName: '--force',
|
|
86
80
|
parameterShortName: '-f',
|
|
@@ -95,6 +89,10 @@ export class PushAction extends CommandLineAction {
|
|
|
95
89
|
defaultValue: 'scp'
|
|
96
90
|
});
|
|
97
91
|
}
|
|
92
|
+
|
|
93
|
+
protected async onExecute(): Promise<void> { // abstract
|
|
94
|
+
await BusinessLogic.doTheWork(this._force.value, this._protocol.value || "(none)");
|
|
95
|
+
}
|
|
98
96
|
}
|
|
99
97
|
```
|
|
100
98
|
|
|
@@ -111,9 +109,7 @@ export class WidgetCommandLine extends CommandLineParser {
|
|
|
111
109
|
});
|
|
112
110
|
|
|
113
111
|
this.addAction(new PushAction());
|
|
114
|
-
}
|
|
115
112
|
|
|
116
|
-
protected onDefineParameters(): void { // abstract
|
|
117
113
|
this._verbose = this.defineFlagParameter({
|
|
118
114
|
parameterLongName: '--verbose',
|
|
119
115
|
parameterShortName: '-v',
|
|
@@ -121,9 +117,9 @@ export class WidgetCommandLine extends CommandLineParser {
|
|
|
121
117
|
});
|
|
122
118
|
}
|
|
123
119
|
|
|
124
|
-
protected onExecute(): Promise<void> { // override
|
|
120
|
+
protected async onExecute(): Promise<void> { // override
|
|
125
121
|
BusinessLogic.configureLogger(this._verbose.value);
|
|
126
|
-
|
|
122
|
+
await super.onExecute();
|
|
127
123
|
}
|
|
128
124
|
}
|
|
129
125
|
```
|
|
@@ -132,7 +128,7 @@ To invoke the parser, the application entry point will do something like this:
|
|
|
132
128
|
|
|
133
129
|
```typescript
|
|
134
130
|
const commandLine: WidgetCommandLine = new WidgetCommandLine();
|
|
135
|
-
commandLine.
|
|
131
|
+
commandLine.executeAsync();
|
|
136
132
|
```
|
|
137
133
|
|
|
138
134
|
When we run `widget --verbose push --force`, the `PushAction.onExecute()` method will get invoked and then your business logic takes over.
|
|
@@ -226,7 +222,7 @@ action.defineChoiceParameter({
|
|
|
226
222
|
});
|
|
227
223
|
|
|
228
224
|
// Parse the command line
|
|
229
|
-
commandLineParser.
|
|
225
|
+
commandLineParser.executeAsync().then(() => {
|
|
230
226
|
console.log('The action is: ' + commandLineParser.selectedAction!.actionName);
|
|
231
227
|
console.log('The force flag is: ' + action.getFlagParameter('--force').value);
|
|
232
228
|
});
|
|
@@ -545,8 +545,7 @@ export declare abstract class CommandLineParameterProvider {
|
|
|
545
545
|
parseScopedLongName(scopedLongName: string): IScopedLongNameParseResult;
|
|
546
546
|
/* Excluded from this release type: _registerDefinedParameters */
|
|
547
547
|
/**
|
|
548
|
-
*
|
|
549
|
-
* e.g. by calling defineFlagParameter().
|
|
548
|
+
* @deprecated - Define parameters in the constructor
|
|
550
549
|
*/
|
|
551
550
|
protected onDefineParameters?(): void;
|
|
552
551
|
/* Excluded from this release type: _getArgumentParser */
|
|
@@ -1148,17 +1147,10 @@ export declare abstract class ScopedCommandLineAction extends CommandLineAction
|
|
|
1148
1147
|
/* Excluded from this release type: _processParsedData */
|
|
1149
1148
|
/* Excluded from this release type: _executeAsync */
|
|
1150
1149
|
/* Excluded from this release type: _registerDefinedParameters */
|
|
1151
|
-
/**
|
|
1152
|
-
* {@inheritdoc CommandLineParameterProvider.onDefineParameters}
|
|
1153
|
-
*/
|
|
1154
|
-
protected onDefineParameters(): void;
|
|
1155
1150
|
/* Excluded from this release type: _getScopedCommandLineParser */
|
|
1156
1151
|
/* Excluded from this release type: _defineParameter */
|
|
1157
1152
|
/**
|
|
1158
|
-
*
|
|
1159
|
-
* e.g. by calling defineFlagParameter(). At least one scoping parameter must be defined.
|
|
1160
|
-
* Scoping parameters are defined by setting the parameterGroupName to
|
|
1161
|
-
* ScopedCommandLineAction.ScopingParameterGroupName.
|
|
1153
|
+
* @deprecated - Define parameters in the constructor
|
|
1162
1154
|
*/
|
|
1163
1155
|
protected onDefineUnscopedParameters?(): void;
|
|
1164
1156
|
/**
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -295,8 +295,7 @@ export declare abstract class CommandLineParameterProvider {
|
|
|
295
295
|
/** @internal */
|
|
296
296
|
_registerDefinedParameters(state: IRegisterDefinedParametersState): void;
|
|
297
297
|
/**
|
|
298
|
-
*
|
|
299
|
-
* e.g. by calling defineFlagParameter().
|
|
298
|
+
* @deprecated - Define parameters in the constructor
|
|
300
299
|
*/
|
|
301
300
|
protected onDefineParameters?(): void;
|
|
302
301
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandLineParameterProvider.d.ts","sourceRoot":"","sources":["../../src/providers/CommandLineParameterProvider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC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;IACI,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAmCtD;;OAEG;IACI,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,0BAA0B;IAW9E,gBAAgB;IACT,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,IAAI;IAyE/E
|
|
1
|
+
{"version":3,"file":"CommandLineParameterProvider.d.ts","sourceRoot":"","sources":["../../src/providers/CommandLineParameterProvider.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAErC,OAAO,KAAK,EACV,4BAA4B,EAC5B,gCAAgC,EAChC,6BAA6B,EAC7B,iCAAiC,EACjC,0BAA0B,EAC1B,4BAA4B,EAC5B,gCAAgC,EAChC,+BAA+B,EAChC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACL,KAAK,wBAAwB,EAG7B,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,0BAA0B,EAC1B,KAAK,mCAAmC,EACzC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,8BAA8B,EAAE,MAAM,8CAA8C,CAAC;AAC9F,OAAO,EACL,2BAA2B,EAC3B,KAAK,oCAAoC,EAC1C,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAC;AAChG,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAClF,OAAO,EACL,0BAA0B,EAC1B,KAAK,mCAAmC,EACzC,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,8BAA8B,EAAE,MAAM,8CAA8C,CAAC;AAC9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAI1E;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;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E,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,aAAa;IAyCrB,OAAO,CAAC,qBAAqB;CAiB9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandLineParameterProvider.js","sourceRoot":"","sources":["../../src/providers/CommandLineParameterProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,mDAAqC;AAarC,2DAKmC;AACnC,yFAGkD;AAClD,iGAA8F;AAC9F,2FAGmD;AACnD,mGAAgG;AAChG,qFAAkF;AAClF,yFAGkD;AAClD,iGAA8F;AAC9F,6EAA0E;AAC1E,4CAAuD;AACvD,6EAA0E;AA6C1E,MAAM,gBAAgB,GAAW,OAAO,CAAC;AACzC,MAAM,oBAAoB,GAAW,UAAU,CAAC;AAChD,MAAM,gCAAgC,GACpC,gFAAgF,CAAC;AAanF;;;;;GAKG;AACH,MAAsB,4BAA4B;IAmBhD,gBAAgB;IAChB,0EAA0E;IAC1E;QACE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,qBAAqB,GAAG,IAAI,GAAG,EAAE,CAAC;QACvC,IAAI,CAAC,sBAAsB,GAAG,IAAI,GAAG,EAAE,CAAC;QACxC,IAAI,CAAC,sBAAsB,GAAG,IAAI,GAAG,EAAE,CAAC;QACxC,IAAI,CAAC,mCAAmC,GAAG,IAAI,GAAG,EAAE,CAAC;QACrD,IAAI,CAAC,oCAAoC,GAAG,IAAI,GAAG,EAAE,CAAC;QACtD,IAAI,CAAC,6BAA6B,GAAG,KAAK,CAAC;QAC3C,IAAI,CAAC,4BAA4B,GAAG,KAAK,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,IAAW,mBAAmB;QAC5B,OAAO,IAAI,CAAC,4BAA4B,CAAC;IAC3C,CAAC;IAED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gB,WAAW,CAAC;QAE/D,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;QACpC,MAAM,IAAI,uDAA0B,CAAC,SAAS,EAAE,GAAG,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACtG,CAAC;;AAn6BH,oEAo6BC;AAn6BgB,wCAAW,GAAW,CAAC,CAAC","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 * as argparse from 'argparse';\n\nimport type {\n ICommandLineChoiceDefinition,\n ICommandLineChoiceListDefinition,\n ICommandLineIntegerDefinition,\n ICommandLineIntegerListDefinition,\n ICommandLineFlagDefinition,\n ICommandLineStringDefinition,\n ICommandLineStringListDefinition,\n ICommandLineRemainderDefinition\n} from '../parameters/CommandLineDefinition';\nimport type { ICommandLineParserOptions } from './CommandLineParser';\nimport {\n type CommandLineParameterBase,\n type CommandLineParameterWithArgument,\n CommandLineParameterKind,\n type CommandLineParameter\n} from '../parameters/BaseClasses';\nimport {\n CommandLineChoiceParameter,\n type IRequiredCommandLineChoiceParameter\n} from '../parameters/CommandLineChoiceParameter';\nimport { CommandLineChoiceListParameter } from '../parameters/CommandLineChoiceListParameter';\nimport {\n CommandLineIntegerParameter,\n type IRequiredCommandLineIntegerParameter\n} from '../parameters/CommandLineIntegerParameter';\nimport { CommandLineIntegerListParameter } from '../parameters/CommandLineIntegerListParameter';\nimport { CommandLineFlagParameter } from '../parameters/CommandLineFlagParameter';\nimport {\n CommandLineStringParameter,\n type IRequiredCommandLineStringParameter\n} from '../parameters/CommandLineStringParameter';\nimport { CommandLineStringListParameter } from '../parameters/CommandLineStringListParameter';\nimport { CommandLineRemainder } from '../parameters/CommandLineRemainder';\nimport { SCOPING_PARAMETER_GROUP } from '../Constants';\nimport { CommandLineParserExitError } from './CommandLineParserExitError';\n\n/**\n * The result containing the parsed parameter long name and scope. Returned when calling\n * {@link CommandLineParameterProvider.parseScopedLongName}.\n *\n * @public\n */\nexport interface IScopedLongNameParseResult {\n /**\n * The long name parsed from the scoped long name, e.g. \"--my-scope:my-parameter\" -\\> \"--my-parameter\"\n */\n longName: string;\n\n /**\n * The scope parsed from the scoped long name or undefined if no scope was found,\n * e.g. \"--my-scope:my-parameter\" -\\> \"my-scope\"\n */\n scope: string | undefined;\n}\n\n/**\n * An object containing the state of the\n *\n * @internal\n */\nexport interface IRegisterDefinedParametersState {\n /**\n * A set of all defined parameter names registered by parent {@link CommandLineParameterProvider}\n * objects.\n */\n parentParameterNames: Set<string>;\n}\n\n/**\n * This is the argparse result data object\n * @internal\n */\nexport interface ICommandLineParserData {\n action: string;\n aliasAction?: string;\n aliasDocumentation?: string;\n [key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n}\n\nconst SCOPE_GROUP_NAME: string = 'scope';\nconst LONG_NAME_GROUP_NAME: string = 'longName';\nconst POSSIBLY_SCOPED_LONG_NAME_REGEXP: RegExp =\n /^--((?<scope>[a-z0-9]+(-[a-z0-9]+)*):)?(?<longName>[a-z0-9]+((-[a-z0-9]+)+)?)$/;\n\ninterface IExtendedArgumentGroup extends argparse.ArgumentGroup {\n // The types are incorrect - this function returns the constructed argument\n // object, which looks like the argument options type.\n addArgument(nameOrFlags: string | string[], options: argparse.ArgumentOptions): argparse.ArgumentOptions;\n}\n\ninterface IExtendedArgumentParser extends argparse.ArgumentParser {\n // This function throws\n error(message: string): never;\n}\n\n/**\n * This is the common base class for CommandLineAction and CommandLineParser\n * that provides functionality for defining command-line parameters.\n *\n * @public\n */\nexport abstract class CommandLineParameterProvider {\n private static _keyCounter: number = 0;\n\n /** @internal */\n public readonly _ambiguousParameterParserKeysByName: Map<string, string>;\n /** @internal */\n protected readonly _registeredParameterParserKeysByName: Map<string, string>;\n\n private readonly _parameters: CommandLineParameter[];\n private readonly _parametersByLongName: Map<string, CommandLineParameter[]>;\n private readonly _parametersByShortName: Map<string, CommandLineParameter[]>;\n private readonly _parameterGroupsByName: Map<\n string | typeof SCOPING_PARAMETER_GROUP,\n argparse.ArgumentGroup\n >;\n private _parametersHaveBeenRegistered: boolean;\n private _parametersHaveBeenProcessed: boolean;\n private _remainder: CommandLineRemainder | undefined;\n\n /** @internal */\n // Third party code should not inherit subclasses or call this constructor\n public constructor() {\n this._parameters = [];\n this._parametersByLongName = new Map();\n this._parametersByShortName = new Map();\n this._parameterGroupsByName = new Map();\n this._ambiguousParameterParserKeysByName = new Map();\n this._registeredParameterParserKeysByName = new Map();\n this._parametersHaveBeenRegistered = false;\n this._parametersHaveBeenProcessed = false;\n }\n\n /**\n * Returns a collection of the parameters that were defined for this object.\n */\n public get parameters(): ReadonlyArray<CommandLineParameterBase> {\n return this._parameters;\n }\n\n /**\n * Informs the caller if the argparse data has been processed into parameters.\n */\n public get parametersProcessed(): boolean {\n return this._parametersHaveBeenProcessed;\n }\n\n /**\n * If {@link CommandLineParameterProvider.defineCommandLineRemainder} was called,\n * this object captures any remaining command line arguments after the recognized portion.\n */\n public get remainder(): CommandLineRemainder | undefined {\n return this._remainder;\n }\n\n /**\n * Defines a command-line parameter whose value must be a string from a fixed set of\n * allowable choices (similar to an enum).\n *\n * @remarks\n * Example of a choice parameter:\n * ```\n * example-tool --log-level warn\n * ```\n */\n public defineChoiceParameter<TChoice extends string = string>(\n definition: ICommandLineChoiceDefinition<TChoice> & {\n required: false | undefined;\n defaultValue: undefined;\n }\n ): CommandLineChoiceParameter<TChoice>;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineChoiceParameter:1)}\n */\n public defineChoiceParameter<TChoice extends string = string>(\n definition: ICommandLineChoiceDefinition<TChoice> & { required: true }\n ): IRequiredCommandLineChoiceParameter<TChoice>;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineChoiceParameter:1)}\n */\n public defineChoiceParameter<TChoice extends string = string>(\n definition: ICommandLineChoiceDefinition<TChoice> & { defaultValue: TChoice }\n ): IRequiredCommandLineChoiceParameter<TChoice>;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineChoiceParameter:1)}\n */\n public defineChoiceParameter<TChoice extends string = string>(\n definition: ICommandLineChoiceDefinition<TChoice>\n ): CommandLineChoiceParameter<TChoice>;\n public defineChoiceParameter<TChoice extends string = string>(\n definition: ICommandLineChoiceDefinition<TChoice>\n ): CommandLineChoiceParameter<TChoice> {\n const parameter: CommandLineChoiceParameter<TChoice> = new CommandLineChoiceParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Returns the CommandLineChoiceParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getChoiceParameter(parameterLongName: string, parameterScope?: string): CommandLineChoiceParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.Choice, parameterScope);\n }\n\n /**\n * Defines a command-line parameter whose value must be a string from a fixed set of\n * allowable choices (similar to an enum). The parameter can be specified multiple times to\n * build a list.\n *\n * @remarks\n * Example of a choice list parameter:\n * ```\n * example-tool --allow-color red --allow-color green\n * ```\n */\n public defineChoiceListParameter<TChoice extends string = string>(\n definition: ICommandLineChoiceListDefinition<TChoice>\n ): CommandLineChoiceListParameter<TChoice> {\n const parameter: CommandLineChoiceListParameter<TChoice> = new CommandLineChoiceListParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Returns the CommandLineChoiceListParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getChoiceListParameter(\n parameterLongName: string,\n parameterScope?: string\n ): CommandLineChoiceListParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.ChoiceList, parameterScope);\n }\n\n /**\n * Defines a command-line switch whose boolean value is true if the switch is provided,\n * and false otherwise.\n *\n * @remarks\n * Example usage of a flag parameter:\n * ```\n * example-tool --debug\n * ```\n */\n public defineFlagParameter(definition: ICommandLineFlagDefinition): CommandLineFlagParameter {\n const parameter: CommandLineFlagParameter = new CommandLineFlagParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Returns the CommandLineFlagParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getFlagParameter(parameterLongName: string, parameterScope?: string): CommandLineFlagParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.Flag, parameterScope);\n }\n\n /**\n * Defines a command-line parameter whose argument is an integer.\n *\n * @remarks\n * Example usage of an integer parameter:\n * ```\n * example-tool --max-attempts 5\n * ```\n */\n public defineIntegerParameter(\n definition: ICommandLineIntegerDefinition & { required: false | undefined; defaultValue: undefined }\n ): CommandLineIntegerParameter;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineIntegerParameter:1)}\n */\n public defineIntegerParameter(\n definition: ICommandLineIntegerDefinition & { required: true }\n ): IRequiredCommandLineIntegerParameter;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineIntegerParameter:1)}\n */\n public defineIntegerParameter(\n definition: ICommandLineIntegerDefinition & { defaultValue: number }\n ): IRequiredCommandLineIntegerParameter;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineIntegerParameter:1)}\n */\n public defineIntegerParameter(definition: ICommandLineIntegerDefinition): CommandLineIntegerParameter;\n public defineIntegerParameter(definition: ICommandLineIntegerDefinition): CommandLineIntegerParameter {\n const parameter: CommandLineIntegerParameter = new CommandLineIntegerParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Returns the CommandLineIntegerParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getIntegerParameter(\n parameterLongName: string,\n parameterScope?: string\n ): CommandLineIntegerParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.Integer, parameterScope);\n }\n\n /**\n * Defines a command-line parameter whose argument is an integer. The parameter can be specified\n * multiple times to build a list.\n *\n * @remarks\n * Example usage of an integer list parameter:\n * ```\n * example-tool --avoid 4 --avoid 13\n * ```\n */\n public defineIntegerListParameter(\n definition: ICommandLineIntegerListDefinition\n ): CommandLineIntegerListParameter {\n const parameter: CommandLineIntegerListParameter = new CommandLineIntegerListParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Returns the CommandLineIntegerParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getIntegerListParameter(\n parameterLongName: string,\n parameterScope?: string\n ): CommandLineIntegerListParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.IntegerList, parameterScope);\n }\n\n /**\n * Defines a command-line parameter whose argument is a single text string.\n *\n * @remarks\n * Example usage of a string parameter:\n * ```\n * example-tool --message \"Hello, world!\"\n * ```\n */\n public defineStringParameter(\n definition: ICommandLineStringDefinition & { required: false | undefined; defaultValue: undefined }\n ): CommandLineStringParameter;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineStringParameter:1)}\n */\n public defineStringParameter(\n definition: ICommandLineStringDefinition & { required: true }\n ): IRequiredCommandLineStringParameter;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineStringParameter:1)}\n */\n public defineStringParameter(\n definition: ICommandLineStringDefinition & { defaultValue: string }\n ): IRequiredCommandLineStringParameter;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineStringParameter:1)}\n */\n public defineStringParameter(definition: ICommandLineStringDefinition): CommandLineStringParameter;\n public defineStringParameter(definition: ICommandLineStringDefinition): CommandLineStringParameter {\n const parameter: CommandLineStringParameter = new CommandLineStringParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Returns the CommandLineStringParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getStringParameter(parameterLongName: string, parameterScope?: string): CommandLineStringParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.String, parameterScope);\n }\n\n /**\n * Defines a command-line parameter whose argument is a single text string. The parameter can be\n * specified multiple times to build a list.\n *\n * @remarks\n * Example usage of a string list parameter:\n * ```\n * example-tool --add file1.txt --add file2.txt --add file3.txt\n * ```\n */\n public defineStringListParameter(\n definition: ICommandLineStringListDefinition\n ): CommandLineStringListParameter {\n const parameter: CommandLineStringListParameter = new CommandLineStringListParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Defines a rule that captures any remaining command line arguments after the recognized portion.\n *\n * @remarks\n * This feature is useful for commands that pass their arguments along to an external tool, relying on\n * that tool to perform validation. (It could also be used to parse parameters without any validation\n * or documentation, but that is not recommended.)\n *\n * Example of capturing the remainder after an optional flag parameter.\n * ```\n * example-tool --my-flag this is the remainder\n * ```\n *\n * In the \"--help\" documentation, the remainder rule will be represented as \"...\".\n */\n public defineCommandLineRemainder(definition: ICommandLineRemainderDefinition): CommandLineRemainder {\n if (this._remainder) {\n throw new Error('defineRemainingArguments() has already been called for this provider');\n }\n this._remainder = new CommandLineRemainder(definition);\n return this._remainder;\n }\n\n /**\n * Returns the CommandLineStringListParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getStringListParameter(\n parameterLongName: string,\n parameterScope?: string\n ): CommandLineStringListParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.StringList, parameterScope);\n }\n\n /**\n * Generates the command-line help text.\n */\n public renderHelpText(): string {\n const initialState: IRegisterDefinedParametersState = {\n parentParameterNames: new Set()\n };\n this._registerDefinedParameters(initialState);\n return this._getArgumentParser().formatHelp();\n }\n\n /**\n * Generates the command-line usage text.\n */\n public renderUsageText(): string {\n const initialState: IRegisterDefinedParametersState = {\n parentParameterNames: new Set()\n };\n this._registerDefinedParameters(initialState);\n return this._getArgumentParser().formatUsage();\n }\n\n /**\n * Returns a object which maps the long name of each parameter in this.parameters\n * to the stringified form of its value. This is useful for logging telemetry, but\n * it is not the proper way of accessing parameters or their values.\n */\n public getParameterStringMap(): Record<string, string> {\n const parameterMap: Record<string, string> = {};\n for (const parameter of this.parameters) {\n const parameterName: string = parameter.scopedLongName || parameter.longName;\n switch (parameter.kind) {\n case CommandLineParameterKind.Flag:\n case CommandLineParameterKind.Choice:\n case CommandLineParameterKind.String:\n case CommandLineParameterKind.Integer:\n parameterMap[parameterName] = JSON.stringify(\n (\n parameter as\n | CommandLineFlagParameter\n | CommandLineIntegerParameter\n | CommandLineChoiceParameter\n | CommandLineStringParameter\n ).value\n );\n break;\n case CommandLineParameterKind.StringList:\n case CommandLineParameterKind.IntegerList:\n case CommandLineParameterKind.ChoiceList:\n const arrayValue: ReadonlyArray<string | number> | undefined = (\n parameter as\n | CommandLineIntegerListParameter\n | CommandLineStringListParameter\n | CommandLineChoiceListParameter\n ).values;\n parameterMap[parameterName] = arrayValue ? arrayValue.join(',') : '';\n break;\n }\n }\n return parameterMap;\n }\n\n /**\n * Returns an object with the parsed scope (if present) and the long name of the parameter.\n */\n public parseScopedLongName(scopedLongName: string): IScopedLongNameParseResult {\n const result: RegExpExecArray | null = POSSIBLY_SCOPED_LONG_NAME_REGEXP.exec(scopedLongName);\n if (!result || !result.groups) {\n throw new Error(`The parameter long name \"${scopedLongName}\" is not valid.`);\n }\n return {\n longName: `--${result.groups[LONG_NAME_GROUP_NAME]}`,\n scope: result.groups[SCOPE_GROUP_NAME]\n };\n }\n\n /** @internal */\n public _registerDefinedParameters(state: IRegisterDefinedParametersState): void {\n if (this._parametersHaveBeenRegistered) {\n // We prevent new parameters from being defined after the first call to _registerDefinedParameters,\n // so we can already ensure that all parameters were registered.\n return;\n }\n\n // First, loop through all parameters with short names. If there are any duplicates, disable the short names\n // since we can't prefix scopes to short names in order to deduplicate them. The duplicate short names will\n // be reported as errors if the user attempts to use them.\n const parametersWithDuplicateShortNames: Set<CommandLineParameterBase> = new Set();\n for (const [shortName, shortNameParameters] of this._parametersByShortName.entries()) {\n if (shortNameParameters.length > 1) {\n for (const parameter of shortNameParameters) {\n this._defineAmbiguousParameter(shortName);\n parametersWithDuplicateShortNames.add(parameter);\n }\n }\n }\n\n // Then, loop through all parameters and register them. If there are any duplicates, ensure that they have\n // provided a scope and register them with the scope. The duplicate long names will be reported as an error\n // if the user attempts to use them.\n for (const longNameParameters of this._parametersByLongName.values()) {\n const useScopedLongName: boolean = longNameParameters.length > 1;\n for (const parameter of longNameParameters) {\n if (useScopedLongName) {\n if (!parameter.parameterScope) {\n throw new Error(\n `The parameter \"${parameter.longName}\" is defined multiple times with the same long name. ` +\n 'Parameters with the same long name must define a scope.'\n );\n }\n this._defineAmbiguousParameter(parameter.longName);\n }\n\n const ignoreShortName: boolean = parametersWithDuplicateShortNames.has(parameter);\n this._registerParameter(parameter, useScopedLongName, ignoreShortName);\n }\n }\n\n // Register the existing parameters as ambiguous parameters. These are generally provided by the\n // parent action.\n const { parentParameterNames } = state;\n for (const parentParameterName of parentParameterNames) {\n this._defineAmbiguousParameter(parentParameterName);\n }\n\n // We also need to loop through the defined ambiguous parameters and register them. These will be reported\n // as errors if the user attempts to use them.\n for (const [ambiguousParameterName, parserKey] of this._ambiguousParameterParserKeysByName) {\n // Only register the ambiguous parameter if it hasn't already been registered. We will still handle these\n // already-registered parameters as ambiguous, but by avoiding registering again, we will defer errors\n // until the user actually attempts to use the parameter.\n if (!this._registeredParameterParserKeysByName.has(ambiguousParameterName)) {\n this._registerAmbiguousParameter(ambiguousParameterName, parserKey);\n }\n }\n\n // Need to add the remainder parameter last\n if (this._remainder) {\n const argparseOptions: argparse.ArgumentOptions = {\n help: this._remainder.description,\n nargs: argparse.Const.REMAINDER,\n metavar: '\"...\"'\n };\n\n this._getArgumentParser().addArgument(argparse.Const.REMAINDER, argparseOptions);\n }\n\n this._parametersHaveBeenRegistered = true;\n }\n\n /**\n * The child class should implement this hook to define its command-line parameters,\n * e.g. by calling defineFlagParameter().\n */\n protected onDefineParameters?(): void;\n\n /**\n * Retrieves the argparse object.\n * @internal\n */\n protected abstract _getArgumentParser(): argparse.ArgumentParser;\n\n /**\n * This is called internally by {@link CommandLineParser.executeAsync}\n * @internal\n */\n public _preParse(): void {\n for (const parameter of this._parameters) {\n parameter._preParse?.();\n }\n }\n\n /**\n * This is called internally by {@link CommandLineParser.executeAsync} before `printUsage` is called\n * @internal\n */\n public _postParse(): void {\n for (const parameter of this._parameters) {\n parameter._postParse?.();\n }\n }\n\n /**\n * This is called internally by {@link CommandLineParser.executeAsync}\n * @internal\n */\n public _processParsedData(parserOptions: ICommandLineParserOptions, data: ICommandLineParserData): void {\n if (!this._parametersHaveBeenRegistered) {\n throw new Error('Parameters have not been registered');\n }\n\n if (this._parametersHaveBeenProcessed) {\n throw new Error('Command Line Parser Data was already processed');\n }\n\n // Search for any ambiguous parameters and throw an error if any are found\n for (const [parameterName, parserKey] of this._ambiguousParameterParserKeysByName) {\n if (data[parserKey]) {\n // When the parser key matches the actually registered parameter, we know that this is an ambiguous\n // parameter sourced from the parent action or tool\n if (this._registeredParameterParserKeysByName.get(parameterName) === parserKey) {\n this._throwParserExitError(parserOptions, data, 1, `Ambiguous option: \"${parameterName}\".`);\n }\n\n // Determine if the ambiguous parameter is a short name or a long name, since the process of finding\n // the non-ambiguous name is different for each.\n const duplicateShortNameParameters: CommandLineParameterBase[] | undefined =\n this._parametersByShortName.get(parameterName);\n if (duplicateShortNameParameters) {\n // We also need to make sure we get the non-ambiguous long name for the parameter, since it is\n // possible for that the long name is ambiguous as well.\n const nonAmbiguousLongNames: string[] = [];\n for (const parameter of duplicateShortNameParameters) {\n const matchingLongNameParameters: CommandLineParameterBase[] | undefined =\n this._parametersByLongName.get(parameter.longName);\n if (!matchingLongNameParameters?.length) {\n // This should never happen\n throw new Error(\n `Unable to find long name parameters for ambiguous short name parameter \"${parameterName}\".`\n );\n }\n // If there is more than one matching long name parameter, then we know that we need to use the\n // scoped long name for the parameter. The scoped long name should always be provided.\n if (matchingLongNameParameters.length > 1) {\n if (!parameter.scopedLongName) {\n // This should never happen\n throw new Error(\n `Unable to find scoped long name for ambiguous short name parameter \"${parameterName}\".`\n );\n }\n nonAmbiguousLongNames.push(parameter.scopedLongName);\n } else {\n nonAmbiguousLongNames.push(parameter.longName);\n }\n }\n\n // Throw an error including the non-ambiguous long names for the parameters that have the ambiguous\n // short name, ex.\n // Error: Ambiguous option \"-p\" could match \"--param1\", \"--param2\"\n this._throwParserExitError(\n parserOptions,\n data,\n 1,\n `Ambiguous option: \"${parameterName}\" could match ${nonAmbiguousLongNames.join(', ')}.`\n );\n }\n\n const duplicateLongNameParameters: CommandLineParameterBase[] | undefined =\n this._parametersByLongName.get(parameterName);\n if (duplicateLongNameParameters) {\n const nonAmbiguousLongNames: string[] = duplicateLongNameParameters.map(\n (p: CommandLineParameterBase) => {\n // The scoped long name should always be provided\n if (!p.scopedLongName) {\n // This should never happen\n throw new Error(\n `Unable to find scoped long name for ambiguous long name parameter \"${parameterName}\".`\n );\n }\n return p.scopedLongName;\n }\n );\n\n // Throw an error including the non-ambiguous scoped long names for the parameters that have the\n // ambiguous long name, ex.\n // Error: Ambiguous option: \"--param\" could match --scope1:param, --scope2:param\n this._throwParserExitError(\n parserOptions,\n data,\n 1,\n `Ambiguous option: \"${parameterName}\" could match ${nonAmbiguousLongNames.join(', ')}.`\n );\n }\n\n // This shouldn't happen, but we also shouldn't allow the user to use the ambiguous parameter\n this._throwParserExitError(parserOptions, data, 1, `Ambiguous option: \"${parameterName}\".`);\n }\n }\n\n // Fill in the values for the parameters\n for (const parameter of this._parameters) {\n const value: unknown = data[parameter._parserKey!];\n parameter._setValue(value);\n parameter._validateValue?.();\n }\n\n if (this.remainder) {\n this.remainder._setValue(data[argparse.Const.REMAINDER]);\n }\n\n this._parametersHaveBeenProcessed = true;\n }\n\n /** @internal */\n protected _defineParameter(parameter: CommandLineParameter): void {\n if (this._parametersHaveBeenRegistered) {\n throw new Error('Parameters have already been registered for this provider');\n }\n\n // Generate and set the parser key at definition time\n parameter._parserKey = this._generateKey();\n\n this._parameters.push(parameter);\n\n // Collect all parameters with the same long name. We will perform conflict resolution at registration.\n let longNameParameters: CommandLineParameter[] | undefined = this._parametersByLongName.get(\n parameter.longName\n );\n if (!longNameParameters) {\n longNameParameters = [];\n this._parametersByLongName.set(parameter.longName, longNameParameters);\n }\n longNameParameters.push(parameter);\n\n // Collect all parameters with the same short name. We will perform conflict resolution at registration.\n if (parameter.shortName) {\n let shortNameParameters: CommandLineParameter[] | undefined = this._parametersByShortName.get(\n parameter.shortName\n );\n if (!shortNameParameters) {\n shortNameParameters = [];\n this._parametersByShortName.set(parameter.shortName, shortNameParameters);\n }\n shortNameParameters.push(parameter);\n }\n }\n\n /** @internal */\n protected _defineAmbiguousParameter(name: string): string {\n if (this._parametersHaveBeenRegistered) {\n throw new Error('Parameters have already been registered for this provider');\n }\n\n // Only generate a new parser key if the ambiguous parameter hasn't been defined yet,\n // either as an existing parameter or as another ambiguous parameter\n let existingParserKey: string | undefined =\n this._registeredParameterParserKeysByName.get(name) ||\n this._ambiguousParameterParserKeysByName.get(name);\n if (!existingParserKey) {\n existingParserKey = this._generateKey();\n }\n\n this._ambiguousParameterParserKeysByName.set(name, existingParserKey);\n return existingParserKey;\n }\n\n /** @internal */\n protected _registerParameter(\n parameter: CommandLineParameter,\n useScopedLongName: boolean,\n ignoreShortName: boolean\n ): void {\n const {\n shortName,\n longName,\n scopedLongName,\n description,\n kind,\n required,\n environmentVariable,\n parameterGroup,\n undocumentedSynonyms,\n _parserKey: parserKey\n } = parameter;\n\n const names: string[] = [];\n if (shortName && !ignoreShortName) {\n names.push(shortName);\n }\n\n // Use the original long name unless otherwise requested\n if (!useScopedLongName) {\n names.push(longName);\n }\n\n // Add the scoped long name if it exists\n if (scopedLongName) {\n names.push(scopedLongName);\n }\n\n let finalDescription: string = description;\n\n const supplementaryNotes: string[] = [];\n parameter._getSupplementaryNotes(supplementaryNotes);\n if (supplementaryNotes.length > 0) {\n // If they left the period off the end of their sentence, then add one.\n if (finalDescription.match(/[a-z0-9]\"?\\s*$/i)) {\n finalDescription = finalDescription.trimEnd() + '.';\n }\n // Append the supplementary text\n finalDescription += ' ' + supplementaryNotes.join(' ');\n }\n\n let choices: string[] | undefined;\n let action: string | undefined;\n let type: string | undefined;\n switch (kind) {\n case CommandLineParameterKind.Choice: {\n choices = parameter.alternatives as string[];\n break;\n }\n case CommandLineParameterKind.ChoiceList: {\n choices = parameter.alternatives as string[];\n action = 'append';\n break;\n }\n case CommandLineParameterKind.Flag:\n action = 'storeTrue';\n break;\n case CommandLineParameterKind.Integer:\n type = 'int';\n break;\n case CommandLineParameterKind.IntegerList:\n type = 'int';\n action = 'append';\n break;\n case CommandLineParameterKind.String:\n break;\n case CommandLineParameterKind.StringList:\n action = 'append';\n break;\n }\n\n // NOTE: Our \"environmentVariable\" feature takes precedence over argparse's \"defaultValue\",\n // so we have to reimplement that feature.\n const argparseOptions: argparse.ArgumentOptions = {\n help: finalDescription,\n dest: parserKey,\n metavar: (parameter as CommandLineParameterWithArgument).argumentName,\n required,\n choices,\n action,\n type\n };\n\n const argumentParser: IExtendedArgumentParser = this._getArgumentParser() as IExtendedArgumentParser;\n let argumentGroup: argparse.ArgumentGroup | undefined;\n if (parameterGroup) {\n argumentGroup = this._parameterGroupsByName.get(parameterGroup);\n if (!argumentGroup) {\n let parameterGroupName: string;\n if (typeof parameterGroup === 'string') {\n parameterGroupName = parameterGroup;\n } else if (parameterGroup === SCOPING_PARAMETER_GROUP) {\n parameterGroupName = 'scoping';\n } else {\n throw new Error('Unexpected parameter group: ' + parameterGroup);\n }\n\n argumentGroup = argumentParser.addArgumentGroup({\n title: `Optional ${parameterGroupName} arguments`\n });\n this._parameterGroupsByName.set(parameterGroup, argumentGroup);\n }\n } else {\n argumentGroup = argumentParser;\n }\n\n const argparseArgument: argparse.ArgumentOptions = (argumentGroup as IExtendedArgumentGroup).addArgument(\n names,\n argparseOptions\n );\n if (required && environmentVariable) {\n // Add some special-cased logic to handle required parameters with environment variables\n\n const originalPreParse: (() => void) | undefined = parameter._preParse?.bind(parameter);\n parameter._preParse = () => {\n originalPreParse?.();\n // Set the value as non-required before parsing. We'll validate it explicitly\n argparseArgument.required = false;\n };\n\n const originalPostParse: (() => void) | undefined = parameter._postParse?.bind(parameter);\n parameter._postParse = () => {\n // Reset the required value to make the usage text correct\n argparseArgument.required = true;\n originalPostParse?.();\n };\n\n function throwMissingParameterError(): never {\n argumentParser.error(`Argument \"${longName}\" is required`);\n }\n\n const originalValidateValue: (() => void) | undefined = parameter._validateValue?.bind(parameter);\n // For these values, we have to perform explicit validation because they're requested\n // as required, but we disabled argparse's required flag to allow the environment variable\n // to potentially fill the value.\n switch (kind) {\n case CommandLineParameterKind.Choice:\n case CommandLineParameterKind.Integer:\n case CommandLineParameterKind.String:\n parameter._validateValue = function () {\n if (this.value === undefined || this.value === null) {\n throwMissingParameterError();\n }\n\n originalValidateValue?.();\n };\n break;\n case CommandLineParameterKind.ChoiceList:\n case CommandLineParameterKind.IntegerList:\n case CommandLineParameterKind.StringList:\n parameter._validateValue = function () {\n if (this.values.length === 0) {\n throwMissingParameterError();\n }\n\n originalValidateValue?.();\n };\n break;\n }\n }\n\n if (undocumentedSynonyms?.length) {\n argumentGroup.addArgument(undocumentedSynonyms, {\n ...argparseOptions,\n help: argparse.Const.SUPPRESS\n });\n }\n\n // Register the parameter names so that we can detect ambiguous parameters\n for (const name of [...names, ...(undocumentedSynonyms || [])]) {\n this._registeredParameterParserKeysByName.set(name, parserKey!);\n }\n }\n\n protected _registerAmbiguousParameter(name: string, parserKey: string): void {\n this._getArgumentParser().addArgument(name, {\n dest: parserKey,\n // We don't know if this argument takes parameters or not, so we need to accept any number of args\n nargs: '*',\n // Ensure that the argument is not shown in the help text, since these parameters are only included\n // to inform the user that ambiguous parameters are present\n help: argparse.Const.SUPPRESS\n });\n }\n\n private _generateKey(): string {\n return 'key_' + (CommandLineParameterProvider._keyCounter++).toString();\n }\n\n private _getParameter<T extends CommandLineParameterBase>(\n parameterLongName: string,\n expectedKind: CommandLineParameterKind,\n parameterScope?: string\n ): T {\n // Support the parameter long name being prefixed with the scope\n const { scope, longName } = this.parseScopedLongName(parameterLongName);\n parameterLongName = longName;\n parameterScope = scope || parameterScope;\n\n const parameters: CommandLineParameterBase[] | undefined =\n this._parametersByLongName.get(parameterLongName);\n if (!parameters) {\n throw new Error(`The parameter \"${parameterLongName}\" is not defined`);\n }\n\n let parameter: CommandLineParameterBase | undefined = parameters.find(\n (p) => p.parameterScope === parameterScope\n );\n if (!parameter) {\n if (parameterScope !== undefined) {\n throw new Error(\n `The parameter \"${parameterLongName}\" with scope \"${parameterScope}\" is not defined.`\n );\n }\n if (parameters.length !== 1) {\n throw new Error(`The parameter \"${parameterLongName}\" is ambiguous. You must specify a scope.`);\n }\n parameter = parameters[0];\n }\n\n if (parameter.kind !== expectedKind) {\n throw new Error(\n `The parameter \"${parameterLongName}\" is of type \"${CommandLineParameterKind[parameter.kind]}\"` +\n ` whereas the caller was expecting \"${CommandLineParameterKind[expectedKind]}\".`\n );\n }\n\n return parameter as T;\n }\n\n private _throwParserExitError(\n parserOptions: ICommandLineParserOptions,\n data: ICommandLineParserData,\n errorCode: number,\n message: string\n ): never {\n // Write out the usage text to make it easier for the user to find the correct parameter name\n const targetActionName: string = data.aliasAction || data.action || '';\n const errorPrefix: string =\n `Error: ${parserOptions.toolFilename}` +\n // Handle aliases, actions, and actionless parameter providers\n `${targetActionName ? ' ' : ''}${targetActionName}: error: `;\n\n // eslint-disable-next-line no-console\n console.log(this.renderUsageText());\n throw new CommandLineParserExitError(errorCode, `${errorPrefix}${message.trimStart().trimEnd()}\\n`);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CommandLineParameterProvider.js","sourceRoot":"","sources":["../../src/providers/CommandLineParameterProvider.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,mDAAqC;AAarC,2DAKmC;AACnC,yFAGkD;AAClD,iGAA8F;AAC9F,2FAGmD;AACnD,mGAAgG;AAChG,qFAAkF;AAClF,yFAGkD;AAClD,iGAA8F;AAC9F,6EAA0E;AAC1E,4CAAuD;AACvD,6EAA0E;AA6C1E,MAAM,gBAAgB,GAAW,OAAO,CAAC;AACzC,MAAM,oBAAoB,GAAW,UAAU,CAAC;AAChD,MAAM,gCAAgC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C,kBAAkB,iBAAiB,2CAA2C,CAAC,CAAC;YAClG,CAAC;YACD,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC;QAED,IAAI,SAAS,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CACb,kBAAkB,iBAAiB,iBAAiB,sCAAwB,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG;gBAC7F,sCAAsC,sCAAwB,CAAC,YAAY,CAAC,IAAI,CACnF,CAAC;QACJ,CAAC;QAED,OAAO,SAAc,CAAC;IACxB,CAAC;IAEO,qBAAqB,CAC3B,aAAwC,EACxC,IAA4B,EAC5B,SAAiB,EACjB,OAAe;QAEf,6FAA6F;QAC7F,MAAM,gBAAgB,GAAW,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QACvE,MAAM,WAAW,GACf,UAAU,aAAa,CAAC,YAAY,EAAE;YACtC,8DAA8D;YAC9D,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,gBAAgB,WAAW,CAAC;QAE/D,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC;QACpC,MAAM,IAAI,uDAA0B,CAAC,SAAS,EAAE,GAAG,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACtG,CAAC;;AAl6BH,oEAm6BC;AAl6BgB,wCAAW,GAAW,CAAC,CAAC","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 * as argparse from 'argparse';\n\nimport type {\n ICommandLineChoiceDefinition,\n ICommandLineChoiceListDefinition,\n ICommandLineIntegerDefinition,\n ICommandLineIntegerListDefinition,\n ICommandLineFlagDefinition,\n ICommandLineStringDefinition,\n ICommandLineStringListDefinition,\n ICommandLineRemainderDefinition\n} from '../parameters/CommandLineDefinition';\nimport type { ICommandLineParserOptions } from './CommandLineParser';\nimport {\n type CommandLineParameterBase,\n type CommandLineParameterWithArgument,\n CommandLineParameterKind,\n type CommandLineParameter\n} from '../parameters/BaseClasses';\nimport {\n CommandLineChoiceParameter,\n type IRequiredCommandLineChoiceParameter\n} from '../parameters/CommandLineChoiceParameter';\nimport { CommandLineChoiceListParameter } from '../parameters/CommandLineChoiceListParameter';\nimport {\n CommandLineIntegerParameter,\n type IRequiredCommandLineIntegerParameter\n} from '../parameters/CommandLineIntegerParameter';\nimport { CommandLineIntegerListParameter } from '../parameters/CommandLineIntegerListParameter';\nimport { CommandLineFlagParameter } from '../parameters/CommandLineFlagParameter';\nimport {\n CommandLineStringParameter,\n type IRequiredCommandLineStringParameter\n} from '../parameters/CommandLineStringParameter';\nimport { CommandLineStringListParameter } from '../parameters/CommandLineStringListParameter';\nimport { CommandLineRemainder } from '../parameters/CommandLineRemainder';\nimport { SCOPING_PARAMETER_GROUP } from '../Constants';\nimport { CommandLineParserExitError } from './CommandLineParserExitError';\n\n/**\n * The result containing the parsed parameter long name and scope. Returned when calling\n * {@link CommandLineParameterProvider.parseScopedLongName}.\n *\n * @public\n */\nexport interface IScopedLongNameParseResult {\n /**\n * The long name parsed from the scoped long name, e.g. \"--my-scope:my-parameter\" -\\> \"--my-parameter\"\n */\n longName: string;\n\n /**\n * The scope parsed from the scoped long name or undefined if no scope was found,\n * e.g. \"--my-scope:my-parameter\" -\\> \"my-scope\"\n */\n scope: string | undefined;\n}\n\n/**\n * An object containing the state of the\n *\n * @internal\n */\nexport interface IRegisterDefinedParametersState {\n /**\n * A set of all defined parameter names registered by parent {@link CommandLineParameterProvider}\n * objects.\n */\n parentParameterNames: Set<string>;\n}\n\n/**\n * This is the argparse result data object\n * @internal\n */\nexport interface ICommandLineParserData {\n action: string;\n aliasAction?: string;\n aliasDocumentation?: string;\n [key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n}\n\nconst SCOPE_GROUP_NAME: string = 'scope';\nconst LONG_NAME_GROUP_NAME: string = 'longName';\nconst POSSIBLY_SCOPED_LONG_NAME_REGEXP: RegExp =\n /^--((?<scope>[a-z0-9]+(-[a-z0-9]+)*):)?(?<longName>[a-z0-9]+((-[a-z0-9]+)+)?)$/;\n\ninterface IExtendedArgumentGroup extends argparse.ArgumentGroup {\n // The types are incorrect - this function returns the constructed argument\n // object, which looks like the argument options type.\n addArgument(nameOrFlags: string | string[], options: argparse.ArgumentOptions): argparse.ArgumentOptions;\n}\n\ninterface IExtendedArgumentParser extends argparse.ArgumentParser {\n // This function throws\n error(message: string): never;\n}\n\n/**\n * This is the common base class for CommandLineAction and CommandLineParser\n * that provides functionality for defining command-line parameters.\n *\n * @public\n */\nexport abstract class CommandLineParameterProvider {\n private static _keyCounter: number = 0;\n\n /** @internal */\n public readonly _ambiguousParameterParserKeysByName: Map<string, string>;\n /** @internal */\n protected readonly _registeredParameterParserKeysByName: Map<string, string>;\n\n private readonly _parameters: CommandLineParameter[];\n private readonly _parametersByLongName: Map<string, CommandLineParameter[]>;\n private readonly _parametersByShortName: Map<string, CommandLineParameter[]>;\n private readonly _parameterGroupsByName: Map<\n string | typeof SCOPING_PARAMETER_GROUP,\n argparse.ArgumentGroup\n >;\n private _parametersHaveBeenRegistered: boolean;\n private _parametersHaveBeenProcessed: boolean;\n private _remainder: CommandLineRemainder | undefined;\n\n /** @internal */\n // Third party code should not inherit subclasses or call this constructor\n public constructor() {\n this._parameters = [];\n this._parametersByLongName = new Map();\n this._parametersByShortName = new Map();\n this._parameterGroupsByName = new Map();\n this._ambiguousParameterParserKeysByName = new Map();\n this._registeredParameterParserKeysByName = new Map();\n this._parametersHaveBeenRegistered = false;\n this._parametersHaveBeenProcessed = false;\n }\n\n /**\n * Returns a collection of the parameters that were defined for this object.\n */\n public get parameters(): ReadonlyArray<CommandLineParameterBase> {\n return this._parameters;\n }\n\n /**\n * Informs the caller if the argparse data has been processed into parameters.\n */\n public get parametersProcessed(): boolean {\n return this._parametersHaveBeenProcessed;\n }\n\n /**\n * If {@link CommandLineParameterProvider.defineCommandLineRemainder} was called,\n * this object captures any remaining command line arguments after the recognized portion.\n */\n public get remainder(): CommandLineRemainder | undefined {\n return this._remainder;\n }\n\n /**\n * Defines a command-line parameter whose value must be a string from a fixed set of\n * allowable choices (similar to an enum).\n *\n * @remarks\n * Example of a choice parameter:\n * ```\n * example-tool --log-level warn\n * ```\n */\n public defineChoiceParameter<TChoice extends string = string>(\n definition: ICommandLineChoiceDefinition<TChoice> & {\n required: false | undefined;\n defaultValue: undefined;\n }\n ): CommandLineChoiceParameter<TChoice>;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineChoiceParameter:1)}\n */\n public defineChoiceParameter<TChoice extends string = string>(\n definition: ICommandLineChoiceDefinition<TChoice> & { required: true }\n ): IRequiredCommandLineChoiceParameter<TChoice>;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineChoiceParameter:1)}\n */\n public defineChoiceParameter<TChoice extends string = string>(\n definition: ICommandLineChoiceDefinition<TChoice> & { defaultValue: TChoice }\n ): IRequiredCommandLineChoiceParameter<TChoice>;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineChoiceParameter:1)}\n */\n public defineChoiceParameter<TChoice extends string = string>(\n definition: ICommandLineChoiceDefinition<TChoice>\n ): CommandLineChoiceParameter<TChoice>;\n public defineChoiceParameter<TChoice extends string = string>(\n definition: ICommandLineChoiceDefinition<TChoice>\n ): CommandLineChoiceParameter<TChoice> {\n const parameter: CommandLineChoiceParameter<TChoice> = new CommandLineChoiceParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Returns the CommandLineChoiceParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getChoiceParameter(parameterLongName: string, parameterScope?: string): CommandLineChoiceParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.Choice, parameterScope);\n }\n\n /**\n * Defines a command-line parameter whose value must be a string from a fixed set of\n * allowable choices (similar to an enum). The parameter can be specified multiple times to\n * build a list.\n *\n * @remarks\n * Example of a choice list parameter:\n * ```\n * example-tool --allow-color red --allow-color green\n * ```\n */\n public defineChoiceListParameter<TChoice extends string = string>(\n definition: ICommandLineChoiceListDefinition<TChoice>\n ): CommandLineChoiceListParameter<TChoice> {\n const parameter: CommandLineChoiceListParameter<TChoice> = new CommandLineChoiceListParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Returns the CommandLineChoiceListParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getChoiceListParameter(\n parameterLongName: string,\n parameterScope?: string\n ): CommandLineChoiceListParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.ChoiceList, parameterScope);\n }\n\n /**\n * Defines a command-line switch whose boolean value is true if the switch is provided,\n * and false otherwise.\n *\n * @remarks\n * Example usage of a flag parameter:\n * ```\n * example-tool --debug\n * ```\n */\n public defineFlagParameter(definition: ICommandLineFlagDefinition): CommandLineFlagParameter {\n const parameter: CommandLineFlagParameter = new CommandLineFlagParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Returns the CommandLineFlagParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getFlagParameter(parameterLongName: string, parameterScope?: string): CommandLineFlagParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.Flag, parameterScope);\n }\n\n /**\n * Defines a command-line parameter whose argument is an integer.\n *\n * @remarks\n * Example usage of an integer parameter:\n * ```\n * example-tool --max-attempts 5\n * ```\n */\n public defineIntegerParameter(\n definition: ICommandLineIntegerDefinition & { required: false | undefined; defaultValue: undefined }\n ): CommandLineIntegerParameter;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineIntegerParameter:1)}\n */\n public defineIntegerParameter(\n definition: ICommandLineIntegerDefinition & { required: true }\n ): IRequiredCommandLineIntegerParameter;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineIntegerParameter:1)}\n */\n public defineIntegerParameter(\n definition: ICommandLineIntegerDefinition & { defaultValue: number }\n ): IRequiredCommandLineIntegerParameter;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineIntegerParameter:1)}\n */\n public defineIntegerParameter(definition: ICommandLineIntegerDefinition): CommandLineIntegerParameter;\n public defineIntegerParameter(definition: ICommandLineIntegerDefinition): CommandLineIntegerParameter {\n const parameter: CommandLineIntegerParameter = new CommandLineIntegerParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Returns the CommandLineIntegerParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getIntegerParameter(\n parameterLongName: string,\n parameterScope?: string\n ): CommandLineIntegerParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.Integer, parameterScope);\n }\n\n /**\n * Defines a command-line parameter whose argument is an integer. The parameter can be specified\n * multiple times to build a list.\n *\n * @remarks\n * Example usage of an integer list parameter:\n * ```\n * example-tool --avoid 4 --avoid 13\n * ```\n */\n public defineIntegerListParameter(\n definition: ICommandLineIntegerListDefinition\n ): CommandLineIntegerListParameter {\n const parameter: CommandLineIntegerListParameter = new CommandLineIntegerListParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Returns the CommandLineIntegerParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getIntegerListParameter(\n parameterLongName: string,\n parameterScope?: string\n ): CommandLineIntegerListParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.IntegerList, parameterScope);\n }\n\n /**\n * Defines a command-line parameter whose argument is a single text string.\n *\n * @remarks\n * Example usage of a string parameter:\n * ```\n * example-tool --message \"Hello, world!\"\n * ```\n */\n public defineStringParameter(\n definition: ICommandLineStringDefinition & { required: false | undefined; defaultValue: undefined }\n ): CommandLineStringParameter;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineStringParameter:1)}\n */\n public defineStringParameter(\n definition: ICommandLineStringDefinition & { required: true }\n ): IRequiredCommandLineStringParameter;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineStringParameter:1)}\n */\n public defineStringParameter(\n definition: ICommandLineStringDefinition & { defaultValue: string }\n ): IRequiredCommandLineStringParameter;\n /**\n * {@inheritdoc CommandLineParameterProvider.(defineStringParameter:1)}\n */\n public defineStringParameter(definition: ICommandLineStringDefinition): CommandLineStringParameter;\n public defineStringParameter(definition: ICommandLineStringDefinition): CommandLineStringParameter {\n const parameter: CommandLineStringParameter = new CommandLineStringParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Returns the CommandLineStringParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getStringParameter(parameterLongName: string, parameterScope?: string): CommandLineStringParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.String, parameterScope);\n }\n\n /**\n * Defines a command-line parameter whose argument is a single text string. The parameter can be\n * specified multiple times to build a list.\n *\n * @remarks\n * Example usage of a string list parameter:\n * ```\n * example-tool --add file1.txt --add file2.txt --add file3.txt\n * ```\n */\n public defineStringListParameter(\n definition: ICommandLineStringListDefinition\n ): CommandLineStringListParameter {\n const parameter: CommandLineStringListParameter = new CommandLineStringListParameter(definition);\n this._defineParameter(parameter);\n return parameter;\n }\n\n /**\n * Defines a rule that captures any remaining command line arguments after the recognized portion.\n *\n * @remarks\n * This feature is useful for commands that pass their arguments along to an external tool, relying on\n * that tool to perform validation. (It could also be used to parse parameters without any validation\n * or documentation, but that is not recommended.)\n *\n * Example of capturing the remainder after an optional flag parameter.\n * ```\n * example-tool --my-flag this is the remainder\n * ```\n *\n * In the \"--help\" documentation, the remainder rule will be represented as \"...\".\n */\n public defineCommandLineRemainder(definition: ICommandLineRemainderDefinition): CommandLineRemainder {\n if (this._remainder) {\n throw new Error('defineRemainingArguments() has already been called for this provider');\n }\n this._remainder = new CommandLineRemainder(definition);\n return this._remainder;\n }\n\n /**\n * Returns the CommandLineStringListParameter with the specified long name.\n * @remarks\n * This method throws an exception if the parameter is not defined.\n */\n public getStringListParameter(\n parameterLongName: string,\n parameterScope?: string\n ): CommandLineStringListParameter {\n return this._getParameter(parameterLongName, CommandLineParameterKind.StringList, parameterScope);\n }\n\n /**\n * Generates the command-line help text.\n */\n public renderHelpText(): string {\n const initialState: IRegisterDefinedParametersState = {\n parentParameterNames: new Set()\n };\n this._registerDefinedParameters(initialState);\n return this._getArgumentParser().formatHelp();\n }\n\n /**\n * Generates the command-line usage text.\n */\n public renderUsageText(): string {\n const initialState: IRegisterDefinedParametersState = {\n parentParameterNames: new Set()\n };\n this._registerDefinedParameters(initialState);\n return this._getArgumentParser().formatUsage();\n }\n\n /**\n * Returns a object which maps the long name of each parameter in this.parameters\n * to the stringified form of its value. This is useful for logging telemetry, but\n * it is not the proper way of accessing parameters or their values.\n */\n public getParameterStringMap(): Record<string, string> {\n const parameterMap: Record<string, string> = {};\n for (const parameter of this.parameters) {\n const parameterName: string = parameter.scopedLongName || parameter.longName;\n switch (parameter.kind) {\n case CommandLineParameterKind.Flag:\n case CommandLineParameterKind.Choice:\n case CommandLineParameterKind.String:\n case CommandLineParameterKind.Integer:\n parameterMap[parameterName] = JSON.stringify(\n (\n parameter as\n | CommandLineFlagParameter\n | CommandLineIntegerParameter\n | CommandLineChoiceParameter\n | CommandLineStringParameter\n ).value\n );\n break;\n case CommandLineParameterKind.StringList:\n case CommandLineParameterKind.IntegerList:\n case CommandLineParameterKind.ChoiceList:\n const arrayValue: ReadonlyArray<string | number> | undefined = (\n parameter as\n | CommandLineIntegerListParameter\n | CommandLineStringListParameter\n | CommandLineChoiceListParameter\n ).values;\n parameterMap[parameterName] = arrayValue ? arrayValue.join(',') : '';\n break;\n }\n }\n return parameterMap;\n }\n\n /**\n * Returns an object with the parsed scope (if present) and the long name of the parameter.\n */\n public parseScopedLongName(scopedLongName: string): IScopedLongNameParseResult {\n const result: RegExpExecArray | null = POSSIBLY_SCOPED_LONG_NAME_REGEXP.exec(scopedLongName);\n if (!result || !result.groups) {\n throw new Error(`The parameter long name \"${scopedLongName}\" is not valid.`);\n }\n return {\n longName: `--${result.groups[LONG_NAME_GROUP_NAME]}`,\n scope: result.groups[SCOPE_GROUP_NAME]\n };\n }\n\n /** @internal */\n public _registerDefinedParameters(state: IRegisterDefinedParametersState): void {\n if (this._parametersHaveBeenRegistered) {\n // We prevent new parameters from being defined after the first call to _registerDefinedParameters,\n // so we can already ensure that all parameters were registered.\n return;\n }\n\n // First, loop through all parameters with short names. If there are any duplicates, disable the short names\n // since we can't prefix scopes to short names in order to deduplicate them. The duplicate short names will\n // be reported as errors if the user attempts to use them.\n const parametersWithDuplicateShortNames: Set<CommandLineParameterBase> = new Set();\n for (const [shortName, shortNameParameters] of this._parametersByShortName.entries()) {\n if (shortNameParameters.length > 1) {\n for (const parameter of shortNameParameters) {\n this._defineAmbiguousParameter(shortName);\n parametersWithDuplicateShortNames.add(parameter);\n }\n }\n }\n\n // Then, loop through all parameters and register them. If there are any duplicates, ensure that they have\n // provided a scope and register them with the scope. The duplicate long names will be reported as an error\n // if the user attempts to use them.\n for (const longNameParameters of this._parametersByLongName.values()) {\n const useScopedLongName: boolean = longNameParameters.length > 1;\n for (const parameter of longNameParameters) {\n if (useScopedLongName) {\n if (!parameter.parameterScope) {\n throw new Error(\n `The parameter \"${parameter.longName}\" is defined multiple times with the same long name. ` +\n 'Parameters with the same long name must define a scope.'\n );\n }\n this._defineAmbiguousParameter(parameter.longName);\n }\n\n const ignoreShortName: boolean = parametersWithDuplicateShortNames.has(parameter);\n this._registerParameter(parameter, useScopedLongName, ignoreShortName);\n }\n }\n\n // Register the existing parameters as ambiguous parameters. These are generally provided by the\n // parent action.\n const { parentParameterNames } = state;\n for (const parentParameterName of parentParameterNames) {\n this._defineAmbiguousParameter(parentParameterName);\n }\n\n // We also need to loop through the defined ambiguous parameters and register them. These will be reported\n // as errors if the user attempts to use them.\n for (const [ambiguousParameterName, parserKey] of this._ambiguousParameterParserKeysByName) {\n // Only register the ambiguous parameter if it hasn't already been registered. We will still handle these\n // already-registered parameters as ambiguous, but by avoiding registering again, we will defer errors\n // until the user actually attempts to use the parameter.\n if (!this._registeredParameterParserKeysByName.has(ambiguousParameterName)) {\n this._registerAmbiguousParameter(ambiguousParameterName, parserKey);\n }\n }\n\n // Need to add the remainder parameter last\n if (this._remainder) {\n const argparseOptions: argparse.ArgumentOptions = {\n help: this._remainder.description,\n nargs: argparse.Const.REMAINDER,\n metavar: '\"...\"'\n };\n\n this._getArgumentParser().addArgument(argparse.Const.REMAINDER, argparseOptions);\n }\n\n this._parametersHaveBeenRegistered = true;\n }\n\n /**\n * @deprecated - Define parameters in the constructor\n */\n protected onDefineParameters?(): void;\n\n /**\n * Retrieves the argparse object.\n * @internal\n */\n protected abstract _getArgumentParser(): argparse.ArgumentParser;\n\n /**\n * This is called internally by {@link CommandLineParser.executeAsync}\n * @internal\n */\n public _preParse(): void {\n for (const parameter of this._parameters) {\n parameter._preParse?.();\n }\n }\n\n /**\n * This is called internally by {@link CommandLineParser.executeAsync} before `printUsage` is called\n * @internal\n */\n public _postParse(): void {\n for (const parameter of this._parameters) {\n parameter._postParse?.();\n }\n }\n\n /**\n * This is called internally by {@link CommandLineParser.executeAsync}\n * @internal\n */\n public _processParsedData(parserOptions: ICommandLineParserOptions, data: ICommandLineParserData): void {\n if (!this._parametersHaveBeenRegistered) {\n throw new Error('Parameters have not been registered');\n }\n\n if (this._parametersHaveBeenProcessed) {\n throw new Error('Command Line Parser Data was already processed');\n }\n\n // Search for any ambiguous parameters and throw an error if any are found\n for (const [parameterName, parserKey] of this._ambiguousParameterParserKeysByName) {\n if (data[parserKey]) {\n // When the parser key matches the actually registered parameter, we know that this is an ambiguous\n // parameter sourced from the parent action or tool\n if (this._registeredParameterParserKeysByName.get(parameterName) === parserKey) {\n this._throwParserExitError(parserOptions, data, 1, `Ambiguous option: \"${parameterName}\".`);\n }\n\n // Determine if the ambiguous parameter is a short name or a long name, since the process of finding\n // the non-ambiguous name is different for each.\n const duplicateShortNameParameters: CommandLineParameterBase[] | undefined =\n this._parametersByShortName.get(parameterName);\n if (duplicateShortNameParameters) {\n // We also need to make sure we get the non-ambiguous long name for the parameter, since it is\n // possible for that the long name is ambiguous as well.\n const nonAmbiguousLongNames: string[] = [];\n for (const parameter of duplicateShortNameParameters) {\n const matchingLongNameParameters: CommandLineParameterBase[] | undefined =\n this._parametersByLongName.get(parameter.longName);\n if (!matchingLongNameParameters?.length) {\n // This should never happen\n throw new Error(\n `Unable to find long name parameters for ambiguous short name parameter \"${parameterName}\".`\n );\n }\n // If there is more than one matching long name parameter, then we know that we need to use the\n // scoped long name for the parameter. The scoped long name should always be provided.\n if (matchingLongNameParameters.length > 1) {\n if (!parameter.scopedLongName) {\n // This should never happen\n throw new Error(\n `Unable to find scoped long name for ambiguous short name parameter \"${parameterName}\".`\n );\n }\n nonAmbiguousLongNames.push(parameter.scopedLongName);\n } else {\n nonAmbiguousLongNames.push(parameter.longName);\n }\n }\n\n // Throw an error including the non-ambiguous long names for the parameters that have the ambiguous\n // short name, ex.\n // Error: Ambiguous option \"-p\" could match \"--param1\", \"--param2\"\n this._throwParserExitError(\n parserOptions,\n data,\n 1,\n `Ambiguous option: \"${parameterName}\" could match ${nonAmbiguousLongNames.join(', ')}.`\n );\n }\n\n const duplicateLongNameParameters: CommandLineParameterBase[] | undefined =\n this._parametersByLongName.get(parameterName);\n if (duplicateLongNameParameters) {\n const nonAmbiguousLongNames: string[] = duplicateLongNameParameters.map(\n (p: CommandLineParameterBase) => {\n // The scoped long name should always be provided\n if (!p.scopedLongName) {\n // This should never happen\n throw new Error(\n `Unable to find scoped long name for ambiguous long name parameter \"${parameterName}\".`\n );\n }\n return p.scopedLongName;\n }\n );\n\n // Throw an error including the non-ambiguous scoped long names for the parameters that have the\n // ambiguous long name, ex.\n // Error: Ambiguous option: \"--param\" could match --scope1:param, --scope2:param\n this._throwParserExitError(\n parserOptions,\n data,\n 1,\n `Ambiguous option: \"${parameterName}\" could match ${nonAmbiguousLongNames.join(', ')}.`\n );\n }\n\n // This shouldn't happen, but we also shouldn't allow the user to use the ambiguous parameter\n this._throwParserExitError(parserOptions, data, 1, `Ambiguous option: \"${parameterName}\".`);\n }\n }\n\n // Fill in the values for the parameters\n for (const parameter of this._parameters) {\n const value: unknown = data[parameter._parserKey!];\n parameter._setValue(value);\n parameter._validateValue?.();\n }\n\n if (this.remainder) {\n this.remainder._setValue(data[argparse.Const.REMAINDER]);\n }\n\n this._parametersHaveBeenProcessed = true;\n }\n\n /** @internal */\n protected _defineParameter(parameter: CommandLineParameter): void {\n if (this._parametersHaveBeenRegistered) {\n throw new Error('Parameters have already been registered for this provider');\n }\n\n // Generate and set the parser key at definition time\n parameter._parserKey = this._generateKey();\n\n this._parameters.push(parameter);\n\n // Collect all parameters with the same long name. We will perform conflict resolution at registration.\n let longNameParameters: CommandLineParameter[] | undefined = this._parametersByLongName.get(\n parameter.longName\n );\n if (!longNameParameters) {\n longNameParameters = [];\n this._parametersByLongName.set(parameter.longName, longNameParameters);\n }\n longNameParameters.push(parameter);\n\n // Collect all parameters with the same short name. We will perform conflict resolution at registration.\n if (parameter.shortName) {\n let shortNameParameters: CommandLineParameter[] | undefined = this._parametersByShortName.get(\n parameter.shortName\n );\n if (!shortNameParameters) {\n shortNameParameters = [];\n this._parametersByShortName.set(parameter.shortName, shortNameParameters);\n }\n shortNameParameters.push(parameter);\n }\n }\n\n /** @internal */\n protected _defineAmbiguousParameter(name: string): string {\n if (this._parametersHaveBeenRegistered) {\n throw new Error('Parameters have already been registered for this provider');\n }\n\n // Only generate a new parser key if the ambiguous parameter hasn't been defined yet,\n // either as an existing parameter or as another ambiguous parameter\n let existingParserKey: string | undefined =\n this._registeredParameterParserKeysByName.get(name) ||\n this._ambiguousParameterParserKeysByName.get(name);\n if (!existingParserKey) {\n existingParserKey = this._generateKey();\n }\n\n this._ambiguousParameterParserKeysByName.set(name, existingParserKey);\n return existingParserKey;\n }\n\n /** @internal */\n protected _registerParameter(\n parameter: CommandLineParameter,\n useScopedLongName: boolean,\n ignoreShortName: boolean\n ): void {\n const {\n shortName,\n longName,\n scopedLongName,\n description,\n kind,\n required,\n environmentVariable,\n parameterGroup,\n undocumentedSynonyms,\n _parserKey: parserKey\n } = parameter;\n\n const names: string[] = [];\n if (shortName && !ignoreShortName) {\n names.push(shortName);\n }\n\n // Use the original long name unless otherwise requested\n if (!useScopedLongName) {\n names.push(longName);\n }\n\n // Add the scoped long name if it exists\n if (scopedLongName) {\n names.push(scopedLongName);\n }\n\n let finalDescription: string = description;\n\n const supplementaryNotes: string[] = [];\n parameter._getSupplementaryNotes(supplementaryNotes);\n if (supplementaryNotes.length > 0) {\n // If they left the period off the end of their sentence, then add one.\n if (finalDescription.match(/[a-z0-9]\"?\\s*$/i)) {\n finalDescription = finalDescription.trimEnd() + '.';\n }\n // Append the supplementary text\n finalDescription += ' ' + supplementaryNotes.join(' ');\n }\n\n let choices: string[] | undefined;\n let action: string | undefined;\n let type: string | undefined;\n switch (kind) {\n case CommandLineParameterKind.Choice: {\n choices = parameter.alternatives as string[];\n break;\n }\n case CommandLineParameterKind.ChoiceList: {\n choices = parameter.alternatives as string[];\n action = 'append';\n break;\n }\n case CommandLineParameterKind.Flag:\n action = 'storeTrue';\n break;\n case CommandLineParameterKind.Integer:\n type = 'int';\n break;\n case CommandLineParameterKind.IntegerList:\n type = 'int';\n action = 'append';\n break;\n case CommandLineParameterKind.String:\n break;\n case CommandLineParameterKind.StringList:\n action = 'append';\n break;\n }\n\n // NOTE: Our \"environmentVariable\" feature takes precedence over argparse's \"defaultValue\",\n // so we have to reimplement that feature.\n const argparseOptions: argparse.ArgumentOptions = {\n help: finalDescription,\n dest: parserKey,\n metavar: (parameter as CommandLineParameterWithArgument).argumentName,\n required,\n choices,\n action,\n type\n };\n\n const argumentParser: IExtendedArgumentParser = this._getArgumentParser() as IExtendedArgumentParser;\n let argumentGroup: argparse.ArgumentGroup | undefined;\n if (parameterGroup) {\n argumentGroup = this._parameterGroupsByName.get(parameterGroup);\n if (!argumentGroup) {\n let parameterGroupName: string;\n if (typeof parameterGroup === 'string') {\n parameterGroupName = parameterGroup;\n } else if (parameterGroup === SCOPING_PARAMETER_GROUP) {\n parameterGroupName = 'scoping';\n } else {\n throw new Error('Unexpected parameter group: ' + parameterGroup);\n }\n\n argumentGroup = argumentParser.addArgumentGroup({\n title: `Optional ${parameterGroupName} arguments`\n });\n this._parameterGroupsByName.set(parameterGroup, argumentGroup);\n }\n } else {\n argumentGroup = argumentParser;\n }\n\n const argparseArgument: argparse.ArgumentOptions = (argumentGroup as IExtendedArgumentGroup).addArgument(\n names,\n argparseOptions\n );\n if (required && environmentVariable) {\n // Add some special-cased logic to handle required parameters with environment variables\n\n const originalPreParse: (() => void) | undefined = parameter._preParse?.bind(parameter);\n parameter._preParse = () => {\n originalPreParse?.();\n // Set the value as non-required before parsing. We'll validate it explicitly\n argparseArgument.required = false;\n };\n\n const originalPostParse: (() => void) | undefined = parameter._postParse?.bind(parameter);\n parameter._postParse = () => {\n // Reset the required value to make the usage text correct\n argparseArgument.required = true;\n originalPostParse?.();\n };\n\n function throwMissingParameterError(): never {\n argumentParser.error(`Argument \"${longName}\" is required`);\n }\n\n const originalValidateValue: (() => void) | undefined = parameter._validateValue?.bind(parameter);\n // For these values, we have to perform explicit validation because they're requested\n // as required, but we disabled argparse's required flag to allow the environment variable\n // to potentially fill the value.\n switch (kind) {\n case CommandLineParameterKind.Choice:\n case CommandLineParameterKind.Integer:\n case CommandLineParameterKind.String:\n parameter._validateValue = function () {\n if (this.value === undefined || this.value === null) {\n throwMissingParameterError();\n }\n\n originalValidateValue?.();\n };\n break;\n case CommandLineParameterKind.ChoiceList:\n case CommandLineParameterKind.IntegerList:\n case CommandLineParameterKind.StringList:\n parameter._validateValue = function () {\n if (this.values.length === 0) {\n throwMissingParameterError();\n }\n\n originalValidateValue?.();\n };\n break;\n }\n }\n\n if (undocumentedSynonyms?.length) {\n argumentGroup.addArgument(undocumentedSynonyms, {\n ...argparseOptions,\n help: argparse.Const.SUPPRESS\n });\n }\n\n // Register the parameter names so that we can detect ambiguous parameters\n for (const name of [...names, ...(undocumentedSynonyms || [])]) {\n this._registeredParameterParserKeysByName.set(name, parserKey!);\n }\n }\n\n protected _registerAmbiguousParameter(name: string, parserKey: string): void {\n this._getArgumentParser().addArgument(name, {\n dest: parserKey,\n // We don't know if this argument takes parameters or not, so we need to accept any number of args\n nargs: '*',\n // Ensure that the argument is not shown in the help text, since these parameters are only included\n // to inform the user that ambiguous parameters are present\n help: argparse.Const.SUPPRESS\n });\n }\n\n private _generateKey(): string {\n return 'key_' + (CommandLineParameterProvider._keyCounter++).toString();\n }\n\n private _getParameter<T extends CommandLineParameterBase>(\n parameterLongName: string,\n expectedKind: CommandLineParameterKind,\n parameterScope?: string\n ): T {\n // Support the parameter long name being prefixed with the scope\n const { scope, longName } = this.parseScopedLongName(parameterLongName);\n parameterLongName = longName;\n parameterScope = scope || parameterScope;\n\n const parameters: CommandLineParameterBase[] | undefined =\n this._parametersByLongName.get(parameterLongName);\n if (!parameters) {\n throw new Error(`The parameter \"${parameterLongName}\" is not defined`);\n }\n\n let parameter: CommandLineParameterBase | undefined = parameters.find(\n (p) => p.parameterScope === parameterScope\n );\n if (!parameter) {\n if (parameterScope !== undefined) {\n throw new Error(\n `The parameter \"${parameterLongName}\" with scope \"${parameterScope}\" is not defined.`\n );\n }\n if (parameters.length !== 1) {\n throw new Error(`The parameter \"${parameterLongName}\" is ambiguous. You must specify a scope.`);\n }\n parameter = parameters[0];\n }\n\n if (parameter.kind !== expectedKind) {\n throw new Error(\n `The parameter \"${parameterLongName}\" is of type \"${CommandLineParameterKind[parameter.kind]}\"` +\n ` whereas the caller was expecting \"${CommandLineParameterKind[expectedKind]}\".`\n );\n }\n\n return parameter as T;\n }\n\n private _throwParserExitError(\n parserOptions: ICommandLineParserOptions,\n data: ICommandLineParserData,\n errorCode: number,\n message: string\n ): never {\n // Write out the usage text to make it easier for the user to find the correct parameter name\n const targetActionName: string = data.aliasAction || data.action || '';\n const errorPrefix: string =\n `Error: ${parserOptions.toolFilename}` +\n // Handle aliases, actions, and actionless parameter providers\n `${targetActionName ? ' ' : ''}${targetActionName}: error: `;\n\n // eslint-disable-next-line no-console\n console.log(this.renderUsageText());\n throw new CommandLineParserExitError(errorCode, `${errorPrefix}${message.trimStart().trimEnd()}\\n`);\n }\n}\n"]}
|
|
@@ -55,10 +55,6 @@ export declare abstract class ScopedCommandLineAction extends CommandLineAction
|
|
|
55
55
|
_executeAsync(): Promise<void>;
|
|
56
56
|
/** @internal */
|
|
57
57
|
_registerDefinedParameters(state: IRegisterDefinedParametersState): void;
|
|
58
|
-
/**
|
|
59
|
-
* {@inheritdoc CommandLineParameterProvider.onDefineParameters}
|
|
60
|
-
*/
|
|
61
|
-
protected onDefineParameters(): void;
|
|
62
58
|
/**
|
|
63
59
|
* Retrieves the scoped CommandLineParser, which is populated after the ScopedCommandLineAction is executed.
|
|
64
60
|
* @internal
|
|
@@ -67,10 +63,7 @@ export declare abstract class ScopedCommandLineAction extends CommandLineAction
|
|
|
67
63
|
/** @internal */
|
|
68
64
|
protected _defineParameter(parameter: CommandLineParameter): void;
|
|
69
65
|
/**
|
|
70
|
-
*
|
|
71
|
-
* e.g. by calling defineFlagParameter(). At least one scoping parameter must be defined.
|
|
72
|
-
* Scoping parameters are defined by setting the parameterGroupName to
|
|
73
|
-
* ScopedCommandLineAction.ScopingParameterGroupName.
|
|
66
|
+
* @deprecated - Define parameters in the constructor
|
|
74
67
|
*/
|
|
75
68
|
protected onDefineUnscopedParameters?(): void;
|
|
76
69
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScopedCommandLineAction.d.ts","sourceRoot":"","sources":["../../src/providers/ScopedCommandLineAction.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,KAAK,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACx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8C;IAC9E,OAAO,CAAC,eAAe,CAA8C;IAErE;;;OAGG;IACH,gBAAuB,qBAAqB,EAAE,OAAO,uBAAuB,CAA2B;gBAEpF,OAAO,EAAE,yBAAyB;IAkBrD;;;;;OAKG;IACH,IAAW,UAAU,IAAI,aAAa,CAAC,wBAAwB,CAAC,CAM/D;IAED;;;OAGG;IACI,kBAAkB,CAAC,aAAa,EAAE,yBAAyB,EAAE,IAAI,EAAE,sBAAsB,GAAG,IAAI;IAyBvG;;;OAGG;IACU,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAuC3C,gBAAgB;IACT,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,IAAI;IAuB/E;;;OAGG;IACH,SAAS,CAAC,2BAA2B,IAAI,iBAAiB;IAO1D,gBAAgB;IAChB,SAAS,CAAC,gBAAgB,CAAC,SAAS,EAAE,oBAAoB,GAAG,IAAI;IAOjE;;OAEG;IACH,SAAS,CAAC,0BAA0B,CAAC,IAAI,IAAI;IAE7C;;;;;;;;OAQG;IACH,SAAS,CAAC,QAAQ,CAAC,wBAAwB,CAAC,uBAAuB,EAAE,4BAA4B,GAAG,IAAI;IAExG;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAC9C"}
|
|
@@ -75,9 +75,18 @@ class InternalScopedCommandLineParser extends CommandLineParser_1.CommandLinePar
|
|
|
75
75
|
*/
|
|
76
76
|
class ScopedCommandLineAction extends CommandLineAction_1.CommandLineAction {
|
|
77
77
|
constructor(options) {
|
|
78
|
+
var _a;
|
|
78
79
|
super(options);
|
|
79
80
|
this._options = options;
|
|
80
81
|
this._scopingParameters = [];
|
|
82
|
+
// Consume the remainder of the command-line, which will later be passed the scoped parser.
|
|
83
|
+
// This will also prevent developers from calling this.defineCommandLineRemainder(...) since
|
|
84
|
+
// we will have already defined it.
|
|
85
|
+
this.defineCommandLineRemainder({
|
|
86
|
+
description: 'Scoped parameters. Must be prefixed with "--", ex. "-- --scopedParameter ' +
|
|
87
|
+
'foo --scopedFlag". For more information on available scoped parameters, use "-- --help".'
|
|
88
|
+
});
|
|
89
|
+
(_a = this.onDefineUnscopedParameters) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
81
90
|
}
|
|
82
91
|
/**
|
|
83
92
|
* {@inheritDoc CommandLineParameterProvider.parameters}
|
|
@@ -149,6 +158,11 @@ class ScopedCommandLineAction extends CommandLineAction_1.CommandLineAction {
|
|
|
149
158
|
}
|
|
150
159
|
/** @internal */
|
|
151
160
|
_registerDefinedParameters(state) {
|
|
161
|
+
if (!this._scopingParameters.length) {
|
|
162
|
+
throw new Error('No scoping parameters defined. At least one scoping parameter must be defined. ' +
|
|
163
|
+
'Scoping parameters are defined by setting the parameterGroupName to ' +
|
|
164
|
+
'ScopedCommandLineAction.ScopingParameterGroupName.');
|
|
165
|
+
}
|
|
152
166
|
super._registerDefinedParameters(state);
|
|
153
167
|
const { parentParameterNames } = state;
|
|
154
168
|
const updatedParentParameterNames = new Set([
|
|
@@ -157,29 +171,6 @@ class ScopedCommandLineAction extends CommandLineAction_1.CommandLineAction {
|
|
|
157
171
|
]);
|
|
158
172
|
this._subparserState = Object.assign(Object.assign({}, state), { parentParameterNames: updatedParentParameterNames });
|
|
159
173
|
}
|
|
160
|
-
/**
|
|
161
|
-
* {@inheritdoc CommandLineParameterProvider.onDefineParameters}
|
|
162
|
-
*/
|
|
163
|
-
onDefineParameters() {
|
|
164
|
-
var _a;
|
|
165
|
-
(_a = this.onDefineUnscopedParameters) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
166
|
-
if (!this._scopingParameters.length) {
|
|
167
|
-
throw new Error('No scoping parameters defined. At least one scoping parameter must be defined. ' +
|
|
168
|
-
'Scoping parameters are defined by setting the parameterGroupName to ' +
|
|
169
|
-
'ScopedCommandLineAction.ScopingParameterGroupName.');
|
|
170
|
-
}
|
|
171
|
-
if (this.remainder) {
|
|
172
|
-
throw new Error('Unscoped remainder parameters are not allowed. Remainder parameters can only be defined on ' +
|
|
173
|
-
'the scoped parameter provider in onDefineScopedParameters().');
|
|
174
|
-
}
|
|
175
|
-
// Consume the remainder of the command-line, which will later be passed the scoped parser.
|
|
176
|
-
// This will also prevent developers from calling this.defineCommandLineRemainder(...) since
|
|
177
|
-
// we will have already defined it.
|
|
178
|
-
this.defineCommandLineRemainder({
|
|
179
|
-
description: 'Scoped parameters. Must be prefixed with "--", ex. "-- --scopedParameter ' +
|
|
180
|
-
'foo --scopedFlag". For more information on available scoped parameters, use "-- --help".'
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
174
|
/**
|
|
184
175
|
* Retrieves the scoped CommandLineParser, which is populated after the ScopedCommandLineAction is executed.
|
|
185
176
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScopedCommandLineAction.js","sourceRoot":"","sources":["../../src/providers/ScopedCommandLineAction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,4CAAuD;AACvD,2DAAwF;AACxF,2DAAwF;AACxF,6EAA0E;AAiB1E;;;GAGG;AACH,MAAM,+BAAgC,SAAQ,qCAAiB;IAI7D,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,YAAmB,OAAgD;QACjE,MAAM,EAAE,aAAa,EAAE,wBAAwB,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,GAC9F,OAAO,CAAC;QAEV,MAAM,WAAW,GAAW,GAAG,YAAY,IAAI,aAAa,CAAC,UAAU,EAAE,CAAC;QAC1E,6FAA6F;QAC7F,MAAM,qBAAqB,GAAW,GAAG,YAAY,IAAI,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,aAAa,CAAC,UAAU,EAAE,CAAC;QACnG,MAAM,WAAW,GAAa,EAAE,CAAC;QACjC,KAAK,MAAM,SAAS,IAAI,wBAAwB,EAAE,CAAC;YACjD,SAAS,CAAC,eAAe,CAAC,WA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AC;IACJ,CAAC;IAED;;OAEG;IACO,kBAAkB;;QAC1B,MAAA,IAAI,CAAC,0BAA0B,oDAAI,CAAC;QAEpC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CACb,iFAAiF;gBAC/E,sEAAsE;gBACtE,oDAAoD,CACvD,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CACb,6FAA6F;gBAC3F,8DAA8D,CACjE,CAAC;QACJ,CAAC;QAED,2FAA2F;QAC3F,4FAA4F;QAC5F,mCAAmC;QACnC,IAAI,CAAC,0BAA0B,CAAC;YAC9B,WAAW,EACT,4EAA4E;gBAC5E,2FAA2F;SAC9F,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACO,2BAA2B;QACnC,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;QAClG,CAAC;QACD,OAAO,IAAI,CAAC,wBAAwB,CAAC;IACvC,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,SAA+B;QACxD,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAClC,IAAI,SAAS,CAAC,cAAc,KAAK,uBAAuB,CAAC,qBAAqB,EAAE,CAAC;YAC/E,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;;AAzKH,0DAkMC;AA3LC;;;GAGG;AACoB,6CAAqB,GAAmC,mCAAuB,CAAC","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 { SCOPING_PARAMETER_GROUP } from '../Constants';\nimport { CommandLineAction, type ICommandLineActionOptions } from './CommandLineAction';\nimport { CommandLineParser, type ICommandLineParserOptions } from './CommandLineParser';\nimport { CommandLineParserExitError } from './CommandLineParserExitError';\nimport type { CommandLineParameter, CommandLineParameterBase } from '../parameters/BaseClasses';\nimport type {\n CommandLineParameterProvider,\n ICommandLineParserData,\n IRegisterDefinedParametersState\n} from './CommandLineParameterProvider';\n\ninterface IInternalScopedCommandLineParserOptions extends ICommandLineParserOptions {\n readonly actionOptions: ICommandLineActionOptions;\n readonly unscopedActionParameters: ReadonlyArray<CommandLineParameter>;\n readonly onDefineScopedParameters: (commandLineParameterProvider: CommandLineParameterProvider) => void;\n readonly aliasAction?: string;\n readonly aliasDocumentation?: string;\n readonly registerDefinedParametersState: IRegisterDefinedParametersState;\n}\n\n/**\n * A CommandLineParser used exclusively to parse the scoped command-line parameters\n * for a ScopedCommandLineAction.\n */\nclass InternalScopedCommandLineParser extends CommandLineParser {\n private _canExecute: boolean;\n private readonly _internalOptions: IInternalScopedCommandLineParserOptions;\n\n public get canExecute(): boolean {\n return this._canExecute;\n }\n\n public constructor(options: IInternalScopedCommandLineParserOptions) {\n const { actionOptions, unscopedActionParameters, toolFilename, aliasAction, aliasDocumentation } =\n options;\n\n const toolCommand: string = `${toolFilename} ${actionOptions.actionName}`;\n // When coming from an alias command, we want to show the alias command name in the help text\n const toolCommandForLogging: string = `${toolFilename} ${aliasAction ?? actionOptions.actionName}`;\n const scopingArgs: string[] = [];\n for (const parameter of unscopedActionParameters) {\n parameter.appendToArgList(scopingArgs);\n }\n const scope: string = scopingArgs.join(' ');\n\n // We can run the parser directly because we are not going to use it for any other actions,\n // so construct a special options object to make the \"--help\" text more useful.\n const scopedCommandLineParserOptions: ICommandLineParserOptions = {\n // Strip the scoping args if coming from an alias command, since they are not applicable\n // to the alias command itself\n toolFilename: `${toolCommandForLogging}${scope && !aliasAction ? ` ${scope} --` : ''}`,\n toolDescription: aliasDocumentation ?? actionOptions.documentation,\n toolEpilog: `For more information on available unscoped parameters, use \"${toolCommand} --help\"`,\n enableTabCompletionAction: false\n };\n\n super(scopedCommandLineParserOptions);\n this._canExecute = false;\n this._internalOptions = options;\n this._internalOptions.onDefineScopedParameters(this);\n }\n\n public _registerDefinedParameters(state: IRegisterDefinedParametersState): void {\n // Since we are in a separate parser, we need to register the parameters using the state\n // from the parent parser.\n super._registerDefinedParameters(this._internalOptions.registerDefinedParametersState);\n }\n\n protected async onExecute(): Promise<void> {\n // override\n // Only set if we made it this far, which may not be the case if an error occurred or\n // if '--help' was specified.\n this._canExecute = true;\n }\n}\n\n/**\n * Represents a sub-command that is part of the CommandLineParser command-line.\n * Applications should create subclasses of ScopedCommandLineAction corresponding to\n * each action that they want to expose.\n *\n * The action name should be comprised of lower case words separated by hyphens\n * or colons. The name should include an English verb (e.g. \"deploy\"). Use a\n * hyphen to separate words (e.g. \"upload-docs\"). A group of related commands\n * can be prefixed with a colon (e.g. \"docs:generate\", \"docs:deploy\",\n * \"docs:serve\", etc).\n *\n * Scoped commands allow for different parameters to be specified for different\n * provided scoping values. For example, the \"scoped-action --scope A\" command\n * may allow for different scoped arguments to be specified than the \"scoped-action\n * --scope B\" command.\n *\n * Scoped arguments are specified after the \"--\" pseudo-argument. For example,\n * \"scoped-action --scope A -- --scopedFoo --scopedBar\".\n *\n * @public\n */\nexport abstract class ScopedCommandLineAction extends CommandLineAction {\n private _options: ICommandLineActionOptions;\n private _scopingParameters: CommandLineParameter[];\n private _unscopedParserOptions: ICommandLineParserOptions | undefined;\n private _scopedCommandLineParser: InternalScopedCommandLineParser | undefined;\n private _subparserState: IRegisterDefinedParametersState | undefined;\n\n /**\n * The required group name to apply to all scoping parameters. At least one parameter\n * must be defined with this group name.\n */\n public static readonly ScopingParameterGroup: typeof SCOPING_PARAMETER_GROUP = SCOPING_PARAMETER_GROUP;\n\n public constructor(options: ICommandLineActionOptions) {\n super(options);\n\n this._options = options;\n this._scopingParameters = [];\n }\n\n /**\n * {@inheritDoc CommandLineParameterProvider.parameters}\n *\n * @internalremarks\n * TODO: Replace this type with `CommandLineParameter` in the next major bump.\n */\n public get parameters(): ReadonlyArray<CommandLineParameterBase> {\n if (this._scopedCommandLineParser) {\n return [...super.parameters, ...this._scopedCommandLineParser.parameters];\n } else {\n return super.parameters;\n }\n }\n\n /**\n * {@inheritdoc CommandLineParameterProvider._processParsedData}\n * @internal\n */\n public _processParsedData(parserOptions: ICommandLineParserOptions, data: ICommandLineParserData): void {\n // override\n super._processParsedData(parserOptions, data);\n\n // This should never happen because the super method should throw if parameters haven't been registered,\n // but guard against this just in-case.\n if (this._subparserState === undefined) {\n throw new Error('Parameters have not been registered');\n }\n\n this._unscopedParserOptions = parserOptions;\n\n // Generate the scoped parser using the parent parser information. We can only create this after we\n // have parsed the data, since the parameter values are used during construction.\n this._scopedCommandLineParser = new InternalScopedCommandLineParser({\n ...parserOptions,\n actionOptions: this._options,\n aliasAction: data.aliasAction,\n aliasDocumentation: data.aliasDocumentation,\n unscopedActionParameters: this.parameters as CommandLineParameter[],\n registerDefinedParametersState: this._subparserState,\n onDefineScopedParameters: this.onDefineScopedParameters.bind(this)\n });\n }\n\n /**\n * {@inheritdoc CommandLineAction._executeAsync}\n * @internal\n */\n public async _executeAsync(): Promise<void> {\n // override\n if (!this._unscopedParserOptions || !this._scopedCommandLineParser) {\n throw new Error('The CommandLineAction parameters must be processed before execution.');\n }\n if (!this.remainder) {\n throw new Error('CommandLineAction.onDefineParameters must be called before execution.');\n }\n\n // The '--' argument is required to separate the action parameters from the scoped parameters,\n // so it needs to be trimmed. If remainder values are provided but no '--' is found, then throw.\n const scopedArgs: string[] = [];\n if (this.remainder.values.length) {\n if (this.remainder.values[0] !== '--') {\n throw new CommandLineParserExitError(\n // argparse sets exit code 2 for invalid arguments\n 2,\n // model the message off of the built-in \"unrecognized arguments\" message\n `${this.renderUsageText()}\\n${this._unscopedParserOptions.toolFilename} ${this.actionName}: ` +\n `error: Unrecognized arguments: ${this.remainder.values[0]}.\\n`\n );\n }\n for (const scopedArg of this.remainder.values.slice(1)) {\n scopedArgs.push(scopedArg);\n }\n }\n\n // Call the scoped parser using only the scoped args to handle parsing\n await this._scopedCommandLineParser.executeWithoutErrorHandlingAsync(scopedArgs);\n\n // Only call execute if the parser reached the execute stage. This may not be true if\n // the parser exited early due to a specified '--help' parameter.\n if (this._scopedCommandLineParser.canExecute) {\n await super._executeAsync();\n }\n\n return;\n }\n\n /** @internal */\n public _registerDefinedParameters(state: IRegisterDefinedParametersState): void {\n super._registerDefinedParameters(state);\n\n const { parentParameterNames } = state;\n const updatedParentParameterNames: Set<string> = new Set([\n ...parentParameterNames,\n ...this._registeredParameterParserKeysByName.keys()\n ]);\n\n this._subparserState = {\n ...state,\n parentParameterNames: updatedParentParameterNames\n };\n }\n\n /**\n * {@inheritdoc CommandLineParameterProvider.onDefineParameters}\n */\n protected onDefineParameters(): void {\n this.onDefineUnscopedParameters?.();\n\n if (!this._scopingParameters.length) {\n throw new Error(\n 'No scoping parameters defined. At least one scoping parameter must be defined. ' +\n 'Scoping parameters are defined by setting the parameterGroupName to ' +\n 'ScopedCommandLineAction.ScopingParameterGroupName.'\n );\n }\n if (this.remainder) {\n throw new Error(\n 'Unscoped remainder parameters are not allowed. Remainder parameters can only be defined on ' +\n 'the scoped parameter provider in onDefineScopedParameters().'\n );\n }\n\n // Consume the remainder of the command-line, which will later be passed the scoped parser.\n // This will also prevent developers from calling this.defineCommandLineRemainder(...) since\n // we will have already defined it.\n this.defineCommandLineRemainder({\n description:\n 'Scoped parameters. Must be prefixed with \"--\", ex. \"-- --scopedParameter ' +\n 'foo --scopedFlag\". For more information on available scoped parameters, use \"-- --help\".'\n });\n }\n\n /**\n * Retrieves the scoped CommandLineParser, which is populated after the ScopedCommandLineAction is executed.\n * @internal\n */\n protected _getScopedCommandLineParser(): CommandLineParser {\n if (!this._scopedCommandLineParser) {\n throw new Error('The scoped CommandLineParser is only populated after the action is executed.');\n }\n return this._scopedCommandLineParser;\n }\n\n /** @internal */\n protected _defineParameter(parameter: CommandLineParameter): void {\n super._defineParameter(parameter);\n if (parameter.parameterGroup === ScopedCommandLineAction.ScopingParameterGroup) {\n this._scopingParameters.push(parameter);\n }\n }\n\n /**\n * The child class should implement this hook to define its unscoped command-line parameters,\n * e.g. by calling defineFlagParameter(). At least one scoping parameter must be defined.\n * Scoping parameters are defined by setting the parameterGroupName to\n * ScopedCommandLineAction.ScopingParameterGroupName.\n */\n protected onDefineUnscopedParameters?(): void;\n\n /**\n * The child class should implement this hook to define its scoped command-line\n * parameters, e.g. by calling scopedParameterProvider.defineFlagParameter(). These\n * parameters will only be available if the action is invoked with a scope.\n *\n * @remarks\n * onDefineScopedParameters is called after the unscoped parameters have been parsed.\n * The values they provide can be used to vary the defined scope parameters.\n */\n protected abstract onDefineScopedParameters(scopedParameterProvider: CommandLineParameterProvider): void;\n\n /**\n * {@inheritDoc CommandLineAction.onExecute}\n */\n protected abstract onExecute(): Promise<void>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ScopedCommandLineAction.js","sourceRoot":"","sources":["../../src/providers/ScopedCommandLineAction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,4CAAuD;AACvD,2DAAwF;AACxF,2DAAwF;AACxF,6EAA0E;AAiB1E;;;GAGG;AACH,MAAM,+BAAgC,SAAQ,qCAAiB;IAI7D,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,YAAmB,OAAgD;QACjE,MAAM,EAAE,aAAa,EAAE,wBAAwB,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,GAC9F,OAAO,CAAC;QAEV,MAAM,WAAW,GAAW,GAAG,YAAY,IAAI,aAAa,CAAC,UAAU,EAAE,CAAC;QAC1E,6FAA6F;QAC7F,MAAM,qBAAqB,GAAW,GAAG,YAAY,IAAI,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,aAAa,CAAC,UAAU,EAAE,CAAC;QACnG,MAAM,WAAW,GAAa,EAAE,CAAC;QACjC,KAAK,MAAM,SAAS,IAAI,wBAAwB,EAAE,CAAC;YACjD,SAAS,CA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AC/E,sEAAsE;gBACtE,oDAAoD,CACvD,CAAC;QACJ,CAAC;QAED,KAAK,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC;QAExC,MAAM,EAAE,oBAAoB,EAAE,GAAG,KAAK,CAAC;QACvC,MAAM,2BAA2B,GAAgB,IAAI,GAAG,CAAC;YACvD,GAAG,oBAAoB;YACvB,GAAG,IAAI,CAAC,oCAAoC,CAAC,IAAI,EAAE;SACpD,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,mCACf,KAAK,KACR,oBAAoB,EAAE,2BAA2B,GAClD,CAAC;IACJ,CAAC;IAED;;;OAGG;IACO,2BAA2B;QACnC,IAAI,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,8EAA8E,CAAC,CAAC;QAClG,CAAC;QACD,OAAO,IAAI,CAAC,wBAAwB,CAAC;IACvC,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,SAA+B;QACxD,KAAK,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAClC,IAAI,SAAS,CAAC,cAAc,KAAK,uBAAuB,CAAC,qBAAqB,EAAE,CAAC;YAC/E,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;;AA9JH,0DAoLC;AA7KC;;;GAGG;AACoB,6CAAqB,GAAmC,mCAAuB,CAAC","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 { SCOPING_PARAMETER_GROUP } from '../Constants';\nimport { CommandLineAction, type ICommandLineActionOptions } from './CommandLineAction';\nimport { CommandLineParser, type ICommandLineParserOptions } from './CommandLineParser';\nimport { CommandLineParserExitError } from './CommandLineParserExitError';\nimport type { CommandLineParameter, CommandLineParameterBase } from '../parameters/BaseClasses';\nimport type {\n CommandLineParameterProvider,\n ICommandLineParserData,\n IRegisterDefinedParametersState\n} from './CommandLineParameterProvider';\n\ninterface IInternalScopedCommandLineParserOptions extends ICommandLineParserOptions {\n readonly actionOptions: ICommandLineActionOptions;\n readonly unscopedActionParameters: ReadonlyArray<CommandLineParameter>;\n readonly onDefineScopedParameters: (commandLineParameterProvider: CommandLineParameterProvider) => void;\n readonly aliasAction?: string;\n readonly aliasDocumentation?: string;\n readonly registerDefinedParametersState: IRegisterDefinedParametersState;\n}\n\n/**\n * A CommandLineParser used exclusively to parse the scoped command-line parameters\n * for a ScopedCommandLineAction.\n */\nclass InternalScopedCommandLineParser extends CommandLineParser {\n private _canExecute: boolean;\n private readonly _internalOptions: IInternalScopedCommandLineParserOptions;\n\n public get canExecute(): boolean {\n return this._canExecute;\n }\n\n public constructor(options: IInternalScopedCommandLineParserOptions) {\n const { actionOptions, unscopedActionParameters, toolFilename, aliasAction, aliasDocumentation } =\n options;\n\n const toolCommand: string = `${toolFilename} ${actionOptions.actionName}`;\n // When coming from an alias command, we want to show the alias command name in the help text\n const toolCommandForLogging: string = `${toolFilename} ${aliasAction ?? actionOptions.actionName}`;\n const scopingArgs: string[] = [];\n for (const parameter of unscopedActionParameters) {\n parameter.appendToArgList(scopingArgs);\n }\n const scope: string = scopingArgs.join(' ');\n\n // We can run the parser directly because we are not going to use it for any other actions,\n // so construct a special options object to make the \"--help\" text more useful.\n const scopedCommandLineParserOptions: ICommandLineParserOptions = {\n // Strip the scoping args if coming from an alias command, since they are not applicable\n // to the alias command itself\n toolFilename: `${toolCommandForLogging}${scope && !aliasAction ? ` ${scope} --` : ''}`,\n toolDescription: aliasDocumentation ?? actionOptions.documentation,\n toolEpilog: `For more information on available unscoped parameters, use \"${toolCommand} --help\"`,\n enableTabCompletionAction: false\n };\n\n super(scopedCommandLineParserOptions);\n this._canExecute = false;\n this._internalOptions = options;\n this._internalOptions.onDefineScopedParameters(this);\n }\n\n public _registerDefinedParameters(state: IRegisterDefinedParametersState): void {\n // Since we are in a separate parser, we need to register the parameters using the state\n // from the parent parser.\n super._registerDefinedParameters(this._internalOptions.registerDefinedParametersState);\n }\n\n protected async onExecute(): Promise<void> {\n // override\n // Only set if we made it this far, which may not be the case if an error occurred or\n // if '--help' was specified.\n this._canExecute = true;\n }\n}\n\n/**\n * Represents a sub-command that is part of the CommandLineParser command-line.\n * Applications should create subclasses of ScopedCommandLineAction corresponding to\n * each action that they want to expose.\n *\n * The action name should be comprised of lower case words separated by hyphens\n * or colons. The name should include an English verb (e.g. \"deploy\"). Use a\n * hyphen to separate words (e.g. \"upload-docs\"). A group of related commands\n * can be prefixed with a colon (e.g. \"docs:generate\", \"docs:deploy\",\n * \"docs:serve\", etc).\n *\n * Scoped commands allow for different parameters to be specified for different\n * provided scoping values. For example, the \"scoped-action --scope A\" command\n * may allow for different scoped arguments to be specified than the \"scoped-action\n * --scope B\" command.\n *\n * Scoped arguments are specified after the \"--\" pseudo-argument. For example,\n * \"scoped-action --scope A -- --scopedFoo --scopedBar\".\n *\n * @public\n */\nexport abstract class ScopedCommandLineAction extends CommandLineAction {\n private _options: ICommandLineActionOptions;\n private _scopingParameters: CommandLineParameter[];\n private _unscopedParserOptions: ICommandLineParserOptions | undefined;\n private _scopedCommandLineParser: InternalScopedCommandLineParser | undefined;\n private _subparserState: IRegisterDefinedParametersState | undefined;\n\n /**\n * The required group name to apply to all scoping parameters. At least one parameter\n * must be defined with this group name.\n */\n public static readonly ScopingParameterGroup: typeof SCOPING_PARAMETER_GROUP = SCOPING_PARAMETER_GROUP;\n\n public constructor(options: ICommandLineActionOptions) {\n super(options);\n\n this._options = options;\n this._scopingParameters = [];\n\n // Consume the remainder of the command-line, which will later be passed the scoped parser.\n // This will also prevent developers from calling this.defineCommandLineRemainder(...) since\n // we will have already defined it.\n this.defineCommandLineRemainder({\n description:\n 'Scoped parameters. Must be prefixed with \"--\", ex. \"-- --scopedParameter ' +\n 'foo --scopedFlag\". For more information on available scoped parameters, use \"-- --help\".'\n });\n\n this.onDefineUnscopedParameters?.();\n }\n\n /**\n * {@inheritDoc CommandLineParameterProvider.parameters}\n *\n * @internalremarks\n * TODO: Replace this type with `CommandLineParameter` in the next major bump.\n */\n public get parameters(): ReadonlyArray<CommandLineParameterBase> {\n if (this._scopedCommandLineParser) {\n return [...super.parameters, ...this._scopedCommandLineParser.parameters];\n } else {\n return super.parameters;\n }\n }\n\n /**\n * {@inheritdoc CommandLineParameterProvider._processParsedData}\n * @internal\n */\n public _processParsedData(parserOptions: ICommandLineParserOptions, data: ICommandLineParserData): void {\n // override\n super._processParsedData(parserOptions, data);\n\n // This should never happen because the super method should throw if parameters haven't been registered,\n // but guard against this just in-case.\n if (this._subparserState === undefined) {\n throw new Error('Parameters have not been registered');\n }\n\n this._unscopedParserOptions = parserOptions;\n\n // Generate the scoped parser using the parent parser information. We can only create this after we\n // have parsed the data, since the parameter values are used during construction.\n this._scopedCommandLineParser = new InternalScopedCommandLineParser({\n ...parserOptions,\n actionOptions: this._options,\n aliasAction: data.aliasAction,\n aliasDocumentation: data.aliasDocumentation,\n unscopedActionParameters: this.parameters as CommandLineParameter[],\n registerDefinedParametersState: this._subparserState,\n onDefineScopedParameters: this.onDefineScopedParameters.bind(this)\n });\n }\n\n /**\n * {@inheritdoc CommandLineAction._executeAsync}\n * @internal\n */\n public async _executeAsync(): Promise<void> {\n // override\n if (!this._unscopedParserOptions || !this._scopedCommandLineParser) {\n throw new Error('The CommandLineAction parameters must be processed before execution.');\n }\n if (!this.remainder) {\n throw new Error('CommandLineAction.onDefineParameters must be called before execution.');\n }\n\n // The '--' argument is required to separate the action parameters from the scoped parameters,\n // so it needs to be trimmed. If remainder values are provided but no '--' is found, then throw.\n const scopedArgs: string[] = [];\n if (this.remainder.values.length) {\n if (this.remainder.values[0] !== '--') {\n throw new CommandLineParserExitError(\n // argparse sets exit code 2 for invalid arguments\n 2,\n // model the message off of the built-in \"unrecognized arguments\" message\n `${this.renderUsageText()}\\n${this._unscopedParserOptions.toolFilename} ${this.actionName}: ` +\n `error: Unrecognized arguments: ${this.remainder.values[0]}.\\n`\n );\n }\n for (const scopedArg of this.remainder.values.slice(1)) {\n scopedArgs.push(scopedArg);\n }\n }\n\n // Call the scoped parser using only the scoped args to handle parsing\n await this._scopedCommandLineParser.executeWithoutErrorHandlingAsync(scopedArgs);\n\n // Only call execute if the parser reached the execute stage. This may not be true if\n // the parser exited early due to a specified '--help' parameter.\n if (this._scopedCommandLineParser.canExecute) {\n await super._executeAsync();\n }\n\n return;\n }\n\n /** @internal */\n public _registerDefinedParameters(state: IRegisterDefinedParametersState): void {\n if (!this._scopingParameters.length) {\n throw new Error(\n 'No scoping parameters defined. At least one scoping parameter must be defined. ' +\n 'Scoping parameters are defined by setting the parameterGroupName to ' +\n 'ScopedCommandLineAction.ScopingParameterGroupName.'\n );\n }\n\n super._registerDefinedParameters(state);\n\n const { parentParameterNames } = state;\n const updatedParentParameterNames: Set<string> = new Set([\n ...parentParameterNames,\n ...this._registeredParameterParserKeysByName.keys()\n ]);\n\n this._subparserState = {\n ...state,\n parentParameterNames: updatedParentParameterNames\n };\n }\n\n /**\n * Retrieves the scoped CommandLineParser, which is populated after the ScopedCommandLineAction is executed.\n * @internal\n */\n protected _getScopedCommandLineParser(): CommandLineParser {\n if (!this._scopedCommandLineParser) {\n throw new Error('The scoped CommandLineParser is only populated after the action is executed.');\n }\n return this._scopedCommandLineParser;\n }\n\n /** @internal */\n protected _defineParameter(parameter: CommandLineParameter): void {\n super._defineParameter(parameter);\n if (parameter.parameterGroup === ScopedCommandLineAction.ScopingParameterGroup) {\n this._scopingParameters.push(parameter);\n }\n }\n\n /**\n * @deprecated - Define parameters in the constructor\n */\n protected onDefineUnscopedParameters?(): void;\n\n /**\n * The child class should implement this hook to define its scoped command-line\n * parameters, e.g. by calling scopedParameterProvider.defineFlagParameter(). These\n * parameters will only be available if the action is invoked with a scope.\n *\n * @remarks\n * onDefineScopedParameters is called after the unscoped parameters have been parsed.\n * The values they provide can be used to vary the defined scope parameters.\n */\n protected abstract onDefineScopedParameters(scopedParameterProvider: CommandLineParameterProvider): void;\n\n /**\n * {@inheritDoc CommandLineAction.onExecute}\n */\n protected abstract onExecute(): Promise<void>;\n}\n"]}
|
|
@@ -96,8 +96,8 @@ class TabCompleteAction extends CommandLineAction_1.CommandLineAction {
|
|
|
96
96
|
finally { if (e_1) throw e_1.error; }
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
getCompletionsAsync(
|
|
100
|
-
return __asyncGenerator(this, arguments, function* getCompletionsAsync_1() {
|
|
99
|
+
getCompletionsAsync(commandLine_1) {
|
|
100
|
+
return __asyncGenerator(this, arguments, function* getCompletionsAsync_1(commandLine, caretPosition = commandLine.length) {
|
|
101
101
|
const actions = this._actions;
|
|
102
102
|
if (!commandLine || !caretPosition) {
|
|
103
103
|
yield __await(yield* __asyncDelegator(__asyncValues(this._getAllActions())));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabCompletionAction.js","sourceRoot":"","sources":["../../src/providers/TabCompletionAction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,8DAAqC;AAIrC,2DAKmC;AACnC,yFAAsF;AACtF,2DAAwD;AAGxD,MAAM,4BAA4B,GAAW,EAAE,CAAC;AAChD,MAAM,gBAAgB,GAAW,CAAC,CAAC;AAEnC,MAAa,iBAAkB,SAAQ,qCAAiB;IAMtD,YACE,OAAyC,EACzC,gBAAyD;QAEzD,KAAK,CAAC;YACJ,UAAU,mEAA8C;YACxD,OAAO,EAAE,0BAA0B;YACnC,aAAa,EAAE,0BAA0B;SAC1C,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,+BAA+B,GAAsC,IAAI,GAAG,EAAE,CAAC;YACrF,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBAC1C,+BAA+B,CAA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C;IACH,CAAC;CACF;AA9MD,8CA8MC","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 stringArgv from 'string-argv';\n\nimport type { IRequiredCommandLineIntegerParameter } from '../parameters/CommandLineIntegerParameter';\nimport type { IRequiredCommandLineStringParameter } from '../parameters/CommandLineStringParameter';\nimport {\n CommandLineParameterKind,\n type CommandLineParameterBase,\n CommandLineParameterWithArgument,\n type CommandLineParameter\n} from '../parameters/BaseClasses';\nimport { CommandLineChoiceParameter } from '../parameters/CommandLineChoiceParameter';\nimport { CommandLineAction } from './CommandLineAction';\nimport { CommandLineConstants } from '../Constants';\n\nconst DEFAULT_WORD_TO_AUTOCOMPLETE: string = '';\nconst DEFAULT_POSITION: number = 0;\n\nexport class TabCompleteAction extends CommandLineAction {\n private readonly _wordToCompleteParameter: IRequiredCommandLineStringParameter;\n private readonly _positionParameter: IRequiredCommandLineIntegerParameter;\n private readonly _actions: Map<string, Map<string, CommandLineParameter>>;\n private readonly _globalParameters: Map<string, CommandLineParameter>;\n\n public constructor(\n actions: ReadonlyArray<CommandLineAction>,\n globalParameters: ReadonlyArray<CommandLineParameterBase>\n ) {\n super({\n actionName: CommandLineConstants.TabCompletionActionName,\n summary: 'Provides tab completion.',\n documentation: 'Provides tab completion.'\n });\n\n this._actions = new Map();\n for (const action of actions) {\n const parameterNameToParameterInfoMap: Map<string, CommandLineParameter> = new Map();\n for (const parameter of action.parameters) {\n parameterNameToParameterInfoMap.set(parameter.longName, parameter as CommandLineParameter);\n if (parameter.shortName) {\n parameterNameToParameterInfoMap.set(parameter.shortName, parameter as CommandLineParameter);\n }\n }\n this._actions.set(action.actionName, parameterNameToParameterInfoMap);\n }\n\n this._globalParameters = new Map<string, CommandLineParameter>();\n for (const parameter of globalParameters) {\n this._globalParameters.set(parameter.longName, parameter as CommandLineParameter);\n if (parameter.shortName) {\n this._globalParameters.set(parameter.shortName, parameter as CommandLineParameter);\n }\n }\n\n this._wordToCompleteParameter = this.defineStringParameter({\n parameterLongName: '--word',\n argumentName: 'WORD',\n description: `The word to complete.`,\n defaultValue: DEFAULT_WORD_TO_AUTOCOMPLETE\n });\n\n this._positionParameter = this.defineIntegerParameter({\n parameterLongName: '--position',\n argumentName: 'INDEX',\n description: `The position in the word to be completed.`,\n defaultValue: DEFAULT_POSITION\n });\n }\n\n protected async onExecute(): Promise<void> {\n const commandLine: string = this._wordToCompleteParameter.value;\n const caretPosition: number = this._positionParameter.value || commandLine.length;\n\n for await (const value of this.getCompletionsAsync(commandLine, caretPosition)) {\n // eslint-disable-next-line no-console\n console.log(value);\n }\n }\n\n public async *getCompletionsAsync(\n commandLine: string,\n caretPosition: number = commandLine.length\n ): AsyncIterable<string> {\n const actions: Map<string, Map<string, CommandLineParameter>> = this._actions;\n\n if (!commandLine || !caretPosition) {\n yield* this._getAllActions();\n return;\n }\n\n const tokens: string[] = Array.from(this.tokenizeCommandLine(commandLine));\n\n // offset arguments by the number of global params in the input\n const globalParameterOffset: number = this._getGlobalParameterOffset(tokens);\n\n if (tokens.length < 2 + globalParameterOffset) {\n yield* this._getAllActions();\n return;\n }\n\n const lastToken: string = tokens[tokens.length - 1];\n const secondLastToken: string = tokens[tokens.length - 2];\n\n const lastCharacterIsWhitespace: boolean = !commandLine.slice(-1).trim();\n const completePartialWord: boolean = caretPosition === commandLine.length && !lastCharacterIsWhitespace;\n\n if (completePartialWord && tokens.length === 2 + globalParameterOffset) {\n for (const actionName of actions.keys()) {\n if (actionName.indexOf(tokens[1 + globalParameterOffset]) === 0) {\n yield actionName;\n }\n }\n } else {\n for (const actionName of actions.keys()) {\n if (actionName === tokens[1 + globalParameterOffset]) {\n const parameterNameMap: Map<string, CommandLineParameter> = actions.get(actionName)!;\n\n const parameterNames: string[] = Array.from(parameterNameMap.keys());\n\n if (completePartialWord) {\n for (const parameterName of parameterNames) {\n if (parameterName === secondLastToken) {\n const values: ReadonlyArray<string> = await this._getParameterValueCompletionsAsync(\n parameterNameMap.get(parameterName)!\n );\n if (values.length > 0) {\n yield* this._completeParameterValues(values, lastToken);\n return;\n }\n }\n }\n yield* this._completeParameterValues(parameterNames, lastToken);\n } else {\n for (const parameterName of parameterNames) {\n if (parameterName === lastToken) {\n const values: ReadonlyArray<string> = await this._getParameterValueCompletionsAsync(\n parameterNameMap.get(parameterName)!\n );\n if (values.length > 0) {\n yield* values;\n return;\n }\n }\n }\n for (const parameterName of parameterNames) {\n if (\n parameterName === lastToken &&\n parameterNameMap.get(parameterName)!.kind !== CommandLineParameterKind.Flag\n ) {\n // The parameter is expecting a value, so don't suggest parameter names again\n return;\n }\n }\n\n yield* parameterNames;\n }\n\n break;\n }\n }\n }\n }\n\n private *_getAllActions(): IterableIterator<string> {\n yield* this._actions.keys();\n yield* this._globalParameters.keys();\n }\n\n public tokenizeCommandLine(commandLine: string): string[] {\n return stringArgv(commandLine);\n }\n\n private async _getParameterValueCompletionsAsync(\n parameter: CommandLineParameter\n ): Promise<ReadonlyArray<string>> {\n let choiceParameterValues: ReadonlyArray<string> = [];\n if (parameter.kind === CommandLineParameterKind.Choice) {\n choiceParameterValues = parameter.alternatives;\n } else if (parameter.kind !== CommandLineParameterKind.Flag) {\n let parameterWithArgumentOrChoices:\n | CommandLineParameterWithArgument\n | CommandLineChoiceParameter\n | undefined = undefined;\n if (\n parameter instanceof CommandLineParameterWithArgument ||\n parameter instanceof CommandLineChoiceParameter\n ) {\n parameterWithArgumentOrChoices = parameter;\n }\n\n if (parameterWithArgumentOrChoices?.completions) {\n choiceParameterValues = await parameterWithArgumentOrChoices.completions();\n }\n }\n\n return choiceParameterValues;\n }\n\n private _getGlobalParameterOffset(tokens: string[]): number {\n const globalParameters: Map<string, CommandLineParameter> = this._globalParameters;\n let count: number = 0;\n\n outer: for (let i: number = 1; i < tokens.length; i++) {\n for (const globalParameter of globalParameters.values()) {\n if (tokens[i] !== globalParameter.longName && tokens[i] !== globalParameter.shortName) {\n break outer;\n }\n }\n count++;\n }\n\n return count;\n }\n\n private *_completeParameterValues(\n choiceParameterValues: ReadonlyArray<string>,\n lastToken: string\n ): IterableIterator<string> {\n for (const choiceParameterValue of choiceParameterValues) {\n if (choiceParameterValue.indexOf(lastToken) === 0) {\n yield choiceParameterValue;\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TabCompletionAction.js","sourceRoot":"","sources":["../../src/providers/TabCompletionAction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,8DAAqC;AAIrC,2DAKmC;AACnC,yFAAsF;AACtF,2DAAwD;AAGxD,MAAM,4BAA4B,GAAW,EAAE,CAAC;AAChD,MAAM,gBAAgB,GAAW,CAAC,CAAC;AAEnC,MAAa,iBAAkB,SAAQ,qCAAiB;IAMtD,YACE,OAAyC,EACzC,gBAAyD;QAEzD,KAAK,CAAC;YACJ,UAAU,mEAA8C;YACxD,OAAO,EAAE,0BAA0B;YACnC,aAAa,EAAE,0BAA0B;SAC1C,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,+BAA+B,GAAsC,IAAI,GAAG,EAAE,CAAC;YACrF,KAAK,MAAM,SAAS,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBAC1C,+BAA+B,CAAC,GAAG,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAiC,CAAC,CAAC;gBAC3F,IAAI,SAAS,CAAC,SAAS,EAAE,CAAC;oBACxB,+BAA+B,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,SAAiC,CAAC,CAAC;gBAC9F,CAAC;YACH,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,+BAA+B,CAAC,CAAC;QACxE,CAAC;QAED,IAAI,CAAC,iBAAiB,GAAG,I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AChD,qBAAqB,GAAG,MAAM,8BAA8B,CAAC,WAAW,EAAE,CAAC;YAC7E,CAAC;QACH,CAAC;QAED,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAEO,yBAAyB,CAAC,MAAgB;QAChD,MAAM,gBAAgB,GAAsC,IAAI,CAAC,iBAAiB,CAAC;QACnF,IAAI,KAAK,GAAW,CAAC,CAAC;QAEtB,KAAK,EAAE,KAAK,IAAI,CAAC,GAAW,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtD,KAAK,MAAM,eAAe,IAAI,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC;gBACxD,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,eAAe,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,eAAe,CAAC,SAAS,EAAE,CAAC;oBACtF,MAAM,KAAK,CAAC;gBACd,CAAC;YACH,CAAC;YACD,KAAK,EAAE,CAAC;QACV,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,CAAC,wBAAwB,CAC/B,qBAA4C,EAC5C,SAAiB;QAEjB,KAAK,MAAM,oBAAoB,IAAI,qBAAqB,EAAE,CAAC;YACzD,IAAI,oBAAoB,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;gBAClD,MAAM,oBAAoB,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA9MD,8CA8MC","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 stringArgv from 'string-argv';\n\nimport type { IRequiredCommandLineIntegerParameter } from '../parameters/CommandLineIntegerParameter';\nimport type { IRequiredCommandLineStringParameter } from '../parameters/CommandLineStringParameter';\nimport {\n CommandLineParameterKind,\n type CommandLineParameterBase,\n CommandLineParameterWithArgument,\n type CommandLineParameter\n} from '../parameters/BaseClasses';\nimport { CommandLineChoiceParameter } from '../parameters/CommandLineChoiceParameter';\nimport { CommandLineAction } from './CommandLineAction';\nimport { CommandLineConstants } from '../Constants';\n\nconst DEFAULT_WORD_TO_AUTOCOMPLETE: string = '';\nconst DEFAULT_POSITION: number = 0;\n\nexport class TabCompleteAction extends CommandLineAction {\n private readonly _wordToCompleteParameter: IRequiredCommandLineStringParameter;\n private readonly _positionParameter: IRequiredCommandLineIntegerParameter;\n private readonly _actions: Map<string, Map<string, CommandLineParameter>>;\n private readonly _globalParameters: Map<string, CommandLineParameter>;\n\n public constructor(\n actions: ReadonlyArray<CommandLineAction>,\n globalParameters: ReadonlyArray<CommandLineParameterBase>\n ) {\n super({\n actionName: CommandLineConstants.TabCompletionActionName,\n summary: 'Provides tab completion.',\n documentation: 'Provides tab completion.'\n });\n\n this._actions = new Map();\n for (const action of actions) {\n const parameterNameToParameterInfoMap: Map<string, CommandLineParameter> = new Map();\n for (const parameter of action.parameters) {\n parameterNameToParameterInfoMap.set(parameter.longName, parameter as CommandLineParameter);\n if (parameter.shortName) {\n parameterNameToParameterInfoMap.set(parameter.shortName, parameter as CommandLineParameter);\n }\n }\n this._actions.set(action.actionName, parameterNameToParameterInfoMap);\n }\n\n this._globalParameters = new Map<string, CommandLineParameter>();\n for (const parameter of globalParameters) {\n this._globalParameters.set(parameter.longName, parameter as CommandLineParameter);\n if (parameter.shortName) {\n this._globalParameters.set(parameter.shortName, parameter as CommandLineParameter);\n }\n }\n\n this._wordToCompleteParameter = this.defineStringParameter({\n parameterLongName: '--word',\n argumentName: 'WORD',\n description: `The word to complete.`,\n defaultValue: DEFAULT_WORD_TO_AUTOCOMPLETE\n });\n\n this._positionParameter = this.defineIntegerParameter({\n parameterLongName: '--position',\n argumentName: 'INDEX',\n description: `The position in the word to be completed.`,\n defaultValue: DEFAULT_POSITION\n });\n }\n\n protected async onExecute(): Promise<void> {\n const commandLine: string = this._wordToCompleteParameter.value;\n const caretPosition: number = this._positionParameter.value || commandLine.length;\n\n for await (const value of this.getCompletionsAsync(commandLine, caretPosition)) {\n // eslint-disable-next-line no-console\n console.log(value);\n }\n }\n\n public async *getCompletionsAsync(\n commandLine: string,\n caretPosition: number = commandLine.length\n ): AsyncIterable<string> {\n const actions: Map<string, Map<string, CommandLineParameter>> = this._actions;\n\n if (!commandLine || !caretPosition) {\n yield* this._getAllActions();\n return;\n }\n\n const tokens: string[] = Array.from(this.tokenizeCommandLine(commandLine));\n\n // offset arguments by the number of global params in the input\n const globalParameterOffset: number = this._getGlobalParameterOffset(tokens);\n\n if (tokens.length < 2 + globalParameterOffset) {\n yield* this._getAllActions();\n return;\n }\n\n const lastToken: string = tokens[tokens.length - 1];\n const secondLastToken: string = tokens[tokens.length - 2];\n\n const lastCharacterIsWhitespace: boolean = !commandLine.slice(-1).trim();\n const completePartialWord: boolean = caretPosition === commandLine.length && !lastCharacterIsWhitespace;\n\n if (completePartialWord && tokens.length === 2 + globalParameterOffset) {\n for (const actionName of actions.keys()) {\n if (actionName.indexOf(tokens[1 + globalParameterOffset]) === 0) {\n yield actionName;\n }\n }\n } else {\n for (const actionName of actions.keys()) {\n if (actionName === tokens[1 + globalParameterOffset]) {\n const parameterNameMap: Map<string, CommandLineParameter> = actions.get(actionName)!;\n\n const parameterNames: string[] = Array.from(parameterNameMap.keys());\n\n if (completePartialWord) {\n for (const parameterName of parameterNames) {\n if (parameterName === secondLastToken) {\n const values: ReadonlyArray<string> = await this._getParameterValueCompletionsAsync(\n parameterNameMap.get(parameterName)!\n );\n if (values.length > 0) {\n yield* this._completeParameterValues(values, lastToken);\n return;\n }\n }\n }\n yield* this._completeParameterValues(parameterNames, lastToken);\n } else {\n for (const parameterName of parameterNames) {\n if (parameterName === lastToken) {\n const values: ReadonlyArray<string> = await this._getParameterValueCompletionsAsync(\n parameterNameMap.get(parameterName)!\n );\n if (values.length > 0) {\n yield* values;\n return;\n }\n }\n }\n for (const parameterName of parameterNames) {\n if (\n parameterName === lastToken &&\n parameterNameMap.get(parameterName)!.kind !== CommandLineParameterKind.Flag\n ) {\n // The parameter is expecting a value, so don't suggest parameter names again\n return;\n }\n }\n\n yield* parameterNames;\n }\n\n break;\n }\n }\n }\n }\n\n private *_getAllActions(): IterableIterator<string> {\n yield* this._actions.keys();\n yield* this._globalParameters.keys();\n }\n\n public tokenizeCommandLine(commandLine: string): string[] {\n return stringArgv(commandLine);\n }\n\n private async _getParameterValueCompletionsAsync(\n parameter: CommandLineParameter\n ): Promise<ReadonlyArray<string>> {\n let choiceParameterValues: ReadonlyArray<string> = [];\n if (parameter.kind === CommandLineParameterKind.Choice) {\n choiceParameterValues = parameter.alternatives;\n } else if (parameter.kind !== CommandLineParameterKind.Flag) {\n let parameterWithArgumentOrChoices:\n | CommandLineParameterWithArgument\n | CommandLineChoiceParameter\n | undefined = undefined;\n if (\n parameter instanceof CommandLineParameterWithArgument ||\n parameter instanceof CommandLineChoiceParameter\n ) {\n parameterWithArgumentOrChoices = parameter;\n }\n\n if (parameterWithArgumentOrChoices?.completions) {\n choiceParameterValues = await parameterWithArgumentOrChoices.completions();\n }\n }\n\n return choiceParameterValues;\n }\n\n private _getGlobalParameterOffset(tokens: string[]): number {\n const globalParameters: Map<string, CommandLineParameter> = this._globalParameters;\n let count: number = 0;\n\n outer: for (let i: number = 1; i < tokens.length; i++) {\n for (const globalParameter of globalParameters.values()) {\n if (tokens[i] !== globalParameter.longName && tokens[i] !== globalParameter.shortName) {\n break outer;\n }\n }\n count++;\n }\n\n return count;\n }\n\n private *_completeParameterValues(\n choiceParameterValues: ReadonlyArray<string>,\n lastToken: string\n ): IterableIterator<string> {\n for (const choiceParameterValue of choiceParameterValues) {\n if (choiceParameterValue.indexOf(lastToken) === 0) {\n yield choiceParameterValue;\n }\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/ts-command-line",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.21.1",
|
|
4
4
|
"description": "An object-oriented command-line parser for TypeScript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"@types/argparse": "1.0.38",
|
|
15
15
|
"argparse": "~1.0.9",
|
|
16
16
|
"string-argv": "~0.3.1",
|
|
17
|
-
"@rushstack/terminal": "0.11.
|
|
17
|
+
"@rushstack/terminal": "0.11.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@rushstack/heft": "0.
|
|
21
|
-
"@rushstack/heft-node-rig": "2.
|
|
20
|
+
"@rushstack/heft": "0.66.9",
|
|
21
|
+
"@rushstack/heft-node-rig": "2.6.7",
|
|
22
22
|
"@types/heft-jest": "1.0.1",
|
|
23
23
|
"@types/node": "18.17.15",
|
|
24
24
|
"local-eslint-config": "1.0.0"
|