1use crate::pkg;
2use crate::utils;
3use anyhow::Result;
4use colored::*;
5
6pub fn run(branch: &str, status: &str, number: &str, commit: &str) -> Result<()> {
7 let _branch_short = if branch == "Production" {
8 "Prod."
9 } else if branch == "Development" {
10 "Dev."
11 } else if branch == "Public" {
12 "Pub."
13 } else if branch == "Special" {
14 "Spec."
15 } else {
16 branch
17 };
18
19 println!("{}", "--- System Information ---".yellow().bold());
20
21 let platform = utils::get_platform()?;
22 let parts: Vec<&str> = platform.split('-').collect();
23 let os = parts.first().cloned().unwrap_or("unknown");
24 let arch = parts.get(1).cloned().unwrap_or("unknown");
25
26 utils::print_aligned_info("OS", os);
27 utils::print_aligned_info("Architecture", arch);
28
29 if os == "linux"
30 && let Some(dist) = utils::get_linux_distribution()
31 {
32 utils::print_aligned_info("Distribution", &dist);
33 }
34
35 let config = pkg::config::read_config()?;
36 let native_pm = config.native_package_manager;
37 let all_pms = config.package_managers.unwrap_or_default();
38
39 if !all_pms.is_empty() {
40 let pm_list: Vec<String> = all_pms
41 .into_iter()
42 .map(|pm| {
43 if Some(pm.clone()) == native_pm {
44 format!("{} (native)", pm.green())
45 } else {
46 pm
47 }
48 })
49 .collect();
50 let pm_list_str = pm_list.join(", ");
51 utils::print_aligned_info("Package Managers", &pm_list_str);
52 } else {
53 utils::print_aligned_info("Package Managers", "Not available (run 'zoi sync')");
54 }
55
56 let tel = if config.telemetry_enabled {
57 "Enabled".green()
58 } else {
59 "Disabled".yellow()
60 };
61 utils::print_aligned_info("Telemetry", &tel.to_string());
62
63 let key_with_colon = format!("{}:", "Version");
64 println!(
65 "{:<18}{} {} {} {}",
66 key_with_colon.cyan(),
67 _branch_short,
68 status,
69 number,
70 commit.green()
71 );
72 Ok(())
73}