(value: &T, cli: &Cli)
| 80 | } |
| 81 | |
| 82 | pub(crate) fn print_value<T>(value: &T, cli: &Cli) |
| 83 | where |
| 84 | T: Serialize, |
| 85 | { |
| 86 | let str = match (&cli.output_format, &cli.output_pretty) { |
| 87 | (OutputFormat::Json, true) => Highlighter::new() |
| 88 | .highlight_to_string( |
| 89 | inkjet::Language::Json, |
| 90 | &ColorPrinter::new(), |
| 91 | serde_json::to_string_pretty(value).unwrap(), |
| 92 | ) |
| 93 | .unwrap(), |
| 94 | (OutputFormat::Json, false) => serde_json::to_string(value).unwrap(), |
| 95 | (OutputFormat::Yaml, true) => Highlighter::new() |
| 96 | .highlight_to_string( |
| 97 | inkjet::Language::Yaml, |
| 98 | &ColorPrinter::new(), |
| 99 | serde_yaml::to_string(value).unwrap(), |
| 100 | ) |
| 101 | .unwrap(), |
| 102 | (OutputFormat::Yaml, false) => serde_yaml::to_string(value).unwrap(), |
| 103 | }; |
| 104 | |
| 105 | print!("{}", str); |
| 106 | } |
| 107 | |
| 108 | #[derive(Deserialize, Serialize)] |
| 109 | #[serde(untagged)] |
no outgoing calls
no test coverage detected