( metadata: Pick<CommandMetadata<string, unknown>, 'inputSchema'>, options: InternalRequestOptions, )
| 19 | } |
| 20 | |
| 21 | export 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 | |
| 38 | function isMetadataFlagValue(value: unknown): value is boolean | number | string { |
| 39 | return typeof value === 'boolean' || typeof value === 'number' || typeof value === 'string'; |
no test coverage detected