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

Function parseArgs

scripts/telemetry-log.cjs:15–36  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

13const { logAgentRunEvent } = require('../core/telemetry/log');
14
15function parseArgs(argv) {
16 const args = {};
17 for (let i = 2; i < argv.length; i++) {
18 const key = argv[i];
19 const val = argv[i + 1];
20 if (key === '--event') { args.event = val; i++; }
21 else if (key === '--agent') { args.agent = val; i++; }
22 else if (key === '--session') { args.session = val; i++; }
23 else if (key === '--run-id') { args.run_id = val; i++; }
24 else if (key === '--agent-id') { args.agent_id = val; i++; }
25 else if (key === '--task-id') { args.task_id = val; i++; }
26 else if (key === '--parent-id') { args.parent_id = val; i++; }
27 else if (key === '--source-event-id') { args.source_event_id = val; i++; }
28 else if (key === '--duration') { args.duration = parseInt(val, 10); i++; }
29 else if (key === '--status') { args.status = val; i++; }
30 else if (key === '--meta') {
31 try { args.meta = JSON.parse(val); } catch { args.meta = val; }
32 i++;
33 }
34 }
35 return args;
36}
37
38function main() {
39 const args = parseArgs(process.argv);

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected