| 5675 | } |
| 5676 | |
| 5677 | fn print_list_simulators(simulators: &Value, format: ListFormat) -> anyhow::Result<()> { |
| 5678 | match format { |
| 5679 | ListFormat::Json => { |
| 5680 | println_json(&serde_json::json!({ "simulators": simulators }))?; |
| 5681 | } |
| 5682 | ListFormat::CompactJson => { |
| 5683 | let compact = simulators |
| 5684 | .as_array() |
| 5685 | .map(|items| { |
| 5686 | items |
| 5687 | .iter() |
| 5688 | .map(compact_simulator_list_entry) |
| 5689 | .collect::<Vec<_>>() |
| 5690 | }) |
| 5691 | .unwrap_or_default(); |
| 5692 | println!( |
| 5693 | "{}", |
| 5694 | serde_json::to_string(&serde_json::json!({ "simulators": compact }))? |
| 5695 | ); |
| 5696 | } |
| 5697 | } |
| 5698 | Ok(()) |
| 5699 | } |
| 5700 | |
| 5701 | fn compact_simulator_list_entry(simulator: &Value) -> Value { |
| 5702 | let mut entry = serde_json::Map::new(); |