@rushstack/ts-command-line 4.17.0 → 4.17.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.
@@ -1 +1 @@
1
- {"version":3,"file":"BaseClasses.js","sourceRoot":"","sources":["../../src/parameters/BaseClasses.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAQ3D;;;GAGG;AACH,IAAY,wBAeX;AAfD,WAAY,wBAAwB;IAClC,6CAA6C;IAC7C,2EAAM,CAAA;IACN,2CAA2C;IAC3C,uEAAI,CAAA;IACJ,8CAA8C;IAC9C,6EAAO,CAAA;IACP,6CAA6C;IAC7C,2EAAM,CAAA;IACN,iDAAiD;IACjD,mFAAU,CAAA;IACV,iDAAiD;IACjD,mFAAU,CAAA;IACV,kDAAkD;IAClD,qFAAW,CAAA;AACb,CAAC,EAfW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAenC;AAED;;;GAGG;AACH,MAAM,gBAAgB,GAAW,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,MAAM,iBAAiB,GAAW,aAAa,CAAC;AAEhD;;;GAGG;AACH,MAAM,YAAY,GAAW,0BAA0B,CAAC;AAExD;;;;;GAKG;AACH,MAAM,gCAAgC,GAAW,oBAAoB,CAAC;AAEtE;;;GAGG;AACH,MAAsB,oBAAoB;IAoCxC,gBAAgB;IAChB,YAAmB,UAAsC;QACvD,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,iBAAiB,CAAC;QAC7C,IAAI,CAAC,eAAe,GAAG,UAAU,CAAC,kBAAkB,CAAC;QACrD,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;QAChD,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;QAChD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;QAC1C,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC;QAC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;IACH,CAAC;CACF;AAhLD,oDAgLC;AAED;;;;;;;GAOG;AACH,MAAsB,gCAAiC,SAAQ,oBAAoB;IAUjF,gBAAgB;IAChB,YAAmB,UAAkD;QACnE,KAAK,CAAC,UAAU,CAAC,CAAC;QAElB,IAAI,UAAU,CAAC,YAAY,KAAK,EAAE,EAAE;YAClC,MAAM,IAAI,KAAK,CACb,yFAAyF,CAC1F,CAAC;SACH;QACD,IAAI,UAAU,CAAC,YAAY,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,YAAY,EAAE;YACrE,MAAM,IAAI,KAAK,CACb,kBAAkB,UAAU,CAAC,YAAY,8CAA8C,CACxF,CAAC;SACH;QACD,MAAM,KAAK,GAA4B,UAAU,CAAC,YAAY,CAAC,KAAK,CAClE,gCAAgC,CAAC,0BAA0B,CAC5D,CAAC;QACF,IAAI,KAAK,EAAE;YACT,MAAM,IAAI,KAAK,CACb,sBAAsB,UAAU,CAAC,YAAY,oCAAoC,KAAK,CAAC,CAAC,CAAC,IAAI;gBAC3F,iEAAiE,CACpE,CAAC;SACH;QACD,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;QAC5C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;IAC5C,CAAC;;AAlCD,oGAAoG;AACrF,2DAA0B,GAAW,YAAY,CAAC;AAF7C,4EAAgC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { SCOPING_PARAMETER_GROUP } from '../Constants';\r\nimport type {\r\n IBaseCommandLineDefinition,\r\n IBaseCommandLineDefinitionWithArgument\r\n} from './CommandLineDefinition';\r\n\r\n/**\r\n * Identifies the kind of a CommandLineParameter.\r\n * @public\r\n */\r\nexport enum CommandLineParameterKind {\r\n /** Indicates a CommandLineChoiceParameter */\r\n Choice,\r\n /** Indicates a CommandLineFlagParameter */\r\n Flag,\r\n /** Indicates a CommandLineIntegerParameter */\r\n Integer,\r\n /** Indicates a CommandLineStringParameter */\r\n String,\r\n /** Indicates a CommandLineStringListParameter */\r\n StringList,\r\n /** Indicates a CommandLineChoiceListParameter */\r\n ChoiceList,\r\n /** Indicates a CommandLineIntegerListParameter */\r\n IntegerList\r\n}\r\n\r\n/**\r\n * Matches kebab-case formatted strings prefixed with double dashes.\r\n * Example: \"--do-something\"\r\n */\r\nconst LONG_NAME_REGEXP: RegExp = /^-(-[a-z0-9]+)+$/;\r\n\r\n/**\r\n * Matches a single upper-case or lower-case letter prefixed with a dash.\r\n * Example: \"-d\"\r\n */\r\nconst SHORT_NAME_REGEXP: RegExp = /^-[a-zA-Z]$/;\r\n\r\n/**\r\n * Matches kebab-case formatted strings\r\n * Example: \"my-scope\"\r\n */\r\nconst SCOPE_REGEXP: RegExp = /^[a-z0-9]+(-[a-z0-9]+)*$/;\r\n\r\n/**\r\n * \"Environment variable names used by the utilities in the Shell and Utilities volume of\r\n * IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore)\r\n * from the characters defined in Portable Character Set and do not begin with a digit.\"\r\n * Example: \"THE_SETTING\"\r\n */\r\nconst ENVIRONMENT_VARIABLE_NAME_REGEXP: RegExp = /^[A-Z_][A-Z0-9_]*$/;\r\n\r\n/**\r\n * The base class for the various command-line parameter types.\r\n * @public\r\n */\r\nexport abstract class CommandLineParameter {\r\n private _shortNameValue: string | undefined;\r\n\r\n /**\r\n * A unique internal key used to retrieve the value from the parser's dictionary.\r\n * @internal\r\n */\r\n public _parserKey: string | undefined;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.parameterLongName} */\r\n public readonly longName: string;\r\n\r\n /**\r\n * If a parameterScope is provided, returns the scope-prefixed long name of the flag,\r\n * including double dashes, eg. \"--scope:do-something\". Otherwise undefined.\r\n */\r\n public readonly scopedLongName: string | undefined;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.parameterGroup} */\r\n public readonly parameterGroup: string | typeof SCOPING_PARAMETER_GROUP | undefined;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.parameterScope} */\r\n public readonly parameterScope: string | undefined;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.description} */\r\n public readonly description: string;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.required} */\r\n public readonly required: boolean;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.environmentVariable} */\r\n public readonly environmentVariable: string | undefined;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.undocumentedSynonyms } */\r\n public readonly undocumentedSynonyms: string[] | undefined;\r\n\r\n /** @internal */\r\n public constructor(definition: IBaseCommandLineDefinition) {\r\n this.longName = definition.parameterLongName;\r\n this._shortNameValue = definition.parameterShortName;\r\n this.parameterGroup = definition.parameterGroup;\r\n this.parameterScope = definition.parameterScope;\r\n this.description = definition.description;\r\n this.required = !!definition.required;\r\n this.environmentVariable = definition.environmentVariable;\r\n this.undocumentedSynonyms = definition.undocumentedSynonyms;\r\n\r\n if (!LONG_NAME_REGEXP.test(this.longName)) {\r\n throw new Error(\r\n `Invalid name: \"${this.longName}\". The parameter long name must be` +\r\n ` lower-case and use dash delimiters (e.g. \"--do-a-thing\")`\r\n );\r\n }\r\n\r\n if (this.shortName) {\r\n if (!SHORT_NAME_REGEXP.test(this.shortName)) {\r\n throw new Error(\r\n `Invalid name: \"${this.shortName}\". The parameter short name must be` +\r\n ` a dash followed by a single upper-case or lower-case letter (e.g. \"-a\")`\r\n );\r\n }\r\n }\r\n\r\n if (this.parameterScope) {\r\n if (!SCOPE_REGEXP.test(this.parameterScope)) {\r\n throw new Error(\r\n `Invalid scope: \"${this.parameterScope}\". The parameter scope name must be` +\r\n ` lower-case and use dash delimiters (e.g. \"my-scope\")`\r\n );\r\n }\r\n // Parameter long name is guaranteed to start with '--' since this is validated above\r\n const unprefixedLongName: string = this.longName.slice(2);\r\n this.scopedLongName = `--${this.parameterScope}:${unprefixedLongName}`;\r\n }\r\n\r\n if (this.environmentVariable) {\r\n if (this.required) {\r\n // TODO: This constraint is imposed only because argparse enforces \"required\" parameters, but\r\n // it does not know about ts-command-line environment variable mappings. We should fix this.\r\n throw new Error(\r\n `An \"environmentVariable\" cannot be specified for \"${this.longName}\"` +\r\n ` because it is a required parameter`\r\n );\r\n }\r\n\r\n if (!ENVIRONMENT_VARIABLE_NAME_REGEXP.test(this.environmentVariable)) {\r\n throw new Error(\r\n `Invalid environment variable name: \"${this.environmentVariable}\". The name must` +\r\n ` consist only of upper-case letters, numbers, and underscores. It may not start with a number.`\r\n );\r\n }\r\n }\r\n\r\n if (this.undocumentedSynonyms && this.undocumentedSynonyms.length > 0) {\r\n for (const undocumentedSynonym of this.undocumentedSynonyms) {\r\n if (this.longName === undocumentedSynonym) {\r\n throw new Error(\r\n `Invalid name: \"${undocumentedSynonym}\". Undocumented synonyms must not be the same` +\r\n ` as the the long name.`\r\n );\r\n } else if (!LONG_NAME_REGEXP.test(undocumentedSynonym)) {\r\n throw new Error(\r\n `Invalid name: \"${undocumentedSynonym}\". All undocumented synonyms name must be lower-case and ` +\r\n 'use dash delimiters (e.g. \"--do-a-thing\")'\r\n );\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.parameterShortName} */\r\n public get shortName(): string | undefined {\r\n return this._shortNameValue;\r\n }\r\n\r\n /**\r\n * Called internally by CommandLineParameterProvider._processParsedData()\r\n * @internal\r\n */\r\n public abstract _setValue(data: any): void; // eslint-disable-line @typescript-eslint/no-explicit-any\r\n\r\n /**\r\n * Returns additional text used by the help formatter.\r\n * @internal\r\n */\r\n public _getSupplementaryNotes(supplementaryNotes: string[]): void {\r\n // virtual\r\n if (this.environmentVariable !== undefined) {\r\n supplementaryNotes.push(\r\n 'This parameter may alternatively be specified via the ' +\r\n this.environmentVariable +\r\n ' environment variable.'\r\n );\r\n }\r\n }\r\n\r\n /**\r\n * Indicates the type of parameter.\r\n */\r\n public abstract get kind(): CommandLineParameterKind;\r\n\r\n /**\r\n * Append the parsed values to the provided string array.\r\n * @remarks\r\n * Sometimes a command line parameter is not used directly, but instead gets passed through to another\r\n * tool that will use it. For example if our parameter comes in as \"--max-count 3\", then we might want to\r\n * call `child_process.spawn()` and append [\"--max-count\", \"3\"] to the args array for that tool.\r\n * appendToArgList() appends zero or more strings to the provided array, based on the input command-line\r\n * that we parsed.\r\n *\r\n * If the parameter was omitted from our command-line and has no default value, then\r\n * nothing will be appended. If the short name was used, the long name will be appended instead.\r\n * @param argList - the parsed strings will be appended to this string array\r\n */\r\n public abstract appendToArgList(argList: string[]): void;\r\n\r\n /**\r\n * Internal usage only. Used to report unexpected output from the argparse library.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n protected reportInvalidData(data: any): never {\r\n throw new Error(`Unexpected data object for parameter \"${this.longName}\": ` + JSON.stringify(data));\r\n }\r\n\r\n protected validateDefaultValue(hasDefaultValue: boolean): void {\r\n if (this.required && hasDefaultValue) {\r\n // If a parameter is \"required\", then the user understands that they always need to\r\n // specify a value for this parameter (either via the command line or via an environment variable).\r\n // It would be confusing to allow a default value that sometimes allows the \"required\" parameter\r\n // to be omitted. If you sometimes don't have a suitable default value, then the better approach\r\n // is to throw a custom error explaining why the parameter is required in that case.\r\n throw new Error(\r\n `A default value cannot be specified for \"${this.longName}\" because it is a \"required\" parameter`\r\n );\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * The common base class for parameters types that receive an argument.\r\n *\r\n * @remarks\r\n * An argument is an accompanying command-line token, such as \"123\" in the\r\n * example \"--max-count 123\".\r\n * @public\r\n */\r\nexport abstract class CommandLineParameterWithArgument extends CommandLineParameter {\r\n // Matches the first character that *isn't* part of a valid upper-case argument name such as \"URL_2\"\r\n private static _invalidArgumentNameRegExp: RegExp = /[^A-Z_0-9]/;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinitionWithArgument.argumentName} */\r\n public readonly argumentName: string;\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinitionWithArgument.completions} */\r\n public readonly completions: (() => Promise<string[]>) | undefined;\r\n\r\n /** @internal */\r\n public constructor(definition: IBaseCommandLineDefinitionWithArgument) {\r\n super(definition);\r\n\r\n if (definition.argumentName === '') {\r\n throw new Error(\r\n 'The argument name cannot be an empty string. (For the default name, specify undefined.)'\r\n );\r\n }\r\n if (definition.argumentName.toUpperCase() !== definition.argumentName) {\r\n throw new Error(\r\n `Invalid name: \"${definition.argumentName}\". The argument name must be all upper case.`\r\n );\r\n }\r\n const match: RegExpMatchArray | null = definition.argumentName.match(\r\n CommandLineParameterWithArgument._invalidArgumentNameRegExp\r\n );\r\n if (match) {\r\n throw new Error(\r\n `The argument name \"${definition.argumentName}\" contains an invalid character \"${match[0]}\".` +\r\n ` Only upper-case letters, numbers, and underscores are allowed.`\r\n );\r\n }\r\n this.argumentName = definition.argumentName;\r\n this.completions = definition.completions;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"BaseClasses.js","sourceRoot":"","sources":["../../src/parameters/BaseClasses.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAQ3D;;;GAGG;AACH,IAAY,wBAeX;AAfD,WAAY,wBAAwB;IAClC,6CAA6C;IAC7C,2EAAM,CAAA;IACN,2CAA2C;IAC3C,uEAAI,CAAA;IACJ,8CAA8C;IAC9C,6EAAO,CAAA;IACP,6CAA6C;IAC7C,2EAAM,CAAA;IACN,iDAAiD;IACjD,mFAAU,CAAA;IACV,iDAAiD;IACjD,mFAAU,CAAA;IACV,kDAAkD;IAClD,qFAAW,CAAA;AACb,CAAC,EAfW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAenC;AAED;;;GAGG;AACH,MAAM,gBAAgB,GAAW,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,MAAM,iBAAiB,GAAW,aAAa,CAAC;AAEhD;;;GAGG;AACH,MAAM,YAAY,GAAW,0BAA0B,CAAC;AAExD;;;;;GAKG;AACH,MAAM,gCAAgC,GAAW,oBAAoB,CAAC;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,2DAA0B,GAAW,YAAY,CAAC;AAF7C,4EAAgC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { SCOPING_PARAMETER_GROUP } from '../Constants';\nimport type {\n IBaseCommandLineDefinition,\n IBaseCommandLineDefinitionWithArgument\n} from './CommandLineDefinition';\n\n/**\n * Identifies the kind of a CommandLineParameter.\n * @public\n */\nexport enum CommandLineParameterKind {\n /** Indicates a CommandLineChoiceParameter */\n Choice,\n /** Indicates a CommandLineFlagParameter */\n Flag,\n /** Indicates a CommandLineIntegerParameter */\n Integer,\n /** Indicates a CommandLineStringParameter */\n String,\n /** Indicates a CommandLineStringListParameter */\n StringList,\n /** Indicates a CommandLineChoiceListParameter */\n ChoiceList,\n /** Indicates a CommandLineIntegerListParameter */\n IntegerList\n}\n\n/**\n * Matches kebab-case formatted strings prefixed with double dashes.\n * Example: \"--do-something\"\n */\nconst LONG_NAME_REGEXP: RegExp = /^-(-[a-z0-9]+)+$/;\n\n/**\n * Matches a single upper-case or lower-case letter prefixed with a dash.\n * Example: \"-d\"\n */\nconst SHORT_NAME_REGEXP: RegExp = /^-[a-zA-Z]$/;\n\n/**\n * Matches kebab-case formatted strings\n * Example: \"my-scope\"\n */\nconst SCOPE_REGEXP: RegExp = /^[a-z0-9]+(-[a-z0-9]+)*$/;\n\n/**\n * \"Environment variable names used by the utilities in the Shell and Utilities volume of\n * IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore)\n * from the characters defined in Portable Character Set and do not begin with a digit.\"\n * Example: \"THE_SETTING\"\n */\nconst ENVIRONMENT_VARIABLE_NAME_REGEXP: RegExp = /^[A-Z_][A-Z0-9_]*$/;\n\n/**\n * The base class for the various command-line parameter types.\n * @public\n */\nexport abstract class CommandLineParameter {\n private _shortNameValue: string | undefined;\n\n /**\n * A unique internal key used to retrieve the value from the parser's dictionary.\n * @internal\n */\n public _parserKey: string | undefined;\n\n /** {@inheritDoc IBaseCommandLineDefinition.parameterLongName} */\n public readonly longName: string;\n\n /**\n * If a parameterScope is provided, returns the scope-prefixed long name of the flag,\n * including double dashes, eg. \"--scope:do-something\". Otherwise undefined.\n */\n public readonly scopedLongName: string | undefined;\n\n /** {@inheritDoc IBaseCommandLineDefinition.parameterGroup} */\n public readonly parameterGroup: string | typeof SCOPING_PARAMETER_GROUP | undefined;\n\n /** {@inheritDoc IBaseCommandLineDefinition.parameterScope} */\n public readonly parameterScope: string | undefined;\n\n /** {@inheritDoc IBaseCommandLineDefinition.description} */\n public readonly description: string;\n\n /** {@inheritDoc IBaseCommandLineDefinition.required} */\n public readonly required: boolean;\n\n /** {@inheritDoc IBaseCommandLineDefinition.environmentVariable} */\n public readonly environmentVariable: string | undefined;\n\n /** {@inheritDoc IBaseCommandLineDefinition.undocumentedSynonyms } */\n public readonly undocumentedSynonyms: string[] | undefined;\n\n /** @internal */\n public constructor(definition: IBaseCommandLineDefinition) {\n this.longName = definition.parameterLongName;\n this._shortNameValue = definition.parameterShortName;\n this.parameterGroup = definition.parameterGroup;\n this.parameterScope = definition.parameterScope;\n this.description = definition.description;\n this.required = !!definition.required;\n this.environmentVariable = definition.environmentVariable;\n this.undocumentedSynonyms = definition.undocumentedSynonyms;\n\n if (!LONG_NAME_REGEXP.test(this.longName)) {\n throw new Error(\n `Invalid name: \"${this.longName}\". The parameter long name must be` +\n ` lower-case and use dash delimiters (e.g. \"--do-a-thing\")`\n );\n }\n\n if (this.shortName) {\n if (!SHORT_NAME_REGEXP.test(this.shortName)) {\n throw new Error(\n `Invalid name: \"${this.shortName}\". The parameter short name must be` +\n ` a dash followed by a single upper-case or lower-case letter (e.g. \"-a\")`\n );\n }\n }\n\n if (this.parameterScope) {\n if (!SCOPE_REGEXP.test(this.parameterScope)) {\n throw new Error(\n `Invalid scope: \"${this.parameterScope}\". The parameter scope name must be` +\n ` lower-case and use dash delimiters (e.g. \"my-scope\")`\n );\n }\n // Parameter long name is guaranteed to start with '--' since this is validated above\n const unprefixedLongName: string = this.longName.slice(2);\n this.scopedLongName = `--${this.parameterScope}:${unprefixedLongName}`;\n }\n\n if (this.environmentVariable) {\n if (this.required) {\n // TODO: This constraint is imposed only because argparse enforces \"required\" parameters, but\n // it does not know about ts-command-line environment variable mappings. We should fix this.\n throw new Error(\n `An \"environmentVariable\" cannot be specified for \"${this.longName}\"` +\n ` because it is a required parameter`\n );\n }\n\n if (!ENVIRONMENT_VARIABLE_NAME_REGEXP.test(this.environmentVariable)) {\n throw new Error(\n `Invalid environment variable name: \"${this.environmentVariable}\". The name must` +\n ` consist only of upper-case letters, numbers, and underscores. It may not start with a number.`\n );\n }\n }\n\n if (this.undocumentedSynonyms && this.undocumentedSynonyms.length > 0) {\n for (const undocumentedSynonym of this.undocumentedSynonyms) {\n if (this.longName === undocumentedSynonym) {\n throw new Error(\n `Invalid name: \"${undocumentedSynonym}\". Undocumented synonyms must not be the same` +\n ` as the the long name.`\n );\n } else if (!LONG_NAME_REGEXP.test(undocumentedSynonym)) {\n throw new Error(\n `Invalid name: \"${undocumentedSynonym}\". All undocumented synonyms name must be lower-case and ` +\n 'use dash delimiters (e.g. \"--do-a-thing\")'\n );\n }\n }\n }\n }\n\n /** {@inheritDoc IBaseCommandLineDefinition.parameterShortName} */\n public get shortName(): string | undefined {\n return this._shortNameValue;\n }\n\n /**\n * Called internally by CommandLineParameterProvider._processParsedData()\n * @internal\n */\n public abstract _setValue(data: any): void; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n /**\n * Returns additional text used by the help formatter.\n * @internal\n */\n public _getSupplementaryNotes(supplementaryNotes: string[]): void {\n // virtual\n if (this.environmentVariable !== undefined) {\n supplementaryNotes.push(\n 'This parameter may alternatively be specified via the ' +\n this.environmentVariable +\n ' environment variable.'\n );\n }\n }\n\n /**\n * Indicates the type of parameter.\n */\n public abstract get kind(): CommandLineParameterKind;\n\n /**\n * Append the parsed values to the provided string array.\n * @remarks\n * Sometimes a command line parameter is not used directly, but instead gets passed through to another\n * tool that will use it. For example if our parameter comes in as \"--max-count 3\", then we might want to\n * call `child_process.spawn()` and append [\"--max-count\", \"3\"] to the args array for that tool.\n * appendToArgList() appends zero or more strings to the provided array, based on the input command-line\n * that we parsed.\n *\n * If the parameter was omitted from our command-line and has no default value, then\n * nothing will be appended. If the short name was used, the long name will be appended instead.\n * @param argList - the parsed strings will be appended to this string array\n */\n public abstract appendToArgList(argList: string[]): void;\n\n /**\n * Internal usage only. Used to report unexpected output from the argparse library.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected reportInvalidData(data: any): never {\n throw new Error(`Unexpected data object for parameter \"${this.longName}\": ` + JSON.stringify(data));\n }\n\n protected validateDefaultValue(hasDefaultValue: boolean): void {\n if (this.required && hasDefaultValue) {\n // If a parameter is \"required\", then the user understands that they always need to\n // specify a value for this parameter (either via the command line or via an environment variable).\n // It would be confusing to allow a default value that sometimes allows the \"required\" parameter\n // to be omitted. If you sometimes don't have a suitable default value, then the better approach\n // is to throw a custom error explaining why the parameter is required in that case.\n throw new Error(\n `A default value cannot be specified for \"${this.longName}\" because it is a \"required\" parameter`\n );\n }\n }\n}\n\n/**\n * The common base class for parameters types that receive an argument.\n *\n * @remarks\n * An argument is an accompanying command-line token, such as \"123\" in the\n * example \"--max-count 123\".\n * @public\n */\nexport abstract class CommandLineParameterWithArgument extends CommandLineParameter {\n // Matches the first character that *isn't* part of a valid upper-case argument name such as \"URL_2\"\n private static _invalidArgumentNameRegExp: RegExp = /[^A-Z_0-9]/;\n\n /** {@inheritDoc IBaseCommandLineDefinitionWithArgument.argumentName} */\n public readonly argumentName: string;\n\n /** {@inheritDoc IBaseCommandLineDefinitionWithArgument.completions} */\n public readonly completions: (() => Promise<string[]>) | undefined;\n\n /** @internal */\n public constructor(definition: IBaseCommandLineDefinitionWithArgument) {\n super(definition);\n\n if (definition.argumentName === '') {\n throw new Error(\n 'The argument name cannot be an empty string. (For the default name, specify undefined.)'\n );\n }\n if (definition.argumentName.toUpperCase() !== definition.argumentName) {\n throw new Error(\n `Invalid name: \"${definition.argumentName}\". The argument name must be all upper case.`\n );\n }\n const match: RegExpMatchArray | null = definition.argumentName.match(\n CommandLineParameterWithArgument._invalidArgumentNameRegExp\n );\n if (match) {\n throw new Error(\n `The argument name \"${definition.argumentName}\" contains an invalid character \"${match[0]}\".` +\n ` Only upper-case letters, numbers, and underscores are allowed.`\n );\n }\n this.argumentName = definition.argumentName;\n this.completions = definition.completions;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandLineChoiceListParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceListParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA+E;AAC/E,2EAAwE;AAExE;;;GAGG;AACH,MAAa,8BAA+B,SAAQ,kCAAoB;IAStE,gBAAgB;IAChB,YAAmB,UAA4C;QAC7D,KAAK,CAAC,UAAU,CAAC,CAAC;QAPZ,YAAO,GAAa,EAAE,CAAC;QAS7B,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;YACtC,MAAM,IAAI,KAAK,CACb,+FAA+F,CAChG,CAAC;SACH;QAED,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;QAC5C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;IAC5C,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,UAAU,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,qDAAqD;QACrD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACvC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACxB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC9B;YACD,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE;gBAC5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poration. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { ICommandLineChoiceListDefinition } from './CommandLineDefinition';\r\nimport { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';\r\nimport { EnvironmentVariableParser } from './EnvironmentVariableParser';\r\n\r\n/**\r\n * The data type returned by {@link CommandLineParameterProvider.defineChoiceListParameter}.\r\n * @public\r\n */\r\nexport class CommandLineChoiceListParameter extends CommandLineParameter {\r\n /** {@inheritDoc ICommandLineChoiceListDefinition.alternatives} */\r\n public readonly alternatives: ReadonlyArray<string>;\r\n\r\n private _values: string[] = [];\r\n\r\n /** {@inheritDoc ICommandLineChoiceListDefinition.completions} */\r\n public readonly completions: (() => Promise<string[]>) | undefined;\r\n\r\n /** @internal */\r\n public constructor(definition: ICommandLineChoiceListDefinition) {\r\n super(definition);\r\n\r\n if (definition.alternatives.length < 1) {\r\n throw new Error(\r\n `When defining a choice list parameter, the alternatives list must contain at least one value.`\r\n );\r\n }\r\n\r\n this.alternatives = definition.alternatives;\r\n this.completions = definition.completions;\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.kind} */\r\n public get kind(): CommandLineParameterKind {\r\n return CommandLineParameterKind.ChoiceList;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._setValue}\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n public _setValue(data: any): void {\r\n // If argparse passed us a value, confirm it is valid\r\n if (data !== null && data !== undefined) {\r\n if (!Array.isArray(data)) {\r\n this.reportInvalidData(data);\r\n }\r\n for (const arrayItem of data) {\r\n if (typeof arrayItem !== 'string') {\r\n this.reportInvalidData(data);\r\n }\r\n }\r\n this._values = data;\r\n return;\r\n }\r\n\r\n if (this.environmentVariable !== undefined) {\r\n const values: string[] | undefined = EnvironmentVariableParser.parseAsList(this.environmentVariable);\r\n if (values) {\r\n for (const value of values) {\r\n if (this.alternatives.indexOf(value) < 0) {\r\n const choices: string = '\"' + this.alternatives.join('\", \"') + '\"';\r\n throw new Error(\r\n `Invalid value \"${value}\" for the environment variable` +\r\n ` ${this.environmentVariable}. Valid choices are: ${choices}`\r\n );\r\n }\r\n }\r\n this._values = values;\r\n return;\r\n }\r\n }\r\n\r\n // (No default value for choice lists)\r\n\r\n this._values = [];\r\n }\r\n\r\n /**\r\n * Returns the string arguments for a choice list parameter that was parsed from the command line.\r\n *\r\n * @remarks\r\n * The array will be empty if the command-line has not been parsed yet,\r\n * or if the parameter was omitted and has no default value.\r\n */\r\n public get values(): ReadonlyArray<string> {\r\n return this._values;\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\r\n public appendToArgList(argList: string[]): void {\r\n if (this.values.length > 0) {\r\n for (const value of this.values) {\r\n argList.push(this.longName);\r\n argList.push(value);\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CommandLineChoiceListParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceListParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA+E;AAC/E,2EAAwE;AAExE;;;GAGG;AACH,MAAa,8BAA+B,SAAQ,kCAAoB;IAStE,gBAAgB;IAChB,YAAmB,UAA4C;QAC7D,KAAK,CAAC,UAAU,CAAC,CAAC;QAPZ,YAAO,GAAa,EAAE,CAAC;QAS7B,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;YACtC,MAAM,IAAI,KAAK,CACb,+FAA+F,CAChG,CAAC;SACH;QAED,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;QAC5C,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;IAC5C,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,UAAU,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,qDAAqD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,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC/B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrB;SACF;IACH,CAAC;CACF;AA1FD,wEA0FC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineChoiceListDefinition } from './CommandLineDefinition';\nimport { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';\nimport { EnvironmentVariableParser } from './EnvironmentVariableParser';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineChoiceListParameter}.\n * @public\n */\nexport class CommandLineChoiceListParameter extends CommandLineParameter {\n /** {@inheritDoc ICommandLineChoiceListDefinition.alternatives} */\n public readonly alternatives: ReadonlyArray<string>;\n\n private _values: string[] = [];\n\n /** {@inheritDoc ICommandLineChoiceListDefinition.completions} */\n public readonly completions: (() => Promise<string[]>) | undefined;\n\n /** @internal */\n public constructor(definition: ICommandLineChoiceListDefinition) {\n super(definition);\n\n if (definition.alternatives.length < 1) {\n throw new Error(\n `When defining a choice list parameter, the alternatives list must contain at least one value.`\n );\n }\n\n this.alternatives = definition.alternatives;\n this.completions = definition.completions;\n }\n\n /** {@inheritDoc CommandLineParameter.kind} */\n public get kind(): CommandLineParameterKind {\n return CommandLineParameterKind.ChoiceList;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // If argparse passed us a value, confirm it is valid\n if (data !== null && data !== undefined) {\n if (!Array.isArray(data)) {\n this.reportInvalidData(data);\n }\n for (const arrayItem of data) {\n if (typeof arrayItem !== 'string') {\n this.reportInvalidData(data);\n }\n }\n this._values = data;\n return;\n }\n\n if (this.environmentVariable !== undefined) {\n const values: string[] | undefined = EnvironmentVariableParser.parseAsList(this.environmentVariable);\n if (values) {\n for (const value of values) {\n if (this.alternatives.indexOf(value) < 0) {\n const choices: string = '\"' + this.alternatives.join('\", \"') + '\"';\n throw new Error(\n `Invalid value \"${value}\" for the environment variable` +\n ` ${this.environmentVariable}. Valid choices are: ${choices}`\n );\n }\n }\n this._values = values;\n return;\n }\n }\n\n // (No default value for choice lists)\n\n this._values = [];\n }\n\n /**\n * Returns the string arguments for a choice list parameter that was parsed from the command line.\n *\n * @remarks\n * The array will be empty if the command-line has not been parsed yet,\n * or if the parameter was omitted and has no default value.\n */\n public get values(): ReadonlyArray<string> {\n return this._values;\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.values.length > 0) {\n for (const value of this.values) {\n argList.push(this.longName);\n argList.push(value);\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandLineChoiceParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA+E;AAE/E;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,kCAAoB;IAYlE,gBAAgB;IAChB,YAAmB,UAAwC;QACzD,KAAK,CAAC,UAAU,CAAC,CAAC;QAPZ,WAAM,GAAuB,SAAS,CAAC;QAS7C,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;YACtC,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;SACH;QACD,IAAI,UAAU,CAAC,YAAY,IAAI,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE;YAC9F,MAAM,IAAI,KAAK,CACb,gCAAgC,UAAU,CAAC,YAAY,GAAG;gBACxD,yCAAyC,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,CAChF,CAAC;SACH;QAED,IAAI,CAAC,YAAY,GAAG,U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ACnC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;YAChC,OAAO;SACR;QAED,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,sBAAsB,CAAC,kBAA4B;QACxD,UAAU;QACV,KAAK,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;YACnC,kBAAkB,CAAC,IAAI,CAAC,yBAAyB,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC;SACzE;IACH,CAAC;IAED;;;;;;OAMG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1B;IACH,CAAC;CACF;AA5GD,gEA4GC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { ICommandLineChoiceDefinition } from './CommandLineDefinition';\r\nimport { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';\r\n\r\n/**\r\n * The data type returned by {@link CommandLineParameterProvider.defineChoiceParameter}.\r\n * @public\r\n */\r\nexport class CommandLineChoiceParameter extends CommandLineParameter {\r\n /** {@inheritDoc ICommandLineChoiceDefinition.alternatives} */\r\n public readonly alternatives: ReadonlyArray<string>;\r\n\r\n /** {@inheritDoc ICommandLineStringDefinition.defaultValue} */\r\n public readonly defaultValue: string | undefined;\r\n\r\n private _value: string | undefined = undefined;\r\n\r\n /** {@inheritDoc ICommandLineChoiceDefinition.completions} */\r\n public readonly completions: (() => Promise<string[]>) | undefined;\r\n\r\n /** @internal */\r\n public constructor(definition: ICommandLineChoiceDefinition) {\r\n super(definition);\r\n\r\n if (definition.alternatives.length < 1) {\r\n throw new Error(\r\n `When defining a choice parameter, the alternatives list must contain at least one value.`\r\n );\r\n }\r\n if (definition.defaultValue && definition.alternatives.indexOf(definition.defaultValue) === -1) {\r\n throw new Error(\r\n `The specified default value \"${definition.defaultValue}\"` +\r\n ` is not one of the available options: ${definition.alternatives.toString()}`\r\n );\r\n }\r\n\r\n this.alternatives = definition.alternatives;\r\n this.defaultValue = definition.defaultValue;\r\n this.validateDefaultValue(!!this.defaultValue);\r\n this.completions = definition.completions;\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.kind} */\r\n public get kind(): CommandLineParameterKind {\r\n return CommandLineParameterKind.Choice;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._setValue}\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n public _setValue(data: any): void {\r\n // abstract\r\n if (data !== null && data !== undefined) {\r\n if (typeof data !== 'string') {\r\n this.reportInvalidData(data);\r\n }\r\n this._value = data;\r\n return;\r\n }\r\n\r\n if (this.environmentVariable !== undefined) {\r\n // Try reading the environment variable\r\n const environmentValue: string | undefined = process.env[this.environmentVariable];\r\n if (environmentValue !== undefined && environmentValue !== '') {\r\n if (this.alternatives.indexOf(environmentValue) < 0) {\r\n const choices: string = '\"' + this.alternatives.join('\", \"') + '\"';\r\n throw new Error(\r\n `Invalid value \"${environmentValue}\" for the environment variable` +\r\n ` ${this.environmentVariable}. Valid choices are: ${choices}`\r\n );\r\n }\r\n this._value = environmentValue;\r\n return;\r\n }\r\n }\r\n\r\n if (this.defaultValue !== undefined) {\r\n this._value = this.defaultValue;\r\n return;\r\n }\r\n\r\n this._value = undefined;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._getSupplementaryNotes}\r\n * @internal\r\n */\r\n public _getSupplementaryNotes(supplementaryNotes: string[]): void {\r\n // virtual\r\n super._getSupplementaryNotes(supplementaryNotes);\r\n if (this.defaultValue !== undefined) {\r\n supplementaryNotes.push(`The default value is \"${this.defaultValue}\".`);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the argument value for a choice parameter that was parsed from the command line.\r\n *\r\n * @remarks\r\n * The return value will be `undefined` if the command-line has not been parsed yet,\r\n * or if the parameter was omitted and has no default value.\r\n */\r\n public get value(): string | undefined {\r\n return this._value;\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\r\n public appendToArgList(argList: string[]): void {\r\n if (this.value !== undefined) {\r\n argList.push(this.longName);\r\n argList.push(this.value);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CommandLineChoiceParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineChoiceParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA+E;AAE/E;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,kCAAoB;IAYlE,gBAAgB;IAChB,YAAmB,UAAwC;QACzD,KAAK,CAAC,UAAU,CAAC,CAAC;QAPZ,WAAM,GAAuB,SAAS,CAAC;QAS7C,IAAI,UAAU,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;YACtC,MAAM,IAAI,KAAK,CACb,0FAA0F,CAC3F,CAAC;SACH;QACD,IAAI,UAAU,CAAC,YAAY,IAAI,UAAU,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE;YAC9F,MAAM,IAAI,KAAK,CACb,gCAAgC,UAAU,CAAC,YAAY,GAAG;gBACxD,yCAAyC,UAAU,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,CAChF,CAAC;SACH;QAED,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;QAC5C,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;QAC5C,IAAI,CAAC,oBAAoB,CAAC,CA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1B,CAAC;IAED;;;OAGG;IACI,sBAAsB,CAAC,kBAA4B;QACxD,UAAU;QACV,KAAK,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;YACnC,kBAAkB,CAAC,IAAI,CAAC,yBAAyB,IAAI,CAAC,YAAY,IAAI,CAAC,CAAC;SACzE;IACH,CAAC;IAED;;;;;;OAMG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1B;IACH,CAAC;CACF;AA5GD,gEA4GC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineChoiceDefinition } from './CommandLineDefinition';\nimport { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineChoiceParameter}.\n * @public\n */\nexport class CommandLineChoiceParameter extends CommandLineParameter {\n /** {@inheritDoc ICommandLineChoiceDefinition.alternatives} */\n public readonly alternatives: ReadonlyArray<string>;\n\n /** {@inheritDoc ICommandLineStringDefinition.defaultValue} */\n public readonly defaultValue: string | undefined;\n\n private _value: string | undefined = undefined;\n\n /** {@inheritDoc ICommandLineChoiceDefinition.completions} */\n public readonly completions: (() => Promise<string[]>) | undefined;\n\n /** @internal */\n public constructor(definition: ICommandLineChoiceDefinition) {\n super(definition);\n\n if (definition.alternatives.length < 1) {\n throw new Error(\n `When defining a choice parameter, the alternatives list must contain at least one value.`\n );\n }\n if (definition.defaultValue && definition.alternatives.indexOf(definition.defaultValue) === -1) {\n throw new Error(\n `The specified default value \"${definition.defaultValue}\"` +\n ` is not one of the available options: ${definition.alternatives.toString()}`\n );\n }\n\n this.alternatives = definition.alternatives;\n this.defaultValue = definition.defaultValue;\n this.validateDefaultValue(!!this.defaultValue);\n this.completions = definition.completions;\n }\n\n /** {@inheritDoc CommandLineParameter.kind} */\n public get kind(): CommandLineParameterKind {\n return CommandLineParameterKind.Choice;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // abstract\n if (data !== null && data !== undefined) {\n if (typeof data !== 'string') {\n this.reportInvalidData(data);\n }\n this._value = data;\n return;\n }\n\n if (this.environmentVariable !== undefined) {\n // Try reading the environment variable\n const environmentValue: string | undefined = process.env[this.environmentVariable];\n if (environmentValue !== undefined && environmentValue !== '') {\n if (this.alternatives.indexOf(environmentValue) < 0) {\n const choices: string = '\"' + this.alternatives.join('\", \"') + '\"';\n throw new Error(\n `Invalid value \"${environmentValue}\" for the environment variable` +\n ` ${this.environmentVariable}. Valid choices are: ${choices}`\n );\n }\n this._value = environmentValue;\n return;\n }\n }\n\n if (this.defaultValue !== undefined) {\n this._value = this.defaultValue;\n return;\n }\n\n this._value = undefined;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._getSupplementaryNotes}\n * @internal\n */\n public _getSupplementaryNotes(supplementaryNotes: string[]): void {\n // virtual\n super._getSupplementaryNotes(supplementaryNotes);\n if (this.defaultValue !== undefined) {\n supplementaryNotes.push(`The default value is \"${this.defaultValue}\".`);\n }\n }\n\n /**\n * Returns the argument value for a choice parameter that was parsed from the command line.\n *\n * @remarks\n * The return value will be `undefined` if the command-line has not been parsed yet,\n * or if the parameter was omitted and has no default value.\n */\n public get value(): string | undefined {\n return this._value;\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.value !== undefined) {\n argList.push(this.longName);\n argList.push(this.value);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandLineDefinition.js","sourceRoot":"","sources":["../../src/parameters/CommandLineDefinition.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { SCOPING_PARAMETER_GROUP } from '../Constants';\r\n\r\n/**\r\n * For use with CommandLineParser, this interface represents a generic command-line parameter\r\n *\r\n * @public\r\n */\r\nexport interface IBaseCommandLineDefinition {\r\n /**\r\n * The long name of the flag including double dashes, e.g. \"--do-something\"\r\n */\r\n parameterLongName: string;\r\n\r\n /**\r\n * An optional short name for the flag including the dash, e.g. \"-d\"\r\n */\r\n parameterShortName?: string;\r\n\r\n /**\r\n * An optional parameter group name, shown when invoking the tool with \"--help\"\r\n */\r\n parameterGroup?: string | typeof SCOPING_PARAMETER_GROUP;\r\n\r\n /**\r\n * An optional parameter scope name, used to add a scope-prefixed parameter synonym,\r\n * e.g. \"--scope:do-something\". Scopes provide additional flexibility for parameters\r\n * in conflict resolution since when a scope is specified, parameters that have\r\n * conflicting long names will be defined using only the scope-prefixed name.\r\n */\r\n parameterScope?: string;\r\n\r\n /**\r\n * Documentation for the parameter that will be shown when invoking the tool with \"--help\"\r\n */\r\n description: string;\r\n\r\n /**\r\n * If true, then an error occurs if the parameter was not included on the command-line.\r\n */\r\n required?: boolean;\r\n\r\n /**\r\n * The name of an environment variable that the parameter value will be read from,\r\n * if it was omitted from the command-line. An error will be reported if the\r\n * environment value cannot be parsed.\r\n *\r\n * @remarks\r\n * The environment variable name must consist only of upper-case letters, numbers,\r\n * and underscores. It may not start with a number.\r\n *\r\n * This feature cannot be used when {@link IBaseCommandLineDefinition.required} is true,\r\n * because in that case the environmentVariable would never be used.\r\n *\r\n * Syntax notes for environment variable values:\r\n *\r\n * - Choice Parameter: The value must match one of the defined choices,\r\n * otherwise a validation error is reported.\r\n * An empty string causes the environment variable to be ignored.\r\n *\r\n * - Flag Parameter: The value must be `1` for true, or `0` for false,\r\n * otherwise a validation error is reported.\r\n * An empty string causes the environment variable to be ignored.\r\n *\r\n * - Integer Parameter: The value must be an integer number,\r\n * otherwise a validation error is reported.\r\n * An empty string causes the environment variable to be ignored.\r\n *\r\n * - String Parameter: Any value is accepted, including an empty string.\r\n *\r\n * - String List Parameter: If the string starts with `[` (ignoring whitespace)\r\n * then it will be parsed as a JSON array, whose elements must be strings,\r\n * numbers, or boolean values.\r\n * If the string does not start with `[`, then it behaves like an\r\n * ordinary String Parameter: Any value is accepted, including an empty string.\r\n */\r\n environmentVariable?: string;\r\n\r\n /**\r\n * Specifies additional names for this parameter that are accepted but not displayed\r\n * in the command line help.\r\n *\r\n * @remarks\r\n * This option can be used in cases where a command-line parameter may have been renamed,\r\n * but the developer doesn't want to break backwards compatibility with systems that may\r\n * still be using the old name. Only the `parameterLongName` syntax is currently allowed.\r\n */\r\n undocumentedSynonyms?: string[];\r\n}\r\n\r\n/**\r\n * The common base interface for parameter types that accept an argument.\r\n *\r\n * @remarks\r\n * An argument is an accompanying command-line token, such as \"123\" in the\r\n * example \"--max-count 123\".\r\n * @public\r\n */\r\nexport interface IBaseCommandLineDefinitionWithArgument extends IBaseCommandLineDefinition {\r\n /**\r\n * The name of the argument, which will be shown in the command-line help.\r\n *\r\n * @remarks\r\n * For example, if the parameter name is '--count\" and the argument name is \"NUMBER\",\r\n * then the command-line help would display \"--count NUMBER\". The argument name must\r\n * be comprised of upper-case letters, numbers, and underscores. It should be kept short.\r\n */\r\n argumentName: string;\r\n\r\n /**\r\n * An optional callback that provides a list of custom choices for tab completion.\r\n * @remarks\r\n * This option is only used when `ICommandLineParserOptions.enableTabCompletionAction`\r\n * is enabled.\r\n */\r\n completions?: () => Promise<string[]>;\r\n}\r\n\r\n/**\r\n * For use with {@link CommandLineParameterProvider.defineChoiceParameter},\r\n * this interface defines a command line parameter which is constrained to a list of possible\r\n * options.\r\n *\r\n * @public\r\n */\r\nexport interface ICommandLineChoiceDefinition extends IBaseCommandLineDefinition {\r\n /**\r\n * A list of strings (which contain no spaces), of possible options which can be selected\r\n */\r\n alternatives: string[];\r\n\r\n /**\r\n * {@inheritDoc ICommandLineStringDefinition.defaultValue}\r\n */\r\n defaultValue?: string;\r\n\r\n /**\r\n * An optional callback that provides a list of custom choices for tab completion.\r\n * @remarks\r\n * This option is only used when `ICommandLineParserOptions.enableTabCompletionAction`\r\n * is enabled.\r\n */\r\n completions?: () => Promise<string[]>;\r\n}\r\n\r\n/**\r\n * For use with {@link CommandLineParameterProvider.defineChoiceListParameter},\r\n * this interface defines a command line parameter which is constrained to a list of possible\r\n * options. The parameter can be specified multiple times to build a list.\r\n *\r\n * @public\r\n */\r\nexport interface ICommandLineChoiceListDefinition extends IBaseCommandLineDefinition {\r\n /**\r\n * A list of strings (which contain no spaces), of possible options which can be selected\r\n */\r\n alternatives: string[];\r\n\r\n /**\r\n * An optional callback that provides a list of custom choices for tab completion.\r\n * @remarks\r\n * This option is only used when `ICommandLineParserOptions.enableTabCompletionAction`\r\n * is enabled.\r\n */\r\n completions?: () => Promise<string[]>;\r\n}\r\n\r\n/**\r\n * For use with {@link CommandLineParameterProvider.defineFlagParameter},\r\n * this interface defines a command line parameter that is a boolean flag.\r\n *\r\n * @public\r\n */\r\nexport interface ICommandLineFlagDefinition extends IBaseCommandLineDefinition {}\r\n\r\n/**\r\n * For use with {@link CommandLineParameterProvider.defineIntegerParameter},\r\n * this interface defines a command line parameter whose argument is an integer value.\r\n *\r\n * @public\r\n */\r\nexport interface ICommandLineIntegerDefinition extends IBaseCommandLineDefinitionWithArgument {\r\n /**\r\n * {@inheritDoc ICommandLineStringDefinition.defaultValue}\r\n */\r\n defaultValue?: number;\r\n}\r\n\r\n/**\r\n * For use with {@link CommandLineParameterProvider.defineIntegerListParameter},\r\n * this interface defines a command line parameter whose argument is an integer value. The\r\n * parameter can be specified multiple times to build a list.\r\n *\r\n * @public\r\n */\r\nexport interface ICommandLineIntegerListDefinition extends IBaseCommandLineDefinitionWithArgument {}\r\n\r\n/**\r\n * For use with {@link CommandLineParameterProvider.defineStringParameter},\r\n * this interface defines a command line parameter whose argument is a string value.\r\n *\r\n * @public\r\n */\r\nexport interface ICommandLineStringDefinition extends IBaseCommandLineDefinitionWithArgument {\r\n /**\r\n * The default value which will be used if the parameter is omitted from the command line.\r\n *\r\n * @remarks\r\n * If a default value is specified, then {@link IBaseCommandLineDefinition.required}\r\n * must not be true. Instead, a custom error message should be used to report cases\r\n * where a default value was not available.\r\n */\r\n defaultValue?: string;\r\n}\r\n\r\n/**\r\n * For use with {@link CommandLineParameterProvider.defineStringListParameter},\r\n * this interface defines a command line parameter whose argument is a single text string.\r\n * The parameter can be specified multiple times to build a list.\r\n *\r\n * @public\r\n */\r\nexport interface ICommandLineStringListDefinition extends IBaseCommandLineDefinitionWithArgument {}\r\n\r\n/**\r\n * For use with {@link CommandLineParameterProvider.defineCommandLineRemainder},\r\n * this interface defines a rule that captures any remaining command line arguments after the recognized portion.\r\n *\r\n * @public\r\n */\r\nexport interface ICommandLineRemainderDefinition {\r\n /**\r\n * Documentation for how the remaining arguments will be used. This will be shown when invoking\r\n * the tool with \"--help\".\r\n */\r\n description: string;\r\n}\r\n"]}
1
+ {"version":3,"file":"CommandLineDefinition.js","sourceRoot":"","sources":["../../src/parameters/CommandLineDefinition.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { SCOPING_PARAMETER_GROUP } from '../Constants';\n\n/**\n * For use with CommandLineParser, this interface represents a generic command-line parameter\n *\n * @public\n */\nexport interface IBaseCommandLineDefinition {\n /**\n * The long name of the flag including double dashes, e.g. \"--do-something\"\n */\n parameterLongName: string;\n\n /**\n * An optional short name for the flag including the dash, e.g. \"-d\"\n */\n parameterShortName?: string;\n\n /**\n * An optional parameter group name, shown when invoking the tool with \"--help\"\n */\n parameterGroup?: string | typeof SCOPING_PARAMETER_GROUP;\n\n /**\n * An optional parameter scope name, used to add a scope-prefixed parameter synonym,\n * e.g. \"--scope:do-something\". Scopes provide additional flexibility for parameters\n * in conflict resolution since when a scope is specified, parameters that have\n * conflicting long names will be defined using only the scope-prefixed name.\n */\n parameterScope?: string;\n\n /**\n * Documentation for the parameter that will be shown when invoking the tool with \"--help\"\n */\n description: string;\n\n /**\n * If true, then an error occurs if the parameter was not included on the command-line.\n */\n required?: boolean;\n\n /**\n * The name of an environment variable that the parameter value will be read from,\n * if it was omitted from the command-line. An error will be reported if the\n * environment value cannot be parsed.\n *\n * @remarks\n * The environment variable name must consist only of upper-case letters, numbers,\n * and underscores. It may not start with a number.\n *\n * This feature cannot be used when {@link IBaseCommandLineDefinition.required} is true,\n * because in that case the environmentVariable would never be used.\n *\n * Syntax notes for environment variable values:\n *\n * - Choice Parameter: The value must match one of the defined choices,\n * otherwise a validation error is reported.\n * An empty string causes the environment variable to be ignored.\n *\n * - Flag Parameter: The value must be `1` for true, or `0` for false,\n * otherwise a validation error is reported.\n * An empty string causes the environment variable to be ignored.\n *\n * - Integer Parameter: The value must be an integer number,\n * otherwise a validation error is reported.\n * An empty string causes the environment variable to be ignored.\n *\n * - String Parameter: Any value is accepted, including an empty string.\n *\n * - String List Parameter: If the string starts with `[` (ignoring whitespace)\n * then it will be parsed as a JSON array, whose elements must be strings,\n * numbers, or boolean values.\n * If the string does not start with `[`, then it behaves like an\n * ordinary String Parameter: Any value is accepted, including an empty string.\n */\n environmentVariable?: string;\n\n /**\n * Specifies additional names for this parameter that are accepted but not displayed\n * in the command line help.\n *\n * @remarks\n * This option can be used in cases where a command-line parameter may have been renamed,\n * but the developer doesn't want to break backwards compatibility with systems that may\n * still be using the old name. Only the `parameterLongName` syntax is currently allowed.\n */\n undocumentedSynonyms?: string[];\n}\n\n/**\n * The common base interface for parameter types that accept an argument.\n *\n * @remarks\n * An argument is an accompanying command-line token, such as \"123\" in the\n * example \"--max-count 123\".\n * @public\n */\nexport interface IBaseCommandLineDefinitionWithArgument extends IBaseCommandLineDefinition {\n /**\n * The name of the argument, which will be shown in the command-line help.\n *\n * @remarks\n * For example, if the parameter name is '--count\" and the argument name is \"NUMBER\",\n * then the command-line help would display \"--count NUMBER\". The argument name must\n * be comprised of upper-case letters, numbers, and underscores. It should be kept short.\n */\n argumentName: string;\n\n /**\n * An optional callback that provides a list of custom choices for tab completion.\n * @remarks\n * This option is only used when `ICommandLineParserOptions.enableTabCompletionAction`\n * is enabled.\n */\n completions?: () => Promise<string[]>;\n}\n\n/**\n * For use with {@link CommandLineParameterProvider.defineChoiceParameter},\n * this interface defines a command line parameter which is constrained to a list of possible\n * options.\n *\n * @public\n */\nexport interface ICommandLineChoiceDefinition extends IBaseCommandLineDefinition {\n /**\n * A list of strings (which contain no spaces), of possible options which can be selected\n */\n alternatives: string[];\n\n /**\n * {@inheritDoc ICommandLineStringDefinition.defaultValue}\n */\n defaultValue?: string;\n\n /**\n * An optional callback that provides a list of custom choices for tab completion.\n * @remarks\n * This option is only used when `ICommandLineParserOptions.enableTabCompletionAction`\n * is enabled.\n */\n completions?: () => Promise<string[]>;\n}\n\n/**\n * For use with {@link CommandLineParameterProvider.defineChoiceListParameter},\n * this interface defines a command line parameter which is constrained to a list of possible\n * options. The parameter can be specified multiple times to build a list.\n *\n * @public\n */\nexport interface ICommandLineChoiceListDefinition extends IBaseCommandLineDefinition {\n /**\n * A list of strings (which contain no spaces), of possible options which can be selected\n */\n alternatives: string[];\n\n /**\n * An optional callback that provides a list of custom choices for tab completion.\n * @remarks\n * This option is only used when `ICommandLineParserOptions.enableTabCompletionAction`\n * is enabled.\n */\n completions?: () => Promise<string[]>;\n}\n\n/**\n * For use with {@link CommandLineParameterProvider.defineFlagParameter},\n * this interface defines a command line parameter that is a boolean flag.\n *\n * @public\n */\nexport interface ICommandLineFlagDefinition extends IBaseCommandLineDefinition {}\n\n/**\n * For use with {@link CommandLineParameterProvider.defineIntegerParameter},\n * this interface defines a command line parameter whose argument is an integer value.\n *\n * @public\n */\nexport interface ICommandLineIntegerDefinition extends IBaseCommandLineDefinitionWithArgument {\n /**\n * {@inheritDoc ICommandLineStringDefinition.defaultValue}\n */\n defaultValue?: number;\n}\n\n/**\n * For use with {@link CommandLineParameterProvider.defineIntegerListParameter},\n * this interface defines a command line parameter whose argument is an integer value. The\n * parameter can be specified multiple times to build a list.\n *\n * @public\n */\nexport interface ICommandLineIntegerListDefinition extends IBaseCommandLineDefinitionWithArgument {}\n\n/**\n * For use with {@link CommandLineParameterProvider.defineStringParameter},\n * this interface defines a command line parameter whose argument is a string value.\n *\n * @public\n */\nexport interface ICommandLineStringDefinition extends IBaseCommandLineDefinitionWithArgument {\n /**\n * The default value which will be used if the parameter is omitted from the command line.\n *\n * @remarks\n * If a default value is specified, then {@link IBaseCommandLineDefinition.required}\n * must not be true. Instead, a custom error message should be used to report cases\n * where a default value was not available.\n */\n defaultValue?: string;\n}\n\n/**\n * For use with {@link CommandLineParameterProvider.defineStringListParameter},\n * this interface defines a command line parameter whose argument is a single text string.\n * The parameter can be specified multiple times to build a list.\n *\n * @public\n */\nexport interface ICommandLineStringListDefinition extends IBaseCommandLineDefinitionWithArgument {}\n\n/**\n * For use with {@link CommandLineParameterProvider.defineCommandLineRemainder},\n * this interface defines a rule that captures any remaining command line arguments after the recognized portion.\n *\n * @public\n */\nexport interface ICommandLineRemainderDefinition {\n /**\n * Documentation for how the remaining arguments will be used. This will be shown when invoking\n * the tool with \"--help\".\n */\n description: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandLineFlagParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineFlagParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA+E;AAE/E;;;GAGG;AACH,MAAa,wBAAyB,SAAQ,kCAAoB;IAGhE,gBAAgB;IAChB,YAAmB,UAAsC;QACvD,KAAK,C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QAAQ,CAAC,CAAC;SAC7B;IACH,CAAC;CACF;AArED,4DAqEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { ICommandLineFlagDefinition } from './CommandLineDefinition';\r\nimport { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';\r\n\r\n/**\r\n * The data type returned by {@link CommandLineParameterProvider.defineFlagParameter}.\r\n * @public\r\n */\r\nexport class CommandLineFlagParameter extends CommandLineParameter {\r\n private _value: boolean = false;\r\n\r\n /** @internal */\r\n public constructor(definition: ICommandLineFlagDefinition) {\r\n super(definition);\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.kind} */\r\n public get kind(): CommandLineParameterKind {\r\n return CommandLineParameterKind.Flag;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._setValue}\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n public _setValue(data: any): void {\r\n // abstract\r\n if (data !== null && data !== undefined) {\r\n if (typeof data !== 'boolean') {\r\n this.reportInvalidData(data);\r\n }\r\n\r\n // If the flag is omitted, then argparse sets the data to \"false\" instead of \"undefined\".\r\n // This design prevents a syntax such as \"--flag=false\", probably because argparse prefers \"--no-flag\".\r\n // If we switch to a new CLI parser, we should try to add support for \"--flag=false\".\r\n if (data) {\r\n this._value = data;\r\n return;\r\n }\r\n }\r\n\r\n if (this.environmentVariable !== undefined) {\r\n // Try reading the environment variable\r\n const environmentValue: string | undefined = process.env[this.environmentVariable];\r\n if (environmentValue !== undefined && environmentValue !== '') {\r\n if (environmentValue !== '0' && environmentValue !== '1') {\r\n throw new Error(\r\n `Invalid value \"${environmentValue}\" for the environment variable` +\r\n ` ${this.environmentVariable}. Valid choices are 0 or 1.`\r\n );\r\n }\r\n this._value = environmentValue === '1';\r\n return;\r\n }\r\n }\r\n\r\n this._value = false;\r\n }\r\n\r\n /**\r\n * Returns a boolean indicating whether the parameter was included in the command line.\r\n *\r\n * @remarks\r\n * The return value will be false if the command-line has not been parsed yet,\r\n * or if the flag was not used.\r\n */\r\n public get value(): boolean {\r\n return this._value;\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\r\n public appendToArgList(argList: string[]): void {\r\n if (this.value) {\r\n argList.push(this.longName);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CommandLineFlagParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineFlagParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA+E;AAE/E;;;GAGG;AACH,MAAa,wBAAyB,SAAQ,kCAAoB;IAGhE,gBAAgB;IAChB,YAAmB,UAAsC;QACvD,KAAK,CAAC,UAAU,CAAC,CAAC;QAJZ,WAAM,GAAY,KAAK,CAAC;IAKhC,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,IAAI,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,WAAW;QACX,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACvC,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE;gBAC7B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC9B;YAED,yFAAyF;YACzF,uGAAuG;YACvG,qFAAqF;YACrF,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;gBACnB,OAAO;aACR;SACF;QAED,IAAI,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE;YAC1C,uCAAuC;YACvC,MAAM,gBAAgB,GAAuB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACnF,IAAI,gBAAgB,KAAK,SAAS,IAAI,gBAAgB,KAAK,EAAE,EAAE;gBAC7D,IAAI,gBAAgB,KAAK,GAAG,IAAI,gBAAgB,KAAK,GAAG,EAAE;oBACxD,MAAM,IAAI,KAAK,CACb,kBAAkB,gBAAgB,gCAAgC;wBAChE,IAAI,IAAI,CAAC,mBAAmB,8BAA8B,CAC7D,CAAC;iBACH;gBACD,IAAI,CAAC,MAAM,GAAG,gBAAgB,KAAK,GAAG,CAAC;gBACvC,OAAO;aACR;SACF;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;;;OAMG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC7B;IACH,CAAC;CACF;AArED,4DAqEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineFlagDefinition } from './CommandLineDefinition';\nimport { CommandLineParameter, CommandLineParameterKind } from './BaseClasses';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineFlagParameter}.\n * @public\n */\nexport class CommandLineFlagParameter extends CommandLineParameter {\n private _value: boolean = false;\n\n /** @internal */\n public constructor(definition: ICommandLineFlagDefinition) {\n super(definition);\n }\n\n /** {@inheritDoc CommandLineParameter.kind} */\n public get kind(): CommandLineParameterKind {\n return CommandLineParameterKind.Flag;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // abstract\n if (data !== null && data !== undefined) {\n if (typeof data !== 'boolean') {\n this.reportInvalidData(data);\n }\n\n // If the flag is omitted, then argparse sets the data to \"false\" instead of \"undefined\".\n // This design prevents a syntax such as \"--flag=false\", probably because argparse prefers \"--no-flag\".\n // If we switch to a new CLI parser, we should try to add support for \"--flag=false\".\n if (data) {\n this._value = data;\n return;\n }\n }\n\n if (this.environmentVariable !== undefined) {\n // Try reading the environment variable\n const environmentValue: string | undefined = process.env[this.environmentVariable];\n if (environmentValue !== undefined && environmentValue !== '') {\n if (environmentValue !== '0' && environmentValue !== '1') {\n throw new Error(\n `Invalid value \"${environmentValue}\" for the environment variable` +\n ` ${this.environmentVariable}. Valid choices are 0 or 1.`\n );\n }\n this._value = environmentValue === '1';\n return;\n }\n }\n\n this._value = false;\n }\n\n /**\n * Returns a boolean indicating whether the parameter was included in the command line.\n *\n * @remarks\n * The return value will be false if the command-line has not been parsed yet,\n * or if the flag was not used.\n */\n public get value(): boolean {\n return this._value;\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.value) {\n argList.push(this.longName);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandLineIntegerListParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineIntegerListParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA2F;AAC3F,2EAAwE;AAExE;;;GAGG;AACH,MAAa,+BAAgC,SAAQ,8CAAgC;IAGnF,gBAAgB;IAChB,YAAmB,UAA6C;QAC9D,KAAK,CAAC,UAAU,CAAC,CAAC;QAJZ,YAAO,GAAa,EAAE,CAAC;IAK/B,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,WAAW,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,qDAAqD;QACrD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACvC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACxB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC9B;YACD,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE;gBAC5B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QAAQ,EAAE,CAAC,CAAC;aAChC;SACF;IACH,CAAC;CACF;AA9ED,0EA8EC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { ICommandLineIntegerListDefinition } from './CommandLineDefinition';\r\nimport { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';\r\nimport { EnvironmentVariableParser } from './EnvironmentVariableParser';\r\n\r\n/**\r\n * The data type returned by {@link CommandLineParameterProvider.defineIntegerListParameter}.\r\n * @public\r\n */\r\nexport class CommandLineIntegerListParameter extends CommandLineParameterWithArgument {\r\n private _values: number[] = [];\r\n\r\n /** @internal */\r\n public constructor(definition: ICommandLineIntegerListDefinition) {\r\n super(definition);\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.kind} */\r\n public get kind(): CommandLineParameterKind {\r\n return CommandLineParameterKind.IntegerList;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._setValue}\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n public _setValue(data: any): void {\r\n // If argparse passed us a value, confirm it is valid\r\n if (data !== null && data !== undefined) {\r\n if (!Array.isArray(data)) {\r\n this.reportInvalidData(data);\r\n }\r\n for (const arrayItem of data) {\r\n if (typeof arrayItem !== 'number') {\r\n this.reportInvalidData(data);\r\n }\r\n }\r\n this._values = data;\r\n return;\r\n }\r\n\r\n // If an environment variable exists, attempt to parse it as a list\r\n if (this.environmentVariable !== undefined) {\r\n const values: string[] | undefined = EnvironmentVariableParser.parseAsList(this.environmentVariable);\r\n if (values) {\r\n const parsedValues: number[] = [];\r\n for (const value of values) {\r\n const parsed: number = parseInt(value, 10);\r\n if (isNaN(parsed) || value.indexOf('.') >= 0) {\r\n throw new Error(\r\n `Invalid value \"${value}\" for the environment variable` +\r\n ` ${this.environmentVariable}. It must be an integer value.`\r\n );\r\n }\r\n parsedValues.push(parsed);\r\n }\r\n this._values = parsedValues;\r\n return;\r\n }\r\n }\r\n\r\n // (No default value for integer lists)\r\n\r\n this._values = [];\r\n }\r\n\r\n /**\r\n * Returns the integer arguments for an integer list parameter that was parsed from the command line.\r\n *\r\n * @remarks\r\n * The array will be empty if the command-line has not been parsed yet,\r\n * or if the parameter was omitted and has no default value.\r\n */\r\n public get values(): ReadonlyArray<number> {\r\n return this._values;\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\r\n public appendToArgList(argList: string[]): void {\r\n if (this.values.length > 0) {\r\n for (const value of this.values) {\r\n argList.push(this.longName);\r\n argList.push(value.toString());\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CommandLineIntegerListParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineIntegerListParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA2F;AAC3F,2EAAwE;AAExE;;;GAGG;AACH,MAAa,+BAAgC,SAAQ,8CAAgC;IAGnF,gBAAgB;IAChB,YAAmB,UAA6C;QAC9D,KAAK,CAAC,UAAU,CAAC,CAAC;QAJZ,YAAO,GAAa,EAAE,CAAC;IAK/B,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,WAAW,CAAC;IAC9C,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,qDAAqD;QACrD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACvC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACxB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC9B;YACD,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE;gBAC5B,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;oBACjC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;iBAC9B;aACF;YACD,IAAI,CA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T license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineIntegerListDefinition } from './CommandLineDefinition';\nimport { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';\nimport { EnvironmentVariableParser } from './EnvironmentVariableParser';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineIntegerListParameter}.\n * @public\n */\nexport class CommandLineIntegerListParameter extends CommandLineParameterWithArgument {\n private _values: number[] = [];\n\n /** @internal */\n public constructor(definition: ICommandLineIntegerListDefinition) {\n super(definition);\n }\n\n /** {@inheritDoc CommandLineParameter.kind} */\n public get kind(): CommandLineParameterKind {\n return CommandLineParameterKind.IntegerList;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // If argparse passed us a value, confirm it is valid\n if (data !== null && data !== undefined) {\n if (!Array.isArray(data)) {\n this.reportInvalidData(data);\n }\n for (const arrayItem of data) {\n if (typeof arrayItem !== 'number') {\n this.reportInvalidData(data);\n }\n }\n this._values = data;\n return;\n }\n\n // If an environment variable exists, attempt to parse it as a list\n if (this.environmentVariable !== undefined) {\n const values: string[] | undefined = EnvironmentVariableParser.parseAsList(this.environmentVariable);\n if (values) {\n const parsedValues: number[] = [];\n for (const value of values) {\n const parsed: number = parseInt(value, 10);\n if (isNaN(parsed) || value.indexOf('.') >= 0) {\n throw new Error(\n `Invalid value \"${value}\" for the environment variable` +\n ` ${this.environmentVariable}. It must be an integer value.`\n );\n }\n parsedValues.push(parsed);\n }\n this._values = parsedValues;\n return;\n }\n }\n\n // (No default value for integer lists)\n\n this._values = [];\n }\n\n /**\n * Returns the integer arguments for an integer list parameter that was parsed from the command line.\n *\n * @remarks\n * The array will be empty if the command-line has not been parsed yet,\n * or if the parameter was omitted and has no default value.\n */\n public get values(): ReadonlyArray<number> {\n return this._values;\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.values.length > 0) {\n for (const value of this.values) {\n argList.push(this.longName);\n argList.push(value.toString());\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandLineIntegerParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineIntegerParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA2F;AAE3F;;;GAGG;AACH,MAAa,2BAA4B,SAAQ,8CAAgC;IAM/E,gBAAgB;IAChB,YAAmB,UAAyC;QAC1D,KAAK,CAAC,UAAU,CAAC,CAAC;QAJZ,WAAM,GAAuB,SAAS,CAAC;QAK7C,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;QAC5C,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,OAAO,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,WAAW;QACX,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACvC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;gBAC5B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC9B;YACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,OAAO;SACR;QAED,IAAI,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE;YAC1C,uCAAuC;YACvC,MAAM,gBAAgB,GAAuB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACnF,IAAI,gBAAgB,KAAK,SAAS,IAAI,gBAAgB,KAAK,EAAE,EAAE;gBAC7D,MAAM,MAAM,GAAW,QAAQ,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;gBACtD,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;oBACvD,MAAM,IAAI,KAAK,CACb,kBAAkB,gBAAgB,gCAAgC;wBAChE,IAAI,IAAI,CAAC,mBAAmB,iCAAiC,CAChE,CAAC;iBACH;gBACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;gBACrB,OAAO;aACR;SACF;QAED,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;YACnC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;YAChC,OAAO;SACR;QAED,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,sBAAsB,CAAC,kBAA4B;QACxD,UAAU;QACV,KAAK,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;YACnC,kBAAkB,CAAC,IAAI,CAAC,wBAAwB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;SACvE;IACH,CAAC;IAED;;;;;;OAMG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;SACrC;IACH,CAAC;CACF;AAvFD,kEAuFC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { ICommandLineIntegerDefinition } from './CommandLineDefinition';\r\nimport { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';\r\n\r\n/**\r\n * The data type returned by {@link CommandLineParameterProvider.defineIntegerParameter}.\r\n * @public\r\n */\r\nexport class CommandLineIntegerParameter extends CommandLineParameterWithArgument {\r\n /** {@inheritDoc ICommandLineStringDefinition.defaultValue} */\r\n public readonly defaultValue: number | undefined;\r\n\r\n private _value: number | undefined = undefined;\r\n\r\n /** @internal */\r\n public constructor(definition: ICommandLineIntegerDefinition) {\r\n super(definition);\r\n this.defaultValue = definition.defaultValue;\r\n this.validateDefaultValue(!!this.defaultValue);\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.kind} */\r\n public get kind(): CommandLineParameterKind {\r\n return CommandLineParameterKind.Integer;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._setValue}\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n public _setValue(data: any): void {\r\n // abstract\r\n if (data !== null && data !== undefined) {\r\n if (typeof data !== 'number') {\r\n this.reportInvalidData(data);\r\n }\r\n this._value = data;\r\n return;\r\n }\r\n\r\n if (this.environmentVariable !== undefined) {\r\n // Try reading the environment variable\r\n const environmentValue: string | undefined = process.env[this.environmentVariable];\r\n if (environmentValue !== undefined && environmentValue !== '') {\r\n const parsed: number = parseInt(environmentValue, 10);\r\n if (isNaN(parsed) || environmentValue.indexOf('.') >= 0) {\r\n throw new Error(\r\n `Invalid value \"${environmentValue}\" for the environment variable` +\r\n ` ${this.environmentVariable}. It must be an integer value.`\r\n );\r\n }\r\n this._value = parsed;\r\n return;\r\n }\r\n }\r\n\r\n if (this.defaultValue !== undefined) {\r\n this._value = this.defaultValue;\r\n return;\r\n }\r\n\r\n this._value = undefined;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._getSupplementaryNotes}\r\n * @internal\r\n */\r\n public _getSupplementaryNotes(supplementaryNotes: string[]): void {\r\n // virtual\r\n super._getSupplementaryNotes(supplementaryNotes);\r\n if (this.defaultValue !== undefined) {\r\n supplementaryNotes.push(`The default value is ${this.defaultValue}.`);\r\n }\r\n }\r\n\r\n /**\r\n * Returns the argument value for an integer parameter that was parsed from the command line.\r\n *\r\n * @remarks\r\n * The return value will be undefined if the command-line has not been parsed yet,\r\n * or if the parameter was omitted and has no default value.\r\n */\r\n public get value(): number | undefined {\r\n return this._value;\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\r\n public appendToArgList(argList: string[]): void {\r\n if (this.value !== undefined) {\r\n argList.push(this.longName);\r\n argList.push(this.value.toString());\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CommandLineIntegerParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineIntegerParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA2F;AAE3F;;;GAGG;AACH,MAAa,2BAA4B,SAAQ,8CAAgC;IAM/E,gBAAgB;IAChB,YAAmB,UAAyC;QAC1D,KAAK,CAAC,UAAU,CAAC,CAAC;QAJZ,WAAM,GAAuB,SAAS,CAAC;QAK7C,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,CAAC;QAC5C,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,OAAO,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,WAAW;QACX,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACvC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;gBAC5B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC9B;YACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,OAAO;SACR;QAED,IAAI,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE;YAC1C,uCAAuC;YACvC,MAAM,gBAAgB,GAAuB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,C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served. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineIntegerDefinition } from './CommandLineDefinition';\nimport { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineIntegerParameter}.\n * @public\n */\nexport class CommandLineIntegerParameter extends CommandLineParameterWithArgument {\n /** {@inheritDoc ICommandLineStringDefinition.defaultValue} */\n public readonly defaultValue: number | undefined;\n\n private _value: number | undefined = undefined;\n\n /** @internal */\n public constructor(definition: ICommandLineIntegerDefinition) {\n super(definition);\n this.defaultValue = definition.defaultValue;\n this.validateDefaultValue(!!this.defaultValue);\n }\n\n /** {@inheritDoc CommandLineParameter.kind} */\n public get kind(): CommandLineParameterKind {\n return CommandLineParameterKind.Integer;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // abstract\n if (data !== null && data !== undefined) {\n if (typeof data !== 'number') {\n this.reportInvalidData(data);\n }\n this._value = data;\n return;\n }\n\n if (this.environmentVariable !== undefined) {\n // Try reading the environment variable\n const environmentValue: string | undefined = process.env[this.environmentVariable];\n if (environmentValue !== undefined && environmentValue !== '') {\n const parsed: number = parseInt(environmentValue, 10);\n if (isNaN(parsed) || environmentValue.indexOf('.') >= 0) {\n throw new Error(\n `Invalid value \"${environmentValue}\" for the environment variable` +\n ` ${this.environmentVariable}. It must be an integer value.`\n );\n }\n this._value = parsed;\n return;\n }\n }\n\n if (this.defaultValue !== undefined) {\n this._value = this.defaultValue;\n return;\n }\n\n this._value = undefined;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._getSupplementaryNotes}\n * @internal\n */\n public _getSupplementaryNotes(supplementaryNotes: string[]): void {\n // virtual\n super._getSupplementaryNotes(supplementaryNotes);\n if (this.defaultValue !== undefined) {\n supplementaryNotes.push(`The default value is ${this.defaultValue}.`);\n }\n }\n\n /**\n * Returns the argument value for an integer parameter that was parsed from the command line.\n *\n * @remarks\n * The return value will be undefined if the command-line has not been parsed yet,\n * or if the parameter was omitted and has no default value.\n */\n public get value(): number | undefined {\n return this._value;\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.value !== undefined) {\n argList.push(this.longName);\n argList.push(this.value.toString());\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandLineRemainder.js","sourceRoot":"","sources":["../../src/parameters/CommandLineRemainder.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D;;;GAGG;AACH,MAAa,oBAAoB;IAM/B,gBAAgB;IAChB,YAAmB,UAA2C;QANtD,YAAO,GAAa,EAAE,CAAC;QAO7B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;IAC5C,CAAC;IAED;;;;;;OAMG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,WAAW;QACX,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,EAAE;YACrE,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;SAClF;QAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC/B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrB;SACF;IACH,CAAC;CACF;AA5CD,oDA4CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { ICommandLineRemainderDefinition } from './CommandLineDefinition';\r\n\r\n/**\r\n * The data type returned by {@link CommandLineParameterProvider.defineCommandLineRemainder}.\r\n * @public\r\n */\r\nexport class CommandLineRemainder {\r\n private _values: string[] = [];\r\n\r\n /** {@inheritDoc IBaseCommandLineDefinition.description} */\r\n public readonly description: string;\r\n\r\n /** @internal */\r\n public constructor(definition: ICommandLineRemainderDefinition) {\r\n this.description = definition.description;\r\n }\r\n\r\n /**\r\n * Returns any remaining command line arguments after the recognized portion\r\n * that was parsed from the command line.\r\n *\r\n * @remarks\r\n * The array will be empty if the command-line has not been parsed yet.\r\n */\r\n public get values(): ReadonlyArray<string> {\r\n return this._values;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._setValue}\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n public _setValue(data: any): void {\r\n // abstract\r\n if (!Array.isArray(data) || !data.every((x) => typeof x === 'string')) {\r\n throw new Error(`Unexpected data object for remainder: ` + JSON.stringify(data));\r\n }\r\n\r\n this._values.push(...data);\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\r\n public appendToArgList(argList: string[]): void {\r\n if (this.values.length > 0) {\r\n for (const value of this.values) {\r\n argList.push(value);\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CommandLineRemainder.js","sourceRoot":"","sources":["../../src/parameters/CommandLineRemainder.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D;;;GAGG;AACH,MAAa,oBAAoB;IAM/B,gBAAgB;IAChB,YAAmB,UAA2C;QANtD,YAAO,GAAa,EAAE,CAAC;QAO7B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC;IAC5C,CAAC;IAED;;;;;;OAMG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,WAAW;QACX,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,EAAE;YACrE,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;SAClF;QAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC/B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrB;SACF;IACH,CAAC;CACF;AA5CD,oDA4CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineRemainderDefinition } from './CommandLineDefinition';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineCommandLineRemainder}.\n * @public\n */\nexport class CommandLineRemainder {\n private _values: string[] = [];\n\n /** {@inheritDoc IBaseCommandLineDefinition.description} */\n public readonly description: string;\n\n /** @internal */\n public constructor(definition: ICommandLineRemainderDefinition) {\n this.description = definition.description;\n }\n\n /**\n * Returns any remaining command line arguments after the recognized portion\n * that was parsed from the command line.\n *\n * @remarks\n * The array will be empty if the command-line has not been parsed yet.\n */\n public get values(): ReadonlyArray<string> {\n return this._values;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // abstract\n if (!Array.isArray(data) || !data.every((x) => typeof x === 'string')) {\n throw new Error(`Unexpected data object for remainder: ` + JSON.stringify(data));\n }\n\n this._values.push(...data);\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.values.length > 0) {\n for (const value of this.values) {\n argList.push(value);\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandLineStringListParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineStringListParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA2F;AAC3F,2EAAwE;AAExE;;;GAGG;AACH,MAAa,8BAA+B,SAAQ,8CAAgC;IAGlF,gBAAgB;IAChB,YAAmB,UAA4C;QAC7D,KAAK,CAAC,UAAU,CAAC,CAAC;QAJZ,YAAO,GAAa,EAAE,CAAC;IAK/B,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,UAAU,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,qDAAqD;QACrD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACvC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACxB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC9B;YACD,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE;gBAC5B,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;oBACjC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;iBAC9B;aACF;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,OAAO;SACR;QAED,mEAAmE;QACnE,IAAI,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE;YAC1C,MAAM,MAAM,GAAyB,qDAAyB,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACrG,IAAI,MAAM,EAAE;gBACV,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;gBACtB,OAAO;aACR;SACF;QAED,sCAAsC;QAEtC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC/B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrB;SACF;IACH,CAAC;CACF;AAnED,wEAmEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { ICommandLineStringListDefinition } from './CommandLineDefinition';\r\nimport { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';\r\nimport { EnvironmentVariableParser } from './EnvironmentVariableParser';\r\n\r\n/**\r\n * The data type returned by {@link CommandLineParameterProvider.defineStringListParameter}.\r\n * @public\r\n */\r\nexport class CommandLineStringListParameter extends CommandLineParameterWithArgument {\r\n private _values: string[] = [];\r\n\r\n /** @internal */\r\n public constructor(definition: ICommandLineStringListDefinition) {\r\n super(definition);\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.kind} */\r\n public get kind(): CommandLineParameterKind {\r\n return CommandLineParameterKind.StringList;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._setValue}\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n public _setValue(data: any): void {\r\n // If argparse passed us a value, confirm it is valid\r\n if (data !== null && data !== undefined) {\r\n if (!Array.isArray(data)) {\r\n this.reportInvalidData(data);\r\n }\r\n for (const arrayItem of data) {\r\n if (typeof arrayItem !== 'string') {\r\n this.reportInvalidData(data);\r\n }\r\n }\r\n this._values = data;\r\n return;\r\n }\r\n\r\n // If an environment variable exists, attempt to parse it as a list\r\n if (this.environmentVariable !== undefined) {\r\n const values: string[] | undefined = EnvironmentVariableParser.parseAsList(this.environmentVariable);\r\n if (values) {\r\n this._values = values;\r\n return;\r\n }\r\n }\r\n\r\n // (No default value for string lists)\r\n\r\n this._values = [];\r\n }\r\n\r\n /**\r\n * Returns the string arguments for a string list parameter that was parsed from the command line.\r\n *\r\n * @remarks\r\n * The array will be empty if the command-line has not been parsed yet,\r\n * or if the parameter was omitted and has no default value.\r\n */\r\n public get values(): ReadonlyArray<string> {\r\n return this._values;\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\r\n public appendToArgList(argList: string[]): void {\r\n if (this.values.length > 0) {\r\n for (const value of this.values) {\r\n argList.push(this.longName);\r\n argList.push(value);\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CommandLineStringListParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineStringListParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA2F;AAC3F,2EAAwE;AAExE;;;GAGG;AACH,MAAa,8BAA+B,SAAQ,8CAAgC;IAGlF,gBAAgB;IAChB,YAAmB,UAA4C;QAC7D,KAAK,CAAC,UAAU,CAAC,CAAC;QAJZ,YAAO,GAAa,EAAE,CAAC;IAK/B,CAAC;IAED,8CAA8C;IAC9C,IAAW,IAAI;QACb,OAAO,sCAAwB,CAAC,UAAU,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACH,8DAA8D;IACvD,SAAS,CAAC,IAAS;QACxB,qDAAqD;QACrD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACvC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACxB,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;aAC9B;YACD,KAAK,MAAM,SAAS,IAAI,IAAI,EAAE;gBAC5B,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;oBACjC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;iBAC9B;aACF;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,OAAO;SACR;QAED,mEAAmE;QACnE,IAAI,IAAI,CAAC,mBAAmB,KAAK,SAAS,EAAE;YAC1C,MAAM,MAAM,GAAyB,qDAAyB,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACrG,IAAI,MAAM,EAAE;gBACV,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;gBACtB,OAAO;aACR;SACF;QAED,sCAAsC;QAEtC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC1B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC/B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACrB;SACF;IACH,CAAC;CACF;AAnED,wEAmEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineStringListDefinition } from './CommandLineDefinition';\nimport { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';\nimport { EnvironmentVariableParser } from './EnvironmentVariableParser';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineStringListParameter}.\n * @public\n */\nexport class CommandLineStringListParameter extends CommandLineParameterWithArgument {\n private _values: string[] = [];\n\n /** @internal */\n public constructor(definition: ICommandLineStringListDefinition) {\n super(definition);\n }\n\n /** {@inheritDoc CommandLineParameter.kind} */\n public get kind(): CommandLineParameterKind {\n return CommandLineParameterKind.StringList;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // If argparse passed us a value, confirm it is valid\n if (data !== null && data !== undefined) {\n if (!Array.isArray(data)) {\n this.reportInvalidData(data);\n }\n for (const arrayItem of data) {\n if (typeof arrayItem !== 'string') {\n this.reportInvalidData(data);\n }\n }\n this._values = data;\n return;\n }\n\n // If an environment variable exists, attempt to parse it as a list\n if (this.environmentVariable !== undefined) {\n const values: string[] | undefined = EnvironmentVariableParser.parseAsList(this.environmentVariable);\n if (values) {\n this._values = values;\n return;\n }\n }\n\n // (No default value for string lists)\n\n this._values = [];\n }\n\n /**\n * Returns the string arguments for a string list parameter that was parsed from the command line.\n *\n * @remarks\n * The array will be empty if the command-line has not been parsed yet,\n * or if the parameter was omitted and has no default value.\n */\n public get values(): ReadonlyArray<string> {\n return this._values;\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.values.length > 0) {\n for (const value of this.values) {\n argList.push(this.longName);\n argList.push(value);\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandLineStringParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineStringParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA2F;AAE3F;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,8CAAgC;IAM9E,gBAAgB;IAChB,YAAmB,UAAwC;QACzD,KAAK,CA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AAE;gBAClC,kBAAkB,CAAC,IAAI,CAAC,wBAAwB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;aACvF;SACF;IACH,CAAC;IAED;;;;;;OAMG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1B;IACH,CAAC;CACF;AArFD,gEAqFC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { ICommandLineStringDefinition } from './CommandLineDefinition';\r\nimport { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';\r\n\r\n/**\r\n * The data type returned by {@link CommandLineParameterProvider.defineStringParameter}.\r\n * @public\r\n */\r\nexport class CommandLineStringParameter extends CommandLineParameterWithArgument {\r\n /** {@inheritDoc ICommandLineStringDefinition.defaultValue} */\r\n public readonly defaultValue: string | undefined;\r\n\r\n private _value: string | undefined = undefined;\r\n\r\n /** @internal */\r\n public constructor(definition: ICommandLineStringDefinition) {\r\n super(definition);\r\n\r\n this.defaultValue = definition.defaultValue;\r\n this.validateDefaultValue(!!this.defaultValue);\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.kind} */\r\n public get kind(): CommandLineParameterKind {\r\n return CommandLineParameterKind.String;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._setValue}\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n public _setValue(data: any): void {\r\n // abstract\r\n if (data !== null && data !== undefined) {\r\n if (typeof data !== 'string') {\r\n this.reportInvalidData(data);\r\n }\r\n this._value = data;\r\n return;\r\n }\r\n\r\n if (this.environmentVariable !== undefined) {\r\n // Try reading the environment variable\r\n const environmentValue: string | undefined = process.env[this.environmentVariable];\r\n if (environmentValue !== undefined) {\r\n // NOTE: If the environment variable is defined as an empty string,\r\n // here we will accept the empty string as our value. (For number/flag we don't do that.)\r\n this._value = environmentValue;\r\n return;\r\n }\r\n }\r\n\r\n if (this.defaultValue !== undefined) {\r\n this._value = this.defaultValue;\r\n return;\r\n }\r\n\r\n this._value = undefined;\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameter._getSupplementaryNotes}\r\n * @internal\r\n */\r\n public _getSupplementaryNotes(supplementaryNotes: string[]): void {\r\n // virtual\r\n super._getSupplementaryNotes(supplementaryNotes);\r\n if (this.defaultValue !== undefined) {\r\n if (this.defaultValue.length < 160) {\r\n supplementaryNotes.push(`The default value is ${JSON.stringify(this.defaultValue)}.`);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Returns the argument value for a string parameter that was parsed from the command line.\r\n *\r\n * @remarks\r\n * The return value will be undefined if the command-line has not been parsed yet,\r\n * or if the parameter was omitted and has no default value.\r\n */\r\n public get value(): string | undefined {\r\n return this._value;\r\n }\r\n\r\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\r\n public appendToArgList(argList: string[]): void {\r\n if (this.value !== undefined) {\r\n argList.push(this.longName);\r\n argList.push(this.value);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"CommandLineStringParameter.js","sourceRoot":"","sources":["../../src/parameters/CommandLineStringParameter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,+CAA2F;AAE3F;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,8CAAgC;IAM9E,gBAAgB;IAChB,YAAmB,UAAwC;QACzD,KAAK,CAAC,UAAU,CAAC,CAAC;QAJZ,WAAM,GAAuB,SAAS,CAAC;QAM7C,IAAI,CAAC,YAAY,GAAG,UAA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CAAC,GAAG,CAAC,CAAC;aACvF;SACF;IACH,CAAC;IAED;;;;;;OAMG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,mEAAmE;IAC5D,eAAe,CAAC,OAAiB;QACtC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC1B;IACH,CAAC;CACF;AArFD,gEAqFC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { ICommandLineStringDefinition } from './CommandLineDefinition';\nimport { CommandLineParameterWithArgument, CommandLineParameterKind } from './BaseClasses';\n\n/**\n * The data type returned by {@link CommandLineParameterProvider.defineStringParameter}.\n * @public\n */\nexport class CommandLineStringParameter extends CommandLineParameterWithArgument {\n /** {@inheritDoc ICommandLineStringDefinition.defaultValue} */\n public readonly defaultValue: string | undefined;\n\n private _value: string | undefined = undefined;\n\n /** @internal */\n public constructor(definition: ICommandLineStringDefinition) {\n super(definition);\n\n this.defaultValue = definition.defaultValue;\n this.validateDefaultValue(!!this.defaultValue);\n }\n\n /** {@inheritDoc CommandLineParameter.kind} */\n public get kind(): CommandLineParameterKind {\n return CommandLineParameterKind.String;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._setValue}\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public _setValue(data: any): void {\n // abstract\n if (data !== null && data !== undefined) {\n if (typeof data !== 'string') {\n this.reportInvalidData(data);\n }\n this._value = data;\n return;\n }\n\n if (this.environmentVariable !== undefined) {\n // Try reading the environment variable\n const environmentValue: string | undefined = process.env[this.environmentVariable];\n if (environmentValue !== undefined) {\n // NOTE: If the environment variable is defined as an empty string,\n // here we will accept the empty string as our value. (For number/flag we don't do that.)\n this._value = environmentValue;\n return;\n }\n }\n\n if (this.defaultValue !== undefined) {\n this._value = this.defaultValue;\n return;\n }\n\n this._value = undefined;\n }\n\n /**\n * {@inheritDoc CommandLineParameter._getSupplementaryNotes}\n * @internal\n */\n public _getSupplementaryNotes(supplementaryNotes: string[]): void {\n // virtual\n super._getSupplementaryNotes(supplementaryNotes);\n if (this.defaultValue !== undefined) {\n if (this.defaultValue.length < 160) {\n supplementaryNotes.push(`The default value is ${JSON.stringify(this.defaultValue)}.`);\n }\n }\n }\n\n /**\n * Returns the argument value for a string parameter that was parsed from the command line.\n *\n * @remarks\n * The return value will be undefined if the command-line has not been parsed yet,\n * or if the parameter was omitted and has no default value.\n */\n public get value(): string | undefined {\n return this._value;\n }\n\n /** {@inheritDoc CommandLineParameter.appendToArgList} @override */\n public appendToArgList(argList: string[]): void {\n if (this.value !== undefined) {\n argList.push(this.longName);\n argList.push(this.value);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EnvironmentVariableParser.js","sourceRoot":"","sources":["../../src/parameters/EnvironmentVariableParser.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;;GAKG;AACH,MAAa,yBAAyB;IAC7B,MAAM,CAAC,WAAW,CAAC,UAAkB;QAC1C,MAAM,gBAAgB,GAAuB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAErE,IAAI,gBAAgB,KAAK,SAAS,EAAE;YAClC,mEAAmE;YACnE,0FAA0F;YAE1F,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;gBAC1C,iGAAiG;gBACjG,2FAA2F;gBAC3F,iGAAiG;gBACjG,+FAA+F;gBAC/F,mGAAmG;gBACnG,+FAA+F;gBAC/F,2BAA2B;gBAC3B,IAAI;oBACF,MAAM,UAAU,GAAY,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;oBACzD,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;wBAC1B,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC,EAClG;wBACA,MAAM,IAAI,KAAK,CACb,OAAO,gBAAgB,6CAA6C;4BAClE,wDAAwD,CAC3D,CAAC;qBACH;oBACD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;iBAC5C;gBAAC,OAAO,EAAE,EAAE;oBACX,MAAM,IAAI,KAAK,CACb,OAAO,gBAAgB,qDAAqD;wBAC1E,wBAAwB;wBACvB,EAAY,CAAC,OAAO,CACxB,CAAC;iBACH;aACF;iBAAM;gBACL,gGAAgG;gBAChG,gCAAgC;gBAChC,OAAO,CAAC,gBAAgB,CAAC,CAAC;aAC3B;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA5CD,8DA4CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/**\r\n * Some parameter types can receive their values from an environment variable instead of\r\n * a command line argument. This class provides some utility methods for parsing environment\r\n * variable values.\r\n * @internal\r\n */\r\nexport class EnvironmentVariableParser {\r\n public static parseAsList(envVarName: string): string[] | undefined {\r\n const environmentValue: string | undefined = process.env[envVarName];\r\n\r\n if (environmentValue !== undefined) {\r\n // NOTE: If the environment variable is defined as an empty string,\r\n // here we will accept the empty string as our value. (For number/flag we don't do that.)\r\n\r\n if (environmentValue.trimLeft()[0] === '[') {\r\n // Specifying multiple items in an environment variable is a somewhat rare case. But environment\r\n // variables are actually a pretty reliable way for a tool to avoid shell escaping problems\r\n // when spawning another tool. For this case, we need a reliable way to pass an array of strings\r\n // that could contain any character. For example, if we simply used \";\" as the list delimiter,\r\n // then what to do if a string contains that character? We'd need to design an escaping mechanism.\r\n // Since JSON is simple and standard and can escape every possible string, it's a better option\r\n // than a custom delimiter.\r\n try {\r\n const parsedJson: unknown = JSON.parse(environmentValue);\r\n if (\r\n !Array.isArray(parsedJson) ||\r\n !parsedJson.every((x) => typeof x === 'string' || typeof x === 'boolean' || typeof x === 'number')\r\n ) {\r\n throw new Error(\r\n `The ${environmentValue} environment variable value must be a JSON ` +\r\n ` array containing only strings, numbers, and booleans.`\r\n );\r\n }\r\n return parsedJson.map((x) => x.toString());\r\n } catch (ex) {\r\n throw new Error(\r\n `The ${environmentValue} environment variable value looks like a JSON array` +\r\n ` but failed to parse: ` +\r\n (ex as Error).message\r\n );\r\n }\r\n } else {\r\n // As a shorthand, a single value may be specified without JSON encoding, as long as it does not\r\n // start with the \"[\" character.\r\n return [environmentValue];\r\n }\r\n }\r\n\r\n return undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"EnvironmentVariableParser.js","sourceRoot":"","sources":["../../src/parameters/EnvironmentVariableParser.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;;GAKG;AACH,MAAa,yBAAyB;IAC7B,MAAM,CAAC,WAAW,CAAC,UAAkB;QAC1C,MAAM,gBAAgB,GAAuB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAErE,IAAI,gBAAgB,KAAK,SAAS,EAAE;YAClC,mEAAmE;YACnE,0FAA0F;YAE1F,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;gBAC1C,iGAAiG;gBACjG,2FAA2F;gBAC3F,iGAAiG;gBACjG,+FAA+F;gBAC/F,mGAAmG;gBACnG,+FAA+F;gBAC/F,2BAA2B;gBAC3B,IAAI;oBACF,MAAM,UAAU,GAAY,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;oBACzD,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;wBAC1B,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC,EAClG;wBACA,MAAM,IAAI,KAAK,CACb,OAAO,gBAAgB,6CAA6C;4BAClE,wDAAwD,CAC3D,CAAC;qBACH;oBACD,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;iBAC5C;gBAAC,OAAO,EAAE,EAAE;oBACX,MAAM,IAAI,KAAK,CACb,OAAO,gBAAgB,qDAAqD;wBAC1E,wBAAwB;wBACvB,EAAY,CAAC,OAAO,CACxB,CAAC;iBACH;aACF;iBAAM;gBACL,gGAAgG;gBAChG,gCAAgC;gBAChC,OAAO,CAAC,gBAAgB,CAAC,CAAC;aAC3B;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA5CD,8DA4CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * Some parameter types can receive their values from an environment variable instead of\n * a command line argument. This class provides some utility methods for parsing environment\n * variable values.\n * @internal\n */\nexport class EnvironmentVariableParser {\n public static parseAsList(envVarName: string): string[] | undefined {\n const environmentValue: string | undefined = process.env[envVarName];\n\n if (environmentValue !== undefined) {\n // NOTE: If the environment variable is defined as an empty string,\n // here we will accept the empty string as our value. (For number/flag we don't do that.)\n\n if (environmentValue.trimLeft()[0] === '[') {\n // Specifying multiple items in an environment variable is a somewhat rare case. But environment\n // variables are actually a pretty reliable way for a tool to avoid shell escaping problems\n // when spawning another tool. For this case, we need a reliable way to pass an array of strings\n // that could contain any character. For example, if we simply used \";\" as the list delimiter,\n // then what to do if a string contains that character? We'd need to design an escaping mechanism.\n // Since JSON is simple and standard and can escape every possible string, it's a better option\n // than a custom delimiter.\n try {\n const parsedJson: unknown = JSON.parse(environmentValue);\n if (\n !Array.isArray(parsedJson) ||\n !parsedJson.every((x) => typeof x === 'string' || typeof x === 'boolean' || typeof x === 'number')\n ) {\n throw new Error(\n `The ${environmentValue} environment variable value must be a JSON ` +\n ` array containing only strings, numbers, and booleans.`\n );\n }\n return parsedJson.map((x) => x.toString());\n } catch (ex) {\n throw new Error(\n `The ${environmentValue} environment variable value looks like a JSON array` +\n ` but failed to parse: ` +\n (ex as Error).message\n );\n }\n } else {\n // As a shorthand, a single value may be specified without JSON encoding, as long as it does not\n // start with the \"[\" character.\n return [environmentValue];\n }\n }\n\n return undefined;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AliasCommandLineAction.js","sourceRoot":"","sources":["../../src/providers/AliasCommandLineAction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,mDAAqC;AAErC,2DAAwD;AACxD,2DAAgG;AAqChG;;;;;;;;;GASG;AACH,MAAa,sBAAuB,SAAQ,qCAAiB;IAa3D,YAAmB,OAAuC;QACxD,MAAM,YAAY,GAAW,OAAO,CAAC,YAAY,CAAC;QAClD,MAAM,gBAAgB,GAAW,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC;QACjE,MAAM,uBAAuB,GAAW,CAAC,OAAO,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpF,MAAM,OAAO,GAAW,iBAAiB,YAAY,IAAI,gBAAgB,GACvE,uBAAuB,CAAC,CAAC,CAAC,IAAI,uBAAuB,EAAE,CAAC,CAAC,CAAC,EAC5D,IAAI,CAAC;QAEL,KAAK,CAAC;YACJ,UAAU,EAAE,OAAO,CAAC,SAAS;YAC7B,OAAO;YACP,aAAa,EACX,GAAG,OAAO,oDAAoD;gBAC9D,IAAI,YAAY,IAAI,gBAAgB,WAAW;SAClD,CAAC,CAAC;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CAAC;QAExC,+EAA+E;QAC/E,qCAAqC;QACrC,KAAK,MAAM,CAAC,sBAAsB,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,mCAAmC,EAAE;YAC1F,MAAM,eAAe,GACnB,IAAI,CAAC,YAAY,CAAC,mCAAmC,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;YAEpF,yFAAyF;YACzF,IAAI,eAAe,EAAE;gBACnB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;aACvD;SACF;IACH,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,aAAwC,EAAE,IAA4B;QAC9F,oGAAoG;QACpG,MAAM,UAAU,GAA2B;YACzC,MAAM,EAAE,IAAI,CAAC,YAAY,CAAC,UAAU;YACpC,WAAW,EAAE,IAAI,CAAC,MAAM;YACxB,kBAAkB,EAAE,IAAI,CAAC,aAAa;SACvC,CAAC;QACF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YAC/C,yFAAyF;YACzF,qFAAqF;YACrF,IAAI,GAAG,KAAK,QAAQ,EAAE;gBACpB,SAAS;aACV;YACD,MAAM,SAAS,GAAuB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACrE,UAAU,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,GAAG,CAAC,GAAG,KAAK,CAAC;SACtC;QACD,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,SAAS;QACvB,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IACrC,CAAC;CACF;AAnJD,wDAmJC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport * as argparse from 'argparse';\r\n\r\nimport { CommandLineAction } from './CommandLineAction';\r\nimport { CommandLineParameterKind, type CommandLineParameter } from '../parameters/BaseClasses';\r\nimport type { ICommandLineParserData, IRegisterDefinedParametersState } from './CommandLineParameterProvider';\r\nimport type { ICommandLineParserOptions } from './CommandLineParser';\r\nimport type { CommandLineChoiceParameter } from '../parameters/CommandLineChoiceParameter';\r\nimport type { CommandLineFlagParameter } from '../parameters/CommandLineFlagParameter';\r\nimport type { CommandLineStringParameter } from '../parameters/CommandLineStringParameter';\r\nimport type { CommandLineIntegerParameter } from '../parameters/CommandLineIntegerParameter';\r\nimport type { CommandLineChoiceListParameter } from '../parameters/CommandLineChoiceListParameter';\r\nimport type { CommandLineIntegerListParameter } from '../parameters/CommandLineIntegerListParameter';\r\n\r\n/**\r\n * Options for the AliasCommandLineAction constructor.\r\n * @public\r\n */\r\nexport interface IAliasCommandLineActionOptions {\r\n /**\r\n * The name of your tool when invoked from the command line. Used for generating help text.\r\n */\r\n toolFilename: string;\r\n\r\n /**\r\n * The name of the alias. For example, if the tool is called \"example\",\r\n * then the \"build\" alias might be invoked as: \"example build -q --some-other-option\"\r\n */\r\n aliasName: string;\r\n\r\n /**\r\n * A list of default parameters to pass to the target action.\r\n */\r\n defaultParameters?: string[];\r\n\r\n /**\r\n * The action that this alias invokes.\r\n */\r\n targetAction: CommandLineAction;\r\n}\r\n\r\n/**\r\n * Represents a sub-command that is part of the CommandLineParser command line.\r\n * The sub-command is an alias for another existing action.\r\n *\r\n * The alias name should be comprised of lower case words separated by hyphens\r\n * or colons. The name should include an English verb (e.g. \"deploy\"). Use a\r\n * hyphen to separate words (e.g. \"upload-docs\").\r\n *\r\n * @public\r\n */\r\nexport class AliasCommandLineAction extends CommandLineAction {\r\n /**\r\n * The action that this alias invokes.\r\n */\r\n public readonly targetAction: CommandLineAction;\r\n\r\n /**\r\n * A list of default arguments to pass to the target action.\r\n */\r\n public readonly defaultParameters: ReadonlyArray<string>;\r\n\r\n private _parameterKeyMap: Map<string, string> = new Map();\r\n\r\n public constructor(options: IAliasCommandLineActionOptions) {\r\n const toolFilename: string = options.toolFilename;\r\n const targetActionName: string = options.targetAction.actionName;\r\n const defaultParametersString: string = (options.defaultParameters || []).join(' ');\r\n const summary: string = `An alias for \"${toolFilename} ${targetActionName}${\r\n defaultParametersString ? ` ${defaultParametersString}` : ''\r\n }\".`;\r\n\r\n super({\r\n actionName: options.aliasName,\r\n summary,\r\n documentation:\r\n `${summary} For more information on the aliased command, use ` +\r\n `\"${toolFilename} ${targetActionName} --help\".`\r\n });\r\n\r\n this.targetAction = options.targetAction;\r\n this.defaultParameters = options.defaultParameters || [];\r\n }\r\n\r\n /** @internal */\r\n public _registerDefinedParameters(state: IRegisterDefinedParametersState): void {\r\n /* override */\r\n // All parameters are going to be defined by the target action. Re-use the target action parameters\r\n // for this action.\r\n for (const parameter of this.targetAction.parameters) {\r\n let aliasParameter: CommandLineParameter;\r\n const nameOptions: { parameterLongName: string; parameterShortName: string | undefined } = {\r\n parameterLongName: parameter.longName,\r\n parameterShortName: parameter.shortName\r\n };\r\n switch (parameter.kind) {\r\n case CommandLineParameterKind.Choice:\r\n const choiceParameter: CommandLineChoiceParameter = parameter as CommandLineChoiceParameter;\r\n aliasParameter = this.defineChoiceParameter({\r\n ...nameOptions,\r\n ...choiceParameter,\r\n alternatives: ([] as string[]).concat(choiceParameter.alternatives)\r\n });\r\n break;\r\n case CommandLineParameterKind.ChoiceList:\r\n const choiceListParameter: CommandLineChoiceListParameter =\r\n parameter as CommandLineChoiceListParameter;\r\n aliasParameter = this.defineChoiceListParameter({\r\n ...nameOptions,\r\n ...choiceListParameter,\r\n alternatives: ([] as string[]).concat(choiceListParameter.alternatives)\r\n });\r\n break;\r\n case CommandLineParameterKind.Flag:\r\n const flagParameter: CommandLineFlagParameter = parameter as CommandLineFlagParameter;\r\n aliasParameter = this.defineFlagParameter({ ...nameOptions, ...flagParameter });\r\n break;\r\n case CommandLineParameterKind.Integer:\r\n const integerParameter: CommandLineIntegerParameter = parameter as CommandLineIntegerParameter;\r\n aliasParameter = this.defineIntegerParameter({ ...nameOptions, ...integerParameter });\r\n break;\r\n case CommandLineParameterKind.IntegerList:\r\n const integerListParameter: CommandLineIntegerListParameter =\r\n parameter as CommandLineIntegerListParameter;\r\n aliasParameter = this.defineIntegerListParameter({ ...nameOptions, ...integerListParameter });\r\n break;\r\n case CommandLineParameterKind.String:\r\n const stringParameter: CommandLineStringParameter = parameter as CommandLineStringParameter;\r\n aliasParameter = this.defineStringParameter({ ...nameOptions, ...stringParameter });\r\n break;\r\n case CommandLineParameterKind.StringList:\r\n const stringListParameter: CommandLineStringParameter = parameter as CommandLineStringParameter;\r\n aliasParameter = this.defineStringListParameter({ ...nameOptions, ...stringListParameter });\r\n break;\r\n default:\r\n throw new Error(`Unsupported parameter kind: ${parameter.kind}`);\r\n }\r\n\r\n // We know the parserKey is defined because the underlying _defineParameter method sets it,\r\n // and all parameters that we have access to have already been defined.\r\n this._parameterKeyMap.set(aliasParameter._parserKey!, parameter._parserKey!);\r\n }\r\n\r\n // We also need to register the remainder parameter if the target action has one. The parser\r\n // key for this parameter is constant.\r\n if (this.targetAction.remainder) {\r\n this.defineCommandLineRemainder(this.targetAction.remainder);\r\n this._parameterKeyMap.set(argparse.Const.REMAINDER, argparse.Const.REMAINDER);\r\n }\r\n\r\n // Finally, register the parameters with the parser. We need to make sure that the target action\r\n // is registered, since we need to re-use its parameters, and ambiguous parameters are discovered\r\n // during registration. This will no-op if the target action is already registered.\r\n this.targetAction._registerDefinedParameters(state);\r\n super._registerDefinedParameters(state);\r\n\r\n // We need to re-map the ambiguous parameters after they are defined by calling\r\n // super._registerDefinedParameters()\r\n for (const [ambiguousParameterName, parserKey] of this._ambiguousParameterParserKeysByName) {\r\n const targetParserKey: string | undefined =\r\n this.targetAction._ambiguousParameterParserKeysByName.get(ambiguousParameterName);\r\n\r\n // If we have a mapping for the specified key, then use it. Otherwise, use the key as-is.\r\n if (targetParserKey) {\r\n this._parameterKeyMap.set(parserKey, targetParserKey);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * This is called internally by CommandLineParser.execute()\r\n * @internal\r\n */\r\n public _processParsedData(parserOptions: ICommandLineParserOptions, data: ICommandLineParserData): void {\r\n // Re-map the parsed data to the target action's parameters and execute the target action processor.\r\n const targetData: ICommandLineParserData = {\r\n action: this.targetAction.actionName,\r\n aliasAction: data.action,\r\n aliasDocumentation: this.documentation\r\n };\r\n for (const [key, value] of Object.entries(data)) {\r\n // If we have a mapping for the specified key, then use it. Otherwise, use the key as-is.\r\n // Skip over the action key though, since we've already re-mapped it to \"aliasAction\"\r\n if (key === 'action') {\r\n continue;\r\n }\r\n const targetKey: string | undefined = this._parameterKeyMap.get(key);\r\n targetData[targetKey ?? key] = value;\r\n }\r\n this.targetAction._processParsedData(parserOptions, targetData);\r\n }\r\n\r\n /**\r\n * Executes the target action.\r\n */\r\n protected async onExecute(): Promise<void> {\r\n await this.targetAction._execute();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"AliasCommandLineAction.js","sourceRoot":"","sources":["../../src/providers/AliasCommandLineAction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,mDAAqC;AAErC,2DAAwD;AACxD,2DAAgG;AAqChG;;;;;;;;;GASG;AACH,MAAa,sBAAuB,SAAQ,qCAAiB;IAa3D,YAAmB,OAAuC;QACxD,MAAM,YAAY,GAAW,OAAO,CAAC,YAAY,CAAC;QAClD,MAAM,gBAAgB,GAAW,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC;QACjE,MAAM,uBAAuB,GAAW,CAAC,OAAO,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpF,MAAM,OAAO,GAAW,iBAAiB,YAAY,IAAI,gBAAgB,GACvE,uBAAuB,CAAC,CAAC,CAAC,IAAI,uBAAuB,EAAE,CAAC,CAAC,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C,SAAS;QACvB,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;IACrC,CAAC;CACF;AAnJD,wDAmJC","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 { CommandLineAction } from './CommandLineAction';\nimport { CommandLineParameterKind, type CommandLineParameter } from '../parameters/BaseClasses';\nimport type { ICommandLineParserData, IRegisterDefinedParametersState } from './CommandLineParameterProvider';\nimport type { ICommandLineParserOptions } from './CommandLineParser';\nimport type { CommandLineChoiceParameter } from '../parameters/CommandLineChoiceParameter';\nimport type { CommandLineFlagParameter } from '../parameters/CommandLineFlagParameter';\nimport type { CommandLineStringParameter } from '../parameters/CommandLineStringParameter';\nimport type { CommandLineIntegerParameter } from '../parameters/CommandLineIntegerParameter';\nimport type { CommandLineChoiceListParameter } from '../parameters/CommandLineChoiceListParameter';\nimport type { CommandLineIntegerListParameter } from '../parameters/CommandLineIntegerListParameter';\n\n/**\n * Options for the AliasCommandLineAction constructor.\n * @public\n */\nexport interface IAliasCommandLineActionOptions {\n /**\n * The name of your tool when invoked from the command line. Used for generating help text.\n */\n toolFilename: string;\n\n /**\n * The name of the alias. For example, if the tool is called \"example\",\n * then the \"build\" alias might be invoked as: \"example build -q --some-other-option\"\n */\n aliasName: string;\n\n /**\n * A list of default parameters to pass to the target action.\n */\n defaultParameters?: string[];\n\n /**\n * The action that this alias invokes.\n */\n targetAction: CommandLineAction;\n}\n\n/**\n * Represents a sub-command that is part of the CommandLineParser command line.\n * The sub-command is an alias for another existing action.\n *\n * The alias 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\").\n *\n * @public\n */\nexport class AliasCommandLineAction extends CommandLineAction {\n /**\n * The action that this alias invokes.\n */\n public readonly targetAction: CommandLineAction;\n\n /**\n * A list of default arguments to pass to the target action.\n */\n public readonly defaultParameters: ReadonlyArray<string>;\n\n private _parameterKeyMap: Map<string, string> = new Map();\n\n public constructor(options: IAliasCommandLineActionOptions) {\n const toolFilename: string = options.toolFilename;\n const targetActionName: string = options.targetAction.actionName;\n const defaultParametersString: string = (options.defaultParameters || []).join(' ');\n const summary: string = `An alias for \"${toolFilename} ${targetActionName}${\n defaultParametersString ? ` ${defaultParametersString}` : ''\n }\".`;\n\n super({\n actionName: options.aliasName,\n summary,\n documentation:\n `${summary} For more information on the aliased command, use ` +\n `\"${toolFilename} ${targetActionName} --help\".`\n });\n\n this.targetAction = options.targetAction;\n this.defaultParameters = options.defaultParameters || [];\n }\n\n /** @internal */\n public _registerDefinedParameters(state: IRegisterDefinedParametersState): void {\n /* override */\n // All parameters are going to be defined by the target action. Re-use the target action parameters\n // for this action.\n for (const parameter of this.targetAction.parameters) {\n let aliasParameter: CommandLineParameter;\n const nameOptions: { parameterLongName: string; parameterShortName: string | undefined } = {\n parameterLongName: parameter.longName,\n parameterShortName: parameter.shortName\n };\n switch (parameter.kind) {\n case CommandLineParameterKind.Choice:\n const choiceParameter: CommandLineChoiceParameter = parameter as CommandLineChoiceParameter;\n aliasParameter = this.defineChoiceParameter({\n ...nameOptions,\n ...choiceParameter,\n alternatives: ([] as string[]).concat(choiceParameter.alternatives)\n });\n break;\n case CommandLineParameterKind.ChoiceList:\n const choiceListParameter: CommandLineChoiceListParameter =\n parameter as CommandLineChoiceListParameter;\n aliasParameter = this.defineChoiceListParameter({\n ...nameOptions,\n ...choiceListParameter,\n alternatives: ([] as string[]).concat(choiceListParameter.alternatives)\n });\n break;\n case CommandLineParameterKind.Flag:\n const flagParameter: CommandLineFlagParameter = parameter as CommandLineFlagParameter;\n aliasParameter = this.defineFlagParameter({ ...nameOptions, ...flagParameter });\n break;\n case CommandLineParameterKind.Integer:\n const integerParameter: CommandLineIntegerParameter = parameter as CommandLineIntegerParameter;\n aliasParameter = this.defineIntegerParameter({ ...nameOptions, ...integerParameter });\n break;\n case CommandLineParameterKind.IntegerList:\n const integerListParameter: CommandLineIntegerListParameter =\n parameter as CommandLineIntegerListParameter;\n aliasParameter = this.defineIntegerListParameter({ ...nameOptions, ...integerListParameter });\n break;\n case CommandLineParameterKind.String:\n const stringParameter: CommandLineStringParameter = parameter as CommandLineStringParameter;\n aliasParameter = this.defineStringParameter({ ...nameOptions, ...stringParameter });\n break;\n case CommandLineParameterKind.StringList:\n const stringListParameter: CommandLineStringParameter = parameter as CommandLineStringParameter;\n aliasParameter = this.defineStringListParameter({ ...nameOptions, ...stringListParameter });\n break;\n default:\n throw new Error(`Unsupported parameter kind: ${parameter.kind}`);\n }\n\n // We know the parserKey is defined because the underlying _defineParameter method sets it,\n // and all parameters that we have access to have already been defined.\n this._parameterKeyMap.set(aliasParameter._parserKey!, parameter._parserKey!);\n }\n\n // We also need to register the remainder parameter if the target action has one. The parser\n // key for this parameter is constant.\n if (this.targetAction.remainder) {\n this.defineCommandLineRemainder(this.targetAction.remainder);\n this._parameterKeyMap.set(argparse.Const.REMAINDER, argparse.Const.REMAINDER);\n }\n\n // Finally, register the parameters with the parser. We need to make sure that the target action\n // is registered, since we need to re-use its parameters, and ambiguous parameters are discovered\n // during registration. This will no-op if the target action is already registered.\n this.targetAction._registerDefinedParameters(state);\n super._registerDefinedParameters(state);\n\n // We need to re-map the ambiguous parameters after they are defined by calling\n // super._registerDefinedParameters()\n for (const [ambiguousParameterName, parserKey] of this._ambiguousParameterParserKeysByName) {\n const targetParserKey: string | undefined =\n this.targetAction._ambiguousParameterParserKeysByName.get(ambiguousParameterName);\n\n // If we have a mapping for the specified key, then use it. Otherwise, use the key as-is.\n if (targetParserKey) {\n this._parameterKeyMap.set(parserKey, targetParserKey);\n }\n }\n }\n\n /**\n * This is called internally by CommandLineParser.execute()\n * @internal\n */\n public _processParsedData(parserOptions: ICommandLineParserOptions, data: ICommandLineParserData): void {\n // Re-map the parsed data to the target action's parameters and execute the target action processor.\n const targetData: ICommandLineParserData = {\n action: this.targetAction.actionName,\n aliasAction: data.action,\n aliasDocumentation: this.documentation\n };\n for (const [key, value] of Object.entries(data)) {\n // If we have a mapping for the specified key, then use it. Otherwise, use the key as-is.\n // Skip over the action key though, since we've already re-mapped it to \"aliasAction\"\n if (key === 'action') {\n continue;\n }\n const targetKey: string | undefined = this._parameterKeyMap.get(key);\n targetData[targetKey ?? key] = value;\n }\n this.targetAction._processParsedData(parserOptions, targetData);\n }\n\n /**\n * Executes the target action.\n */\n protected async onExecute(): Promise<void> {\n await this.targetAction._execute();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CommandLineAction.js","sourceRoot":"","sources":["../../src/providers/CommandLineAction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,iFAA2G;AAE3G,6EAA0E;AA0B1E;;GAEG;AACH,MAAM,kBAAkB,GAAW,kCAAkC,CAAC;AAEtE;;;;;;;;;;;;GAYG;AACH,MAAsB,iBAAkB,SAAQ,2DAA4B;IAY1E,YAAmB,OAAkC;QACnD,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAChD,MAAM,IAAI,KAAK,CACb,wBAAwB,OAAO,CAAC,UAAU,KAAK;gBAC7C,2FAA2F,CAC9F,CAAC;SACH;QAED,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAE3C,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;IACnC,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,gBAAoC;;QACtD,IAAI,CAAC,eAAe,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE;YACjE,IAAI,EAAE,IAAI,CAAC,OAAO;YAClB,WAAW,EAAE,IAAI,CAAC,aAAa;SAChC,CAAC,CAAC;QAEH,wDAAwD;QACxD,IAAI,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,MAAc,EAAE,OAAe,EAAE,EAAE;YAC9D,MAAM,IAAI,uDAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC,CAAC;QACF,MAAM,6BAA6B,GAAkC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,IAAI,CAClG,IAAI,CAAC,eAAe,CACrB,CAAC;QACF,IAAI,CAAC,eAAe,CAAC,KAAK,GAAG,CAAC,GAAmB,EAAE,EAAE;YACnD,kFAAkF;YAClF,IAAI,GAAG,YAAY,uDAA0B,EAAE;gBAC7C,MAAM,GAAG,CAAC;aACX;YACD,6BAA6B,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC,CAAC;QAEF,MAAA,IAAI,CAAC,kBAAkB,oDAAI,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,aAAwC,EAAE,IAA4B;QAC9F,KAAK,CAAC,kBAAkB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAChD,CAAC;IAED;;;OAGG;IACI,QAAQ;QACb,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACO,kBAAkB;QAC1B,WAAW;QACX,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,qCAAqC;YACrC,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;SACrG;QAED,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;CAMF;AA3FD,8CA2FC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type * as argparse from 'argparse';\r\n\r\nimport { CommandLineParameterProvider, type ICommandLineParserData } from './CommandLineParameterProvider';\r\nimport type { ICommandLineParserOptions } from './CommandLineParser';\r\nimport { CommandLineParserExitError } from './CommandLineParserExitError';\r\n\r\n/**\r\n * Options for the CommandLineAction constructor.\r\n * @public\r\n */\r\nexport interface ICommandLineActionOptions {\r\n /**\r\n * The name of the action. For example, if the tool is called \"example\",\r\n * then the \"build\" action might be invoked as: \"example build -q --some-other-option\"\r\n */\r\n actionName: string;\r\n\r\n /**\r\n * A quick summary that is shown on the main help page, which is displayed\r\n * by the command \"example --help\"\r\n */\r\n summary: string;\r\n\r\n /**\r\n * A detailed description that is shown on the action help page, which is displayed\r\n * by the command \"example build --help\", e.g. for actionName=\"build\".\r\n */\r\n documentation: string;\r\n}\r\n\r\n/**\r\n * Example: \"do-something\"\r\n */\r\nconst ACTION_NAME_REGEXP: RegExp = /^[a-z][a-z0-9]*([-:][a-z0-9]+)*$/;\r\n\r\n/**\r\n * Represents a sub-command that is part of the CommandLineParser command line.\r\n * Applications should create subclasses of CommandLineAction corresponding to\r\n * each action that they want to expose.\r\n *\r\n * The action name should be comprised of lower case words separated by hyphens\r\n * or colons. The name should include an English verb (e.g. \"deploy\"). Use a\r\n * hyphen to separate words (e.g. \"upload-docs\"). A group of related commands\r\n * can be prefixed with a colon (e.g. \"docs:generate\", \"docs:deploy\",\r\n * \"docs:serve\", etc).\r\n *\r\n * @public\r\n */\r\nexport abstract class CommandLineAction extends CommandLineParameterProvider {\r\n /** {@inheritDoc ICommandLineActionOptions.actionName} */\r\n public readonly actionName: string;\r\n\r\n /** {@inheritDoc ICommandLineActionOptions.summary} */\r\n public readonly summary: string;\r\n\r\n /** {@inheritDoc ICommandLineActionOptions.documentation} */\r\n public readonly documentation: string;\r\n\r\n private _argumentParser: argparse.ArgumentParser | undefined;\r\n\r\n public constructor(options: ICommandLineActionOptions) {\r\n super();\r\n\r\n if (!ACTION_NAME_REGEXP.test(options.actionName)) {\r\n throw new Error(\r\n `Invalid action name \"${options.actionName}\". ` +\r\n `The name must be comprised of lower-case words optionally separated by hyphens or colons.`\r\n );\r\n }\r\n\r\n this.actionName = options.actionName;\r\n this.summary = options.summary;\r\n this.documentation = options.documentation;\r\n\r\n this._argumentParser = undefined;\r\n }\r\n\r\n /**\r\n * This is called internally by CommandLineParser.addAction()\r\n * @internal\r\n */\r\n public _buildParser(actionsSubParser: argparse.SubParser): void {\r\n this._argumentParser = actionsSubParser.addParser(this.actionName, {\r\n help: this.summary,\r\n description: this.documentation\r\n });\r\n\r\n // Monkey-patch the error handling for the action parser\r\n this._argumentParser.exit = (status: number, message: string) => {\r\n throw new CommandLineParserExitError(status, message);\r\n };\r\n const originalArgumentParserErrorFn: (err: Error | string) => void = this._argumentParser.error.bind(\r\n this._argumentParser\r\n );\r\n this._argumentParser.error = (err: Error | string) => {\r\n // Ensure the ParserExitError bubbles up to the top without any special processing\r\n if (err instanceof CommandLineParserExitError) {\r\n throw err;\r\n }\r\n originalArgumentParserErrorFn(err);\r\n };\r\n\r\n this.onDefineParameters?.();\r\n }\r\n\r\n /**\r\n * This is called internally by CommandLineParser.execute()\r\n * @internal\r\n */\r\n public _processParsedData(parserOptions: ICommandLineParserOptions, data: ICommandLineParserData): void {\r\n super._processParsedData(parserOptions, data);\r\n }\r\n\r\n /**\r\n * Invoked by CommandLineParser.onExecute().\r\n * @internal\r\n */\r\n public _execute(): Promise<void> {\r\n return this.onExecute();\r\n }\r\n\r\n /**\r\n * {@inheritDoc CommandLineParameterProvider._getArgumentParser}\r\n * @internal\r\n */\r\n protected _getArgumentParser(): argparse.ArgumentParser {\r\n // override\r\n if (!this._argumentParser) {\r\n // We will improve this in the future\r\n throw new Error('The CommandLineAction must be added to a CommandLineParser before it can be used');\r\n }\r\n\r\n return this._argumentParser;\r\n }\r\n\r\n /**\r\n * Your subclass should implement this hook to perform the operation.\r\n */\r\n protected abstract onExecute(): Promise<void>;\r\n}\r\n"]}
1
+ {"version":3,"file":"CommandLineAction.js","sourceRoot":"","sources":["../../src/providers/CommandLineAction.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAI3D,iFAA2G;AAE3G,6EAA0E;AA0B1E;;GAEG;AACH,MAA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A,IAAI,CAAC,kBAAkB,oDAAI,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACI,kBAAkB,CAAC,aAAwC,EAAE,IAA4B;QAC9F,KAAK,CAAC,kBAAkB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAChD,CAAC;IAED;;;OAGG;IACI,QAAQ;QACb,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACO,kBAAkB;QAC1B,WAAW;QACX,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,qCAAqC;YACrC,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;SACrG;QAED,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;CAMF;AA3FD,8CA2FC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type * as argparse from 'argparse';\n\nimport { CommandLineParameterProvider, type ICommandLineParserData } from './CommandLineParameterProvider';\nimport type { ICommandLineParserOptions } from './CommandLineParser';\nimport { CommandLineParserExitError } from './CommandLineParserExitError';\n\n/**\n * Options for the CommandLineAction constructor.\n * @public\n */\nexport interface ICommandLineActionOptions {\n /**\n * The name of the action. For example, if the tool is called \"example\",\n * then the \"build\" action might be invoked as: \"example build -q --some-other-option\"\n */\n actionName: string;\n\n /**\n * A quick summary that is shown on the main help page, which is displayed\n * by the command \"example --help\"\n */\n summary: string;\n\n /**\n * A detailed description that is shown on the action help page, which is displayed\n * by the command \"example build --help\", e.g. for actionName=\"build\".\n */\n documentation: string;\n}\n\n/**\n * Example: \"do-something\"\n */\nconst ACTION_NAME_REGEXP: RegExp = /^[a-z][a-z0-9]*([-:][a-z0-9]+)*$/;\n\n/**\n * Represents a sub-command that is part of the CommandLineParser command line.\n * Applications should create subclasses of CommandLineAction 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 * @public\n */\nexport abstract class CommandLineAction extends CommandLineParameterProvider {\n /** {@inheritDoc ICommandLineActionOptions.actionName} */\n public readonly actionName: string;\n\n /** {@inheritDoc ICommandLineActionOptions.summary} */\n public readonly summary: string;\n\n /** {@inheritDoc ICommandLineActionOptions.documentation} */\n public readonly documentation: string;\n\n private _argumentParser: argparse.ArgumentParser | undefined;\n\n public constructor(options: ICommandLineActionOptions) {\n super();\n\n if (!ACTION_NAME_REGEXP.test(options.actionName)) {\n throw new Error(\n `Invalid action name \"${options.actionName}\". ` +\n `The name must be comprised of lower-case words optionally separated by hyphens or colons.`\n );\n }\n\n this.actionName = options.actionName;\n this.summary = options.summary;\n this.documentation = options.documentation;\n\n this._argumentParser = undefined;\n }\n\n /**\n * This is called internally by CommandLineParser.addAction()\n * @internal\n */\n public _buildParser(actionsSubParser: argparse.SubParser): void {\n this._argumentParser = actionsSubParser.addParser(this.actionName, {\n help: this.summary,\n description: this.documentation\n });\n\n // Monkey-patch the error handling for the action parser\n this._argumentParser.exit = (status: number, message: string) => {\n throw new CommandLineParserExitError(status, message);\n };\n const originalArgumentParserErrorFn: (err: Error | string) => void = this._argumentParser.error.bind(\n this._argumentParser\n );\n this._argumentParser.error = (err: Error | string) => {\n // Ensure the ParserExitError bubbles up to the top without any special processing\n if (err instanceof CommandLineParserExitError) {\n throw err;\n }\n originalArgumentParserErrorFn(err);\n };\n\n this.onDefineParameters?.();\n }\n\n /**\n * This is called internally by CommandLineParser.execute()\n * @internal\n */\n public _processParsedData(parserOptions: ICommandLineParserOptions, data: ICommandLineParserData): void {\n super._processParsedData(parserOptions, data);\n }\n\n /**\n * Invoked by CommandLineParser.onExecute().\n * @internal\n */\n public _execute(): Promise<void> {\n return this.onExecute();\n }\n\n /**\n * {@inheritDoc CommandLineParameterProvider._getArgumentParser}\n * @internal\n */\n protected _getArgumentParser(): argparse.ArgumentParser {\n // override\n if (!this._argumentParser) {\n // We will improve this in the future\n throw new Error('The CommandLineAction must be added to a CommandLineParser before it can be used');\n }\n\n return this._argumentParser;\n }\n\n /**\n * Your subclass should implement this hook to perform the operation.\n */\n protected abstract onExecute(): Promise<void>;\n}\n"]}