Print pre-formatted output in specified format (json/yaml/table). Use this when converter functions return `Result ` instead of `serde_json::Value`. # Returns - `Ok(true)` if format was handled (json/yaml), caller should return - `Ok(false)` if format is "table", caller should continue to table rendering - `Err` for unsupported formats or conversion errors # Example ```ignore if print_ou
(format: impl AsRef<str>, json_fn: J, yaml_fn: Y)
| 140 | /// } |
| 141 | /// ``` |
| 142 | pub fn print_output_direct<J, Y>(format: impl AsRef<str>, json_fn: J, yaml_fn: Y) -> Result<bool> |
| 143 | where |
| 144 | J: FnOnce() -> Result<String>, |
| 145 | Y: FnOnce() -> Result<String>, |
| 146 | { |
| 147 | match format.as_ref() { |
| 148 | "json" => { |
| 149 | let json = json_fn()?; |
| 150 | println!("{json}"); |
| 151 | Ok(true) |
| 152 | } |
| 153 | "yaml" => { |
| 154 | let yaml = yaml_fn()?; |
| 155 | print!("{yaml}"); |
| 156 | Ok(true) |
| 157 | } |
| 158 | "table" => Ok(false), |
| 159 | _ => Err(miette::miette!( |
| 160 | "unsupported output format: {}", |
| 161 | format.as_ref() |
| 162 | )), |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | /// Print collection output to a custom writer in specified format (json/yaml/table). |
| 167 | /// |
no outgoing calls