MCPcopy
hub / github.com/BuilderIO/agent-native / parseArgs

Function parseArgs

packages/core/src/scripts/parse-args.ts:10–32  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

8 * Supports: --key value, --key=value, --flag (boolean true)
9 */
10export function parseArgs(args: string[]): Record<string, string> {
11 const result: Record<string, string> = {};
12 for (let i = 0; i < args.length; i++) {
13 const arg = args[i];
14 if (!arg.startsWith("--")) continue;
15
16 const eqIndex = arg.indexOf("=");
17 if (eqIndex !== -1) {
18 const key = arg.slice(2, eqIndex);
19 result[key] = arg.slice(eqIndex + 1);
20 } else {
21 const key = arg.slice(2);
22 const next = args[i + 1];
23 if (next && !next.startsWith("--")) {
24 result[key] = next;
25 i++;
26 } else {
27 result[key] = "true";
28 }
29 }
30 }
31 return result;
32}
33
34/**
35 * Convert kebab-case keys to camelCase.

Callers 15

delete-pin.tsFile · 0.90
get-pins.tsFile · 0.90
resolve-pin.tsFile · 0.90
update-pin.tsFile · 0.90
create-pin.tsFile · 0.90
extract-pdf.tsFile · 0.90
fetch-logos.tsFile · 0.90
helloFunction · 0.90
helloFunction · 0.90
helloFunction · 0.90
utils.spec.tsFile · 0.70
saveMemoryScriptFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected