MCPcopy Index your code
hub / github.com/microsoft/vscode-cpptools / parseFlags

Function parseFlags

Extension/src/SSH/sshCommandToConfig.ts:174–201  ·  view source on GitHub ↗

* Parses flags from the given array of arguments, returning the index of the * next non-flag in the input (or the total length of the input if none are found).

(input: string[], entries: { [key: string]: string })

Source from the content-addressed store, hash-verified

172 * next non-flag in the input (or the total length of the input if none are found).
173 */
174function parseFlags(input: string[], entries: { [key: string]: string }): number {
175 // prefix with `:` to tell the library not to log anything itself
176 const parser: BasicParser = new BasicParser(`:${getOptDirective}`, input, 0);
177
178 while (true) {
179 const next: IParsedOption | undefined = parser.getopt();
180 if (!next) {
181 break;
182 }
183
184 if (next.option === ':') {
185 throw new CommandParseError(`Expected flag -${next.optopt} to have an argument but it did not`);
186 }
187
188 if (next.option === '?') {
189 throw new CommandParseError(`Unknown flag ${next.optopt}`);
190 }
191
192 const resolver: ((entries: { [key: string]: string }, value: string) => void) | null = flags[next.option];
193 if (!resolver) {
194 continue; // known but ignored flag
195 }
196
197 resolver(entries, next.optarg);
198 }
199
200 return parser.optind();
201}
202
203/**
204 * Parses the SSH connection address. This behaves like OpenSSH and for the

Callers 1

sshCommandToConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected