1 line
3.9 KiB
Plaintext
1 line
3.9 KiB
Plaintext
{"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"]} |