MCPcopy Index your code
hub / github.com/TypeScriptToLua/TypeScriptToLua / updateParsedCommandLine

Function updateParsedCommandLine

src/cli/parse.ts:145–180  ·  view source on GitHub ↗
(parsedCommandLine: ts.ParsedCommandLine, args: string[])

Source from the content-addressed store, hash-verified

143}
144
145function updateParsedCommandLine(parsedCommandLine: ts.ParsedCommandLine, args: string[]): ParsedCommandLine {
146 for (let i = 0; i < args.length; i++) {
147 if (!args[i].startsWith("-")) continue;
148
149 const isShorthand = !args[i].startsWith("--");
150 const argumentName = args[i].substring(isShorthand ? 1 : 2);
151 const option = optionDeclarations.find(option => {
152 if (option.name.toLowerCase() === argumentName.toLowerCase()) return true;
153 if (isShorthand && option.aliases) {
154 return option.aliases.some(a => a.toLowerCase() === argumentName.toLowerCase());
155 }
156
157 return false;
158 });
159
160 if (option) {
161 // Ignore errors caused by tstl specific compiler options
162 parsedCommandLine.errors = parsedCommandLine.errors.filter(
163 // TS5023: Unknown compiler option '{0}'.
164 // TS5025: Unknown compiler option '{0}'. Did you mean '{1}'?
165 e => !((e.code === 5023 || e.code === 5025) && String(e.messageText).includes(`'${args[i]}'.`))
166 );
167
168 const { error, value, consumed } = readCommandLineArgument(option, args[i + 1]);
169 if (error) parsedCommandLine.errors.push(error);
170 parsedCommandLine.options[option.name] = value;
171 if (consumed) {
172 // Values of custom options are parsed as a file name, exclude them
173 parsedCommandLine.fileNames = parsedCommandLine.fileNames.filter(f => f !== args[i + 1]);
174 i += 1;
175 }
176 }
177 }
178
179 return parsedCommandLine;
180}
181
182interface CommandLineArgument extends ReadValueResult {
183 consumed: boolean;

Callers 1

parseCommandLineFunction · 0.85

Calls 1

readCommandLineArgumentFunction · 0.85

Tested by

no test coverage detected