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GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;oBACrD,GAAG,EAAE,CAAC;gBACV,CAAC;gBACD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;YAC1C,CAAC;QACL,CAAC;QAED,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACrC,CAAC;IACL,sBAAC;AAAD,CAAC,AApGD,CAAqC,0BAAgB,GAoGpD;AApGY,eAAe;IAD3B,qBAAS,CAAC,EAAC,IAAI,EAAE,mBAAmB,EAAC,CAAC;GAC1B,eAAe,CAoG3B;AApGY,0CAAe","sourcesContent":["import * as ts from 'typescript';\nimport * as _ts from '../../../ts-internal';\n\nimport {Component} from '../../component';\nimport {DiscoverEvent, OptionsComponent} from '../options';\nimport {ParameterType} from '../declaration';\n\n@Component({name: 'options:arguments'})\nexport class ArgumentsReader extends OptionsComponent {\n initialize() {\n this.listenTo(this.owner, DiscoverEvent.DISCOVER, this.onDiscover);\n }\n\n onDiscover(event: DiscoverEvent) {\n if (this.application.isCLI) {\n this.parseArguments(event);\n }\n }\n\n /**\n * Read and store the given list of arguments.\n *\n * @param args The list of arguments that should be parsed. When omitted the\n * current command line arguments will be used.\n * @param ignoreUnknownArgs Should unknown arguments be ignored? If so the parser\n * will simply skip all unknown arguments.\n * @returns TRUE on success, otherwise FALSE.\n */\n private parseArguments(event: DiscoverEvent, args?: string[]) {\n let index = 0;\n const owner = this.owner;\n args = args || process.argv.slice(2);\n\n function readArgument(arg: string) {\n const declaration = owner.getDeclaration(arg);\n if (!declaration) {\n event.addError('Unknown option: %s', arg);\n } else if (declaration.type !== ParameterType.Boolean) {\n if (!args[index]) {\n event.addError('Option \"%s\" expects an argument', declaration.name);\n } else {\n event.data[declaration.name] = args[index++];\n }\n } else {\n event.data[declaration.name] = true;\n }\n }\n\n while (index < args.length) {\n const arg = args[index++];\n\n if (arg.charCodeAt(0) === _ts.CharacterCodes.at) {\n this.parseResponseFile(event, arg.slice(1));\n } else if (arg.charCodeAt(0) === _ts.CharacterCodes.minus) {\n readArgument(arg.slice(arg.charCodeAt(1) === _ts.CharacterCodes.minus ? 2 : 1).toLowerCase());\n } else {\n event.addInputFile(arg);\n }\n }\n }\n\n /**\n * Read the arguments stored in the given file.\n *\n * @param filename The path and filename that should be parsed.\n * @param ignoreUnknownArgs Should unknown arguments be ignored?\n * @returns TRUE on success, otherwise FALSE.\n */\n private parseResponseFile(event: DiscoverEvent, filename: string) {\n const text = ts.sys.readFile(filename);\n if (!text) {\n event.addError('File not found: \"%s\"', filename);\n return;\n }\n\n const args: string[] = [];\n let pos = 0;\n while (true) {\n while (pos < text.length && text.charCodeAt(pos) <= _ts.CharacterCodes.space) {\n pos++;\n }\n if (pos >= text.length) {\n break;\n }\n\n const start = pos;\n if (text.charCodeAt(start) === _ts.CharacterCodes.doubleQuote) {\n pos++;\n while (pos < text.length && text.charCodeAt(pos) !== _ts.CharacterCodes.doubleQuote) {\n pos++;\n }\n if (pos < text.length) {\n args.push(text.substring(start + 1, pos));\n pos++;\n } else {\n event.addError('Unterminated quoted string in response file \"%s\"', filename);\n return;\n }\n } else {\n while (text.charCodeAt(pos) > _ts.CharacterCodes.space) {\n pos++;\n }\n args.push(text.substring(start, pos));\n }\n }\n\n this.parseArguments(event, args);\n }\n}\n"]}
|