MCPcopy
hub / github.com/coder/mux / parseKeyValueArgs

Function parseKeyValueArgs

src/cli/workflow.ts:126–138  ·  view source on GitHub ↗
(values: readonly string[])

Source from the content-addressed store, hash-verified

124}
125
126function parseKeyValueArgs(values: readonly string[]): Record<string, unknown> {
127 const result: Record<string, unknown> = {};
128 for (const value of values) {
129 const eqIndex = value.indexOf("=");
130 if (eqIndex <= 0) {
131 throw new Error(`Invalid --arg "${value}". Expected key=value`);
132 }
133 const key = value.slice(0, eqIndex).trim();
134 assert(key.length > 0, "Workflow --arg key must be non-empty");
135 result[key] = parseScalar(value.slice(eqIndex + 1).trim());
136 }
137 return result;
138}
139
140function parseScalar(value: string): unknown {
141 if (value === "true") return true;

Callers 1

parseWorkflowArgsFunction · 0.85

Calls 2

parseScalarFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected