(
def: &ToolDefinition,
schema_properties: &Map<String, Value>,
required: &[String],
collected: &mut Map<String, Value>,
positionals: Vec<String>,
read_stdin: &mut impl FnMut()
| 510 | } |
| 511 | |
| 512 | fn bind_positionals( |
| 513 | def: &ToolDefinition, |
| 514 | schema_properties: &Map<String, Value>, |
| 515 | required: &[String], |
| 516 | collected: &mut Map<String, Value>, |
| 517 | positionals: Vec<String>, |
| 518 | read_stdin: &mut impl FnMut() -> Result<String>, |
| 519 | ) -> Result<()> { |
| 520 | let mut positional_iter = positionals.into_iter(); |
| 521 | for req in required { |
| 522 | if collected.contains_key(req) { |
| 523 | continue; |
| 524 | } |
| 525 | let Some(prop) = schema_properties.get(req) else { |
| 526 | continue; |
| 527 | }; |
| 528 | let Some(value) = positional_iter.next() else { |
| 529 | break; |
| 530 | }; |
| 531 | let resolved = resolve_at_file(&value, read_stdin)?; |
| 532 | let coerced = coerce_value(req, Some(prop), &resolved)?; |
| 533 | collected.insert(req.clone(), coerced); |
| 534 | } |
| 535 | let leftover: Vec<String> = positional_iter.collect(); |
| 536 | if leftover.is_empty() { |
| 537 | return Ok(()); |
| 538 | } |
| 539 | Err(TraceDecayError::Config { |
| 540 | message: format!( |
| 541 | "unexpected positional argument(s): {} — use --key value flags or \ |
| 542 | run `tracedecay tool {} --help`", |
| 543 | leftover.join(" "), |
| 544 | short_tool_name(&def.name) |
| 545 | ), |
| 546 | }) |
| 547 | } |
| 548 | |
| 549 | /// Resolve a `--args` value to its JSON text. `--args` is a *whole-payload* |
| 550 | /// argument (the value IS the object), so it follows the same convention as |
no test coverage detected