{"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,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,MAAM,CAAC;IACzC,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,EAAE;gBAClC,mEAAmE;gBACnE,0FAA0F;gBAC1F,IAAI,CAAC,MAAM,GAAG,gBAAgB,CAAC;gBAC/B,OAAO;aACR;SACF;QAED,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;YACnC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC;YAChC,OAAO;SACR;QAED,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,sBAAsB,CAAC,kBAA4B;QACxD,UAAU;QACV,KAAK,CAAC,sBAAsB,CAAC,kBAAkB,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;YACnC,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,GAAG,EAAE;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.\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"]}