MCPcopy Index your code
hub / github.com/codebymitch/TitanBot / parseArgs

Function parseArgs

scripts/restore-drill.js:14–40  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

12const { Pool } = pg;
13
14function parseArgs(argv) {
15 const args = {};
16
17 for (let index = 0; index < argv.length; index += 1) {
18 const token = argv[index];
19 if (!token.startsWith('--')) {
20 continue;
21 }
22
23 const [rawKey, inlineValue] = token.slice(2).split('=');
24 if (typeof inlineValue !== 'undefined') {
25 args[rawKey] = inlineValue;
26 continue;
27 }
28
29 const nextToken = argv[index + 1];
30 if (!nextToken || nextToken.startsWith('--')) {
31 args[rawKey] = true;
32 continue;
33 }
34
35 args[rawKey] = nextToken;
36 index += 1;
37 }
38
39 return args;
40}
41
42function ensureCommand(command) {
43 const result = spawnSync(command, ['--version'], {

Callers 1

runFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected