MCPcopy Index your code
hub / github.com/callstack/agent-device / readMetadataCommandFlags

Function readMetadataCommandFlags

src/commands/command-flags.ts:21–36  ·  view source on GitHub ↗
(
  metadata: Pick<CommandMetadata<string, unknown>, 'inputSchema'>,
  options: InternalRequestOptions,
)

Source from the content-addressed store, hash-verified

19}
20
21export function readMetadataCommandFlags(
22 metadata: Pick<CommandMetadata<string, unknown>, 'inputSchema'>,
23 options: InternalRequestOptions,
24): Partial<CommandFlags> {
25 const properties = metadata.inputSchema.properties;
26 if (!properties) return {};
27
28 const flags: Record<string, unknown> = {};
29 const record = options as Record<string, unknown>;
30 for (const key of Object.keys(properties)) {
31 if (!CLI_FLAG_KEYS.has(key)) continue;
32 const value = record[key];
33 if (isMetadataFlagValue(value)) flags[key] = value;
34 }
35 return flags as Partial<CommandFlags>;
36}
37
38function isMetadataFlagValue(value: unknown): value is boolean | number | string {
39 return typeof value === 'boolean' || typeof value === 'number' || typeof value === 'string';

Callers 2

Calls 1

isMetadataFlagValueFunction · 0.85

Tested by

no test coverage detected