feat(main): integrate system info collection
Swadhin Biswas committed 7 months ago
b4cba5f
1 parent c734462
commit b4cba5f
1 file changed
+50 -0
Showing 1 changed file+50-0
▼src/main.rs
+50-0
| @@ -228,3 +228,53 @@ fn apply_args_to_config(config: &mut Config, args: &Args) { | ||
228 | 228 | if args.stdout { |
229 | 229 | config.stdout = true; |
230 | 230 | config.bold = false; |
231 | + } | |
232 | + if let Some(bold) = args.bold { | |
233 | + config.bold = bold; | |
234 | + } | |
235 | + if let Some(ref backend) = args.backend { | |
236 | + config.image_backend = backend.clone(); | |
237 | + } | |
238 | + if let Some(ref source) = args.source { | |
239 | + config.image_source = source.clone(); | |
240 | + } | |
241 | + if let Some(ref distro) = args.ascii_distro { | |
242 | + config.ascii_distro = distro.clone(); | |
243 | + } | |
244 | + if args.emoji { | |
245 | + config.emoji_mode = true; | |
246 | + } | |
247 | + if args.nerd_font { | |
248 | + config.nerd_font = true; | |
249 | + } | |
250 | + if args.custom_image.is_some() { | |
251 | + config.custom_image = args.custom_image.clone(); | |
252 | + } | |
253 | + if args.logo_only { | |
254 | + config.logo_only = true; | |
255 | + } | |
256 | + if let Some(gap) = args.gap { | |
257 | + config.gap = gap; | |
258 | + } | |
259 | + if let Some(ref sep) = args.separator { | |
260 | + config.separator = sep.clone(); | |
261 | + } | |
262 | + if let Some(start) = args.block_range_start { | |
263 | + config.block_range.0 = start; | |
264 | + } | |
265 | + if let Some(end) = args.block_range_end { | |
266 | + config.block_range.1 = end; | |
267 | + } | |
268 | + if let Some(width) = args.block_width { | |
269 | + config.block_width = width; | |
270 | + } | |
271 | +} | |
272 | + | |
273 | +fn print_json(info: &SystemInfo) { | |
274 | + let gpu_str = info.gpu.join(", "); | |
275 | + println!("{{"); | |
276 | + let fields: Vec<(&str, &str)> = vec![ | |
277 | + ("os", &info.os), | |
278 | + ("host", &info.host), | |
279 | + ("kernel", &info.kernel), | |
280 | + ("uptime", &info.uptime), | |
231 | 281 | |