| 30 | |
| 31 | impl Command for MemoryKinds { |
| 32 | fn run(&self) -> CliResult<()> { |
| 33 | if self.json { |
| 34 | let arr: Vec<serde_json::Value> = MEMORY_KIND_GUIDANCE |
| 35 | .iter() |
| 36 | .map(|(kind, description)| { |
| 37 | serde_json::json!({ "kind": kind, "description": description }) |
| 38 | }) |
| 39 | .collect(); |
| 40 | println!("{}", serde_json::to_string_pretty(&arr).unwrap()); |
| 41 | return Ok(()); |
| 42 | } |
| 43 | |
| 44 | let width = MEMORY_KIND_GUIDANCE |
| 45 | .iter() |
| 46 | .map(|(k, _)| k.len()) |
| 47 | .max() |
| 48 | .unwrap_or(0); |
| 49 | println!( |
| 50 | "Allowed memory kinds (pick the best fit; create one memory per durable insight):" |
| 51 | ); |
| 52 | println!(); |
| 53 | for (kind, description) in MEMORY_KIND_GUIDANCE { |
| 54 | println!(" {:<width$} {}", kind, description, width = width); |
| 55 | } |
| 56 | Ok(()) |
| 57 | } |
| 58 | } |