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

Function readEnvFlagDefaults

src/utils/cli-config.ts:124–141  ·  view source on GitHub ↗
(env: EnvMap, command: string | null)

Source from the content-addressed store, hash-verified

122}
123
124function readEnvFlagDefaults(env: EnvMap, command: string | null): Partial<CliFlags> {
125 const flags: Partial<CliFlags> = {};
126 for (const spec of getConfigurableOptionSpecs(command)) {
127 if (spec.key === 'installSource') continue;
128 const envNames = spec.env.names;
129 const envValue = envNames
130 .map((name) => ({ name, value: env[name] }))
131 .find((entry) => typeof entry.value === 'string' && entry.value.trim().length > 0);
132 if (!envValue) continue;
133 (flags as Record<string, unknown>)[spec.key] = parseOptionValueFromSource(
134 spec,
135 envValue.value as string,
136 `environment variable ${envValue.name}`,
137 envValue.name,
138 );
139 }
140 return flags;
141}

Callers 1

Calls 2

Tested by

no test coverage detected