(
key: &str,
short: &str,
props: &Map<String, Value>,
required: &[String],
)
| 362 | } |
| 363 | |
| 364 | fn unknown_key_error( |
| 365 | key: &str, |
| 366 | short: &str, |
| 367 | props: &Map<String, Value>, |
| 368 | required: &[String], |
| 369 | ) -> TraceDecayError { |
| 370 | let suggestion = nearest_key(key, props) |
| 371 | .map(|k| format!(" — did you mean `--{}`?", k.replace('_', "-"))) |
| 372 | .unwrap_or_default(); |
| 373 | let mut valid: Vec<String> = props |
| 374 | .keys() |
| 375 | .map(|k| { |
| 376 | let flag = format!("--{}", k.replace('_', "-")); |
| 377 | if required.contains(k) { |
| 378 | format!("{flag} (required)") |
| 379 | } else { |
| 380 | flag |
| 381 | } |
| 382 | }) |
| 383 | .collect(); |
| 384 | valid.sort(); |
| 385 | TraceDecayError::Config { |
| 386 | message: format!( |
| 387 | "unknown parameter `--{}` for `{short}`{suggestion} Valid: {}", |
| 388 | key.replace('_', "-"), |
| 389 | valid.join(", ") |
| 390 | ), |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | /// True when a JSON value is acceptable for a schema `type` string. `number` |
| 395 | /// accepts integers; `integer` requires a whole number. Unknown schema types |
no test coverage detected