MCPcopy Create free account
hub / github.com/openai/plugins / parseArgs

Function parseArgs

plugins/openai-developers/scripts/openai-platform-api-key.mjs:43–69  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

41}
42
43function parseArgs(argv) {
44 const args = { _: [] };
45 for (let index = 0; index < argv.length; index += 1) {
46 const arg = argv[index];
47 if (!arg.startsWith("--")) {
48 args._.push(arg);
49 continue;
50 }
51 const key = arg.slice(2);
52 if (!VALID_OPTIONS.has(key)) {
53 fail(`Unknown option: --${key}.`);
54 }
55 const value = argv[index + 1];
56 if (OPTIONS_WITH_VALUES.has(key)) {
57 if (value == null) {
58 fail(`Missing value for --${key}.`);
59 }
60 if (value.startsWith("--") && !OPTIONS_ALLOWING_DASH_VALUES.has(key)) {
61 fail(`Missing value for --${key}.`);
62 }
63 args[key] = value;
64 index += 1;
65 continue;
66 }
67 }
68 return args;
69}
70
71function printJson(value) {
72 process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);

Callers 15

mainFunction · 0.70
search_docs.mjsFile · 0.50
validate.mjsFile · 0.50
search_docs.mjsFile · 0.50
validate.mjsFile · 0.50
search_docs.mjsFile · 0.50
validate.mjsFile · 0.50
search_docs.mjsFile · 0.50
validate.mjsFile · 0.50
search_docs.mjsFile · 0.50
validate.mjsFile · 0.50
search_docs.mjsFile · 0.50

Calls 2

failFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected