MCPcopy
hub / github.com/callstack/agent-device / parseConfigObject

Function parseConfigObject

src/utils/cli-config.ts:96–122  ·  view source on GitHub ↗
(
  source: Record<string, unknown>,
  sourceLabel: string,
)

Source from the content-addressed store, hash-verified

94}
95
96function parseConfigObject(
97 source: Record<string, unknown>,
98 sourceLabel: string,
99): Partial<CliFlags> {
100 const flags: Partial<CliFlags> = {};
101 for (const [rawKey, rawValue] of Object.entries(source)) {
102 if (rawKey === 'installSource') {
103 flags.installSource = parseInstallSourceConfig(rawValue, sourceLabel);
104 continue;
105 }
106 const key = rawKey as FlagKey;
107 const spec = getOptionSpec(key);
108 if (!spec) {
109 throw new AppError('INVALID_ARGS', `Unknown config key "${rawKey}" in ${sourceLabel}.`);
110 }
111 if (!spec.config.enabled) {
112 throw new AppError('INVALID_ARGS', `Unsupported config key "${rawKey}" in ${sourceLabel}.`);
113 }
114 (flags as Record<string, unknown>)[key] = parseOptionValueFromSource(
115 spec,
116 rawValue,
117 sourceLabel,
118 rawKey,
119 );
120 }
121 return flags;
122}
123
124function readEnvFlagDefaults(env: EnvMap, command: string | null): Partial<CliFlags> {
125 const flags: Partial<CliFlags> = {};

Callers 1

loadSingleConfigFileFunction · 0.85

Calls 3

parseInstallSourceConfigFunction · 0.90
getOptionSpecFunction · 0.90

Tested by

no test coverage detected