(&self, text_fn: TFn, json_fn: JFn)
| 77 | |
| 78 | impl OutputFormat { |
| 79 | pub fn print<T, TFn, J, JFn>(&self, text_fn: TFn, json_fn: JFn) |
| 80 | where |
| 81 | T: std::fmt::Display, |
| 82 | TFn: FnOnce() -> T, |
| 83 | J: Serialize, |
| 84 | JFn: FnOnce() -> J, |
| 85 | { |
| 86 | match self { |
| 87 | OutputFormat::Plain => println!("{}", text_fn()), |
| 88 | OutputFormat::Json => println!("{}", serde_json::to_string(&json_fn()).unwrap()), |
| 89 | OutputFormat::JsonPretty => println!("{}", serde_json::to_string_pretty(&json_fn()).unwrap()), |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | /// The Amazon Q CLI |