(
schema: ToolSchemaShape,
opts: SchemaToYargsOptionsOptions = {},
)
| 244 | * Returns a map of flag names (kebab-case) to yargs options. |
| 245 | */ |
| 246 | export function schemaToYargsOptions( |
| 247 | schema: ToolSchemaShape, |
| 248 | opts: SchemaToYargsOptionsOptions = {}, |
| 249 | ): Map<string, YargsOptionConfig> { |
| 250 | const options = new Map<string, YargsOptionConfig>(); |
| 251 | |
| 252 | for (const [key, zodType] of Object.entries(schema)) { |
| 253 | const opt = zodToYargsOption(zodType, { |
| 254 | hasHydratedDefault: Object.prototype.hasOwnProperty.call(opts.hydratedDefaults ?? {}, key), |
| 255 | }); |
| 256 | if (opt) { |
| 257 | const flagName = toKebabCase(key); |
| 258 | options.set(flagName, opt); |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | return options; |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * Get list of schema keys that couldn't be converted to CLI flags. |
no test coverage detected