Print settings list in JSON or JSON Pretty format
(settings: &[SettingInfo], pretty: bool)
| 149 | |
| 150 | /// Print settings list in JSON or JSON Pretty format |
| 151 | fn print_settings_json(settings: &[SettingInfo], pretty: bool) -> Result<()> { |
| 152 | let settings_list: Vec<_> = settings |
| 153 | .iter() |
| 154 | .map(|s| { |
| 155 | json!({ |
| 156 | "key": s.key, |
| 157 | "description": s.description, |
| 158 | "current_value": s.current_value, |
| 159 | }) |
| 160 | }) |
| 161 | .collect(); |
| 162 | |
| 163 | let output = if pretty { |
| 164 | serde_json::to_string_pretty(&settings_list)? |
| 165 | } else { |
| 166 | serde_json::to_string(&settings_list)? |
| 167 | }; |
| 168 | |
| 169 | println!("{}", output); |
| 170 | Ok(()) |
| 171 | } |
| 172 | |
| 173 | /// Print all available settings |
| 174 | fn print_all_settings(os: &Os, format: OutputFormat) -> Result<()> { |
no test coverage detected