mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-22 20:23:12 +00:00
Some simple fixes to abide by clippy
This commit is contained in:
parent
c1a3f4dc50
commit
4974ae0886
7 changed files with 16 additions and 26 deletions
|
@ -22,7 +22,7 @@ macOS support will hopefully come soon<sup>TM</sup>.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Note that all options and keybinds on GitHub may reflect the current development build, and not that of the current releases. For now, refer to the [crate](https://crates.io/crates/bottom) README for documentation as of time of release.
|
Note that all options and keybindings on GitHub may reflect the current development build, and not that of the current releases. For now, refer to the [crate](https://crates.io/crates/bottom) README for documentation as of time of release.
|
||||||
|
|
||||||
### Command line options
|
### Command line options
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ Note that all options and keybinds on GitHub may reflect the current development
|
||||||
|
|
||||||
- `-r <RATE>`, `--rate <RATE>` will set the refresh rate in _milliseconds_. Lowest it can go is 250ms, the highest it can go is 2<sup>128 - 1</sup>. Defaults to 1000ms, and lower values may take more resources due to more frequent polling of data, and may be less accurate in some circumstances.
|
- `-r <RATE>`, `--rate <RATE>` will set the refresh rate in _milliseconds_. Lowest it can go is 250ms, the highest it can go is 2<sup>128 - 1</sup>. Defaults to 1000ms, and lower values may take more resources due to more frequent polling of data, and may be less accurate in some circumstances.
|
||||||
|
|
||||||
### Keybinds
|
### Keybindings
|
||||||
|
|
||||||
#### General
|
#### General
|
||||||
|
|
||||||
|
|
|
@ -87,15 +87,7 @@ pub async fn get_disk_usage_list() -> crate::utils::error::Result<Vec<DiskData>>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vec_disks.sort_by(|a, b| {
|
vec_disks.sort_by(|a, b| a.name.cmp(&b.name));
|
||||||
if a.name < b.name {
|
|
||||||
std::cmp::Ordering::Less
|
|
||||||
} else if a.name > b.name {
|
|
||||||
std::cmp::Ordering::Greater
|
|
||||||
} else {
|
|
||||||
std::cmp::Ordering::Equal
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(vec_disks)
|
Ok(vec_disks)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@ use std::process::Command;
|
||||||
|
|
||||||
// Copied from SO: https://stackoverflow.com/a/55231715
|
// Copied from SO: https://stackoverflow.com/a/55231715
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
use std::ptr::null_mut;
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
use winapi::{
|
use winapi::{
|
||||||
shared::{minwindef::DWORD, ntdef::HANDLE},
|
shared::{minwindef::DWORD, ntdef::HANDLE},
|
||||||
um::{
|
um::{
|
||||||
|
@ -20,7 +18,7 @@ struct Process(HANDLE);
|
||||||
impl Process {
|
impl Process {
|
||||||
fn open(pid: DWORD) -> Result<Process, String> {
|
fn open(pid: DWORD) -> Result<Process, String> {
|
||||||
let pc = unsafe { OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_TERMINATE, 0, pid) };
|
let pc = unsafe { OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_TERMINATE, 0, pid) };
|
||||||
if pc == null_mut() {
|
if pc.is_null() {
|
||||||
return Err("!OpenProcess".to_string());
|
return Err("!OpenProcess".to_string());
|
||||||
}
|
}
|
||||||
Ok(Process(pc))
|
Ok(Process(pc))
|
||||||
|
|
|
@ -56,7 +56,7 @@ pub fn draw_data<B: backend::Backend>(terminal: &mut Terminal<B>, app_state: &mu
|
||||||
.split(vertical_dialog_chunk[1]);
|
.split(vertical_dialog_chunk[1]);
|
||||||
|
|
||||||
let help_text = [
|
let help_text = [
|
||||||
Text::raw("\nGeneral Keybinds\n"),
|
Text::raw("\nGeneral Keybindings\n"),
|
||||||
Text::raw("q, Ctrl-c to quit.\n"),
|
Text::raw("q, Ctrl-c to quit.\n"),
|
||||||
Text::raw("Ctrl-r to reset all data.\n"),
|
Text::raw("Ctrl-r to reset all data.\n"),
|
||||||
Text::raw("f to toggle freezing and unfreezing the display.\n"),
|
Text::raw("f to toggle freezing and unfreezing the display.\n"),
|
||||||
|
@ -64,7 +64,7 @@ pub fn draw_data<B: backend::Backend>(terminal: &mut Terminal<B>, app_state: &mu
|
||||||
Text::raw("Up and Down scrolls through a list.\n"),
|
Text::raw("Up and Down scrolls through a list.\n"),
|
||||||
Text::raw("Esc to close a dialog window (help or dd confirmation).\n"),
|
Text::raw("Esc to close a dialog window (help or dd confirmation).\n"),
|
||||||
Text::raw("? to get this help screen.\n"),
|
Text::raw("? to get this help screen.\n"),
|
||||||
Text::raw("\n Process Panel Keybinds\n"),
|
Text::raw("\n Process Panel Keybindings\n"),
|
||||||
Text::raw("dd to kill the selected process.\n"),
|
Text::raw("dd to kill the selected process.\n"),
|
||||||
Text::raw("c to sort by CPU usage.\n"),
|
Text::raw("c to sort by CPU usage.\n"),
|
||||||
Text::raw("m to sort by memory usage.\n"),
|
Text::raw("m to sort by memory usage.\n"),
|
||||||
|
|
|
@ -289,13 +289,13 @@ pub fn convert_network_data_points(network_data: &[data_collection::network::Net
|
||||||
let rx_display = if let Some(last_num_bytes_entry) = network_data.last() {
|
let rx_display = if let Some(last_num_bytes_entry) = network_data.last() {
|
||||||
let num_bytes = last_num_bytes_entry.rx;
|
let num_bytes = last_num_bytes_entry.rx;
|
||||||
if num_bytes < 1024 {
|
if num_bytes < 1024 {
|
||||||
format!("RX: {:5.*} B/s", 1, num_bytes as f64).to_string()
|
format!("RX: {:5.*} B/s", 1, num_bytes as f64)
|
||||||
} else if num_bytes < (1024 * 1024) {
|
} else if num_bytes < (1024 * 1024) {
|
||||||
format!("RX: {:5.*}KiB/s", 1, num_bytes as f64 / 1024.0).to_string()
|
format!("RX: {:5.*}KiB/s", 1, num_bytes as f64 / 1024.0)
|
||||||
} else if num_bytes < (1024 * 1024 * 1024) {
|
} else if num_bytes < (1024 * 1024 * 1024) {
|
||||||
format!("RX: {:5.*}MiB/s", 1, num_bytes as f64 / 1024.0 / 1024.0).to_string()
|
format!("RX: {:5.*}MiB/s", 1, num_bytes as f64 / 1024.0 / 1024.0)
|
||||||
} else {
|
} else {
|
||||||
format!("RX: {:5.*}GiB/s", 1, num_bytes as f64 / 1024.0 / 1024.0 / 1024.0).to_string()
|
format!("RX: {:5.*}GiB/s", 1, num_bytes as f64 / 1024.0 / 1024.0 / 1024.0)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
"0.0B/s".to_string()
|
"0.0B/s".to_string()
|
||||||
|
@ -304,13 +304,13 @@ pub fn convert_network_data_points(network_data: &[data_collection::network::Net
|
||||||
let tx_display = if let Some(last_num_bytes_entry) = network_data.last() {
|
let tx_display = if let Some(last_num_bytes_entry) = network_data.last() {
|
||||||
let num_bytes = last_num_bytes_entry.tx;
|
let num_bytes = last_num_bytes_entry.tx;
|
||||||
if num_bytes < 1024 {
|
if num_bytes < 1024 {
|
||||||
format!("TX: {:5.*} B/s", 1, num_bytes as f64).to_string()
|
format!("TX: {:5.*} B/s", 1, num_bytes as f64)
|
||||||
} else if num_bytes < (1024 * 1024) {
|
} else if num_bytes < (1024 * 1024) {
|
||||||
format!("TX: {:5.*}KiB/s", 1, num_bytes as f64 / 1024.0).to_string()
|
format!("TX: {:5.*}KiB/s", 1, num_bytes as f64 / 1024.0)
|
||||||
} else if num_bytes < (1024 * 1024 * 1024) {
|
} else if num_bytes < (1024 * 1024 * 1024) {
|
||||||
format!("TX: {:5.*}MiB/s", 1, num_bytes as f64 / 1024.0 / 1024.0).to_string()
|
format!("TX: {:5.*}MiB/s", 1, num_bytes as f64 / 1024.0 / 1024.0)
|
||||||
} else {
|
} else {
|
||||||
format!("TX: {:5.*}GiB/s", 1, num_bytes as f64 / 1024.0 / 1024.0 / 1024.0).to_string()
|
format!("TX: {:5.*}GiB/s", 1, num_bytes as f64 / 1024.0 / 1024.0 / 1024.0)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
"0B.0/s".to_string()
|
"0B.0/s".to_string()
|
||||||
|
|
|
@ -177,7 +177,7 @@ fn main() -> error::Result<()> {
|
||||||
// Event loop
|
// Event loop
|
||||||
let (rtx, rrx) = mpsc::channel();
|
let (rtx, rrx) = mpsc::channel();
|
||||||
{
|
{
|
||||||
let tx = tx.clone();
|
let tx = tx;
|
||||||
let mut first_run = true;
|
let mut first_run = true;
|
||||||
let temp_type = app.temperature_type.clone();
|
let temp_type = app.temperature_type.clone();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
|
|
|
@ -65,7 +65,7 @@ impl From<std::num::ParseIntError> for BottomError {
|
||||||
|
|
||||||
impl From<std::string::String> for BottomError {
|
impl From<std::string::String> for BottomError {
|
||||||
fn from(err: std::string::String) -> Self {
|
fn from(err: std::string::String) -> Self {
|
||||||
BottomError::GenericError { message: err.to_string() }
|
BottomError::GenericError { message: err }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue