MCPcopy Create free account
hub / github.com/SethGammon/Citadel / parseArgs

Function parseArgs

scripts/deploy-steward.js:11–59  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

9} = require('../core/deploy-steward/steward');
10
11function parseArgs(argv) {
12 const args = {
13 projectRoot: process.cwd(),
14 scan: false,
15 run: false,
16 dryRun: false,
17 json: false,
18 enqueue: [],
19 mergeMode: 'serial',
20 mergeMethod: 'squash',
21 deleteBranch: true,
22 write: true,
23 };
24
25 for (let index = 0; index < argv.length; index++) {
26 const arg = argv[index];
27 const next = argv[index + 1];
28 if (arg === '--project-root') { args.projectRoot = path.resolve(next || '.'); index++; }
29 else if (arg === '--scan') args.scan = true;
30 else if (arg === '--run') args.run = true;
31 else if (arg === '--dry-run') args.dryRun = true;
32 else if (arg === '--json') args.json = true;
33 else if (arg === '--no-write') args.write = false;
34 else if (arg === '--enqueue-pr') { args.enqueue.push({ pr: next }); index++; }
35 else if (arg === '--branch') { args.branch = next || null; index++; }
36 else if (arg === '--head') { args.head = next || null; index++; }
37 else if (arg === '--merge-mode') { args.mergeMode = next || 'serial'; index++; }
38 else if (arg === '--merge-method') { args.mergeMethod = next || 'squash'; index++; }
39 else if (arg === '--keep-branch') args.deleteBranch = false;
40 else if (arg === '--deploy-command') { args.deployCommand = next || ''; index++; }
41 else if (arg === '--allow-no-checks') args.allowNoChecks = true;
42 else if (arg === '--require-fresh-readiness') args.requireFreshReadiness = true;
43 else if (arg === '--force-lease') args.forceLease = true;
44 else if (arg === '--max-items') { args.maxItems = Number.parseInt(next, 10); index++; }
45 else if (arg === '--gh') { args.gh = next || 'gh'; index++; }
46 else if (arg === '--help' || arg === '-h') args.help = true;
47 else if (!arg.startsWith('-')) args.enqueue.push({ pr: arg });
48 }
49
50 if (!['serial', 'merge-queue'].includes(args.mergeMode)) {
51 throw new Error('--merge-mode must be serial or merge-queue');
52 }
53 if (!['squash', 'merge', 'rebase'].includes(args.mergeMethod)) {
54 throw new Error('--merge-method must be squash, merge, or rebase');
55 }
56 if (!Number.isFinite(args.maxItems)) delete args.maxItems;
57
58 return args;
59}
60
61function usage() {
62 return [

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected