diff --git a/rustfmt.toml b/rustfmt.toml index fae7c139..6e1fdffd 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,4 @@ -max_width = 200 +max_width = 175 reorder_imports = true control_brace_style = "ClosingNextLine" fn_args_layout = "Compressed" diff --git a/src/app/data_collection/cpu.rs b/src/app/data_collection/cpu.rs index e2a00272..8a09ee17 100644 --- a/src/app/data_collection/cpu.rs +++ b/src/app/data_collection/cpu.rs @@ -24,5 +24,8 @@ pub fn get_cpu_data_list(sys : &System) -> Result { }) } - Ok(CPUPackage { cpu_vec, instant : Instant::now() }) + Ok(CPUPackage { + cpu_vec, + instant : Instant::now(), + }) } diff --git a/src/app/data_collection/disks.rs b/src/app/data_collection/disks.rs index 1700ddbb..4e532b8a 100644 --- a/src/app/data_collection/disks.rs +++ b/src/app/data_collection/disks.rs @@ -48,7 +48,10 @@ pub async fn get_io_usage_list(get_physical : bool) -> Result Result, heim::Error> { @@ -65,7 +68,13 @@ pub async fn get_disk_usage_list() -> Result, heim::Error> { used_space : usage.used().get::(), total_space : usage.total().get::(), mount_point : Box::from(partition.mount_point().to_str().unwrap_or("Name Unavailable")), - name : Box::from(partition.device().unwrap_or_else(|| std::ffi::OsStr::new("Name Unavailable")).to_str().unwrap_or("Name Unavailable")), + name : Box::from( + partition + .device() + .unwrap_or_else(|| std::ffi::OsStr::new("Name Unavailable")) + .to_str() + .unwrap_or("Name Unavailable"), + ), }); } } diff --git a/src/app/data_collection/processes.rs b/src/app/data_collection/processes.rs index 85ce5a61..3f8512e0 100644 --- a/src/app/data_collection/processes.rs +++ b/src/app/data_collection/processes.rs @@ -173,7 +173,10 @@ pub async fn get_sorted_processes_list(prev_idle : &mut f64, prev_non_idle : &mu if cfg!(target_os = "linux") { // Linux specific - this is a massive pain... ugh. - let ps_result = Command::new("ps").args(&["-axo", "pid:10,comm:50,%mem:5", "--noheader"]).output().expect("Failed to execute."); + let ps_result = Command::new("ps") + .args(&["-axo", "pid:10,comm:50,%mem:5", "--noheader"]) + .output() + .expect("Failed to execute."); let ps_stdout = String::from_utf8_lossy(&ps_result.stdout); let split_string = ps_stdout.split('\n'); let cpu_usage = vangelis_cpu_usage_calculation(prev_idle, prev_non_idle).unwrap(); // TODO: FIX THIS ERROR CHECKING diff --git a/src/canvas.rs b/src/canvas.rs index 2cd26c4d..40f13ec0 100644 --- a/src/canvas.rs +++ b/src/canvas.rs @@ -30,9 +30,15 @@ pub struct CanvasData { pub fn draw_data(terminal : &mut Terminal, app_data : &app::App, canvas_data : &CanvasData) -> error::Result<()> { let border_style : Style = Style::default().fg(BORDER_STYLE_COLOUR); - let temperature_rows = canvas_data.temp_sensor_data.iter().map(|sensor| Row::StyledData(sensor.iter(), Style::default().fg(TEXT_COLOUR))); + let temperature_rows = canvas_data + .temp_sensor_data + .iter() + .map(|sensor| Row::StyledData(sensor.iter(), Style::default().fg(TEXT_COLOUR))); let disk_rows = canvas_data.disk_data.iter().map(|disk| Row::StyledData(disk.iter(), Style::default().fg(TEXT_COLOUR))); - let process_rows = canvas_data.process_data.iter().map(|process| Row::StyledData(process.iter(), Style::default().fg(TEXT_COLOUR))); + let process_rows = canvas_data + .process_data + .iter() + .map(|process| Row::StyledData(process.iter(), Style::default().fg(TEXT_COLOUR))); terminal.draw(|mut f| { debug!("Drawing!"); @@ -146,7 +152,13 @@ pub fn draw_data(terminal : &mut Terminal, app_dat Table::new(["Disk", "Mount", "Used", "Total", "Free"].iter(), disk_rows) .block(Block::default().title("Disk Usage").borders(Borders::ALL).border_style(border_style)) .header_style(Style::default().fg(Color::LightBlue).modifier(Modifier::BOLD)) - .widths(&[(width * 0.25) as u16, (width * 0.2) as u16, (width * 0.15) as u16, (width * 0.15) as u16, (width * 0.15) as u16]) + .widths(&[ + (width * 0.25) as u16, + (width * 0.2) as u16, + (width * 0.15) as u16, + (width * 0.15) as u16, + (width * 0.15) as u16, + ]) .render(&mut f, middle_divided_chunk_2[1]); } diff --git a/src/main.rs b/src/main.rs index d771c6ec..8c56d9da 100644 --- a/src/main.rs +++ b/src/main.rs @@ -302,8 +302,11 @@ fn update_cpu_data_points(show_avg_cpu : bool, app_data : &data_collection::Data for (i, data) in cpu_collection.iter().enumerate() { cpu_data_vector.push(( // + 1 to skip total CPU if show_avg_cpu is false - format!("{:4}: ", &*(app_data.list_of_cpu_packages.last().unwrap().cpu_vec[i + if show_avg_cpu { 0 } else { 1 }].cpu_name)).to_uppercase() - + &format!("{:3}%", (data.last().unwrap_or(&(0_f64, 0_f64)).1.round() as u64)), + format!( + "{:4}: ", + &*(app_data.list_of_cpu_packages.last().unwrap().cpu_vec[i + if show_avg_cpu { 0 } else { 1 }].cpu_name) + ) + .to_uppercase() + &format!("{:3}%", (data.last().unwrap_or(&(0_f64, 0_f64)).1.round() as u64)), data.clone(), )) }