MCPcopy Create free account
hub / github.com/chhoumann/quickadd / extractVariables

Function extractVariables

src/cli/registerQuickAddCliHandlers.ts:222–244  ·  view source on GitHub ↗
(
	params: CliData,
	reservedKeys: Set<string>,
)

Source from the content-addressed store, hash-verified

220// execution (quickadd:run can run a Macro choice), so this is not an escalation
221// boundary.
222function extractVariables(
223 params: CliData,
224 reservedKeys: Set<string>,
225): Record<string, unknown> {
226 const variables: Record<string, unknown> = {};
227
228 if (typeof params.vars === "string") {
229 Object.assign(variables, parseVarsJson(params.vars));
230 }
231
232 for (const [key, value] of Object.entries(params)) {
233 if (key.startsWith("value-")) {
234 const variableName = key.slice(6);
235 if (variableName) variables[variableName] = value;
236 continue;
237 }
238
239 if (reservedKeys.has(key)) continue;
240 variables[key] = value;
241 }
242
243 return variables;
244}
245
246function flattenChoices(
247 choices: IChoice[],

Callers 4

runResolvedChoiceFunction · 0.85
runTemplateHandlerFunction · 0.85
checkChoiceHandlerFunction · 0.85
interactiveHandlerFunction · 0.85

Calls 1

parseVarsJsonFunction · 0.85

Tested by

no test coverage detected