mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-23 05:34:57 +02:00
Optimized imports as per clion
This commit is contained in:
parent
d922f85b95
commit
bbdd7786ce
17
src/app.rs
17
src/app.rs
@ -1,16 +1,17 @@
|
|||||||
pub mod data_harvester;
|
|
||||||
use data_harvester::{processes, temperature};
|
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
pub mod data_farmer;
|
|
||||||
use data_farmer::*;
|
|
||||||
|
|
||||||
use crate::{canvas, constants, utils::error::Result};
|
|
||||||
mod process_killer;
|
|
||||||
|
|
||||||
use unicode_segmentation::GraphemeCursor;
|
use unicode_segmentation::GraphemeCursor;
|
||||||
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
|
use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};
|
||||||
|
|
||||||
|
use data_farmer::*;
|
||||||
|
use data_harvester::{processes, temperature};
|
||||||
|
|
||||||
|
use crate::{canvas, constants, utils::error::Result};
|
||||||
|
|
||||||
|
pub mod data_harvester;
|
||||||
|
pub mod data_farmer;
|
||||||
|
mod process_killer;
|
||||||
|
|
||||||
const MAX_SEARCH_LENGTH: usize = 200;
|
const MAX_SEARCH_LENGTH: usize = 200;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use crate::data_harvester::{cpu, disks, mem, network, processes, temperature, Data};
|
|
||||||
/// In charge of cleaning, processing, and managing data. I couldn't think of
|
/// In charge of cleaning, processing, and managing data. I couldn't think of
|
||||||
/// a better name for the file. Since I called data collection "harvesting",
|
/// a better name for the file. Since I called data collection "harvesting",
|
||||||
/// then this is the farmer I guess.
|
/// then this is the farmer I guess.
|
||||||
@ -16,6 +15,8 @@ use crate::data_harvester::{cpu, disks, mem, network, processes, temperature, Da
|
|||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
|
||||||
|
use crate::data_harvester::{cpu, Data, disks, mem, network, processes, temperature};
|
||||||
|
|
||||||
pub type TimeOffset = f64;
|
pub type TimeOffset = f64;
|
||||||
pub type Value = f64;
|
pub type Value = f64;
|
||||||
pub type JoinedDataPoints = (Value, Vec<(TimeOffset, Value)>);
|
pub type JoinedDataPoints = (Value, Vec<(TimeOffset, Value)>);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
//! This is the main file to house data collection functions.
|
//! This is the main file to house data collection functions.
|
||||||
|
|
||||||
use std::{collections::HashMap, time::Instant};
|
use std::{collections::HashMap, time::Instant};
|
||||||
|
|
||||||
use sysinfo::{System, SystemExt};
|
use sysinfo::{System, SystemExt};
|
||||||
|
|
||||||
pub mod cpu;
|
pub mod cpu;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use heim::net;
|
use heim::net;
|
||||||
use heim::units::information::byte;
|
use heim::units::information::byte;
|
||||||
use std::time::Instant;
|
|
||||||
use sysinfo::{NetworkExt, System, SystemExt};
|
use sysinfo::{NetworkExt, System, SystemExt};
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug)]
|
#[derive(Default, Clone, Debug)]
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
use crate::utils::error;
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::{hash_map::RandomState, HashMap},
|
collections::{hash_map::RandomState, HashMap},
|
||||||
process::Command,
|
process::Command,
|
||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
|
|
||||||
use sysinfo::{ProcessExt, ProcessorExt, System, SystemExt};
|
use sysinfo::{ProcessExt, ProcessorExt, System, SystemExt};
|
||||||
|
|
||||||
|
use crate::utils::error;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum ProcessSorting {
|
pub enum ProcessSorting {
|
||||||
CPU,
|
CPU,
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use heim::units::thermodynamic_temperature;
|
use heim::units::thermodynamic_temperature;
|
||||||
use std::cmp::Ordering;
|
|
||||||
use sysinfo::{ComponentExt, System, SystemExt};
|
use sysinfo::{ComponentExt, System, SystemExt};
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone)]
|
#[derive(Default, Debug, Clone)]
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
/// This file is meant to house (OS specific) implementations on how to kill processes.
|
|
||||||
use crate::utils::error::BottomError;
|
|
||||||
use std::process::Command;
|
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 winapi::{
|
use winapi::{
|
||||||
shared::{minwindef::DWORD, ntdef::HANDLE},
|
shared::{minwindef::DWORD, ntdef::HANDLE},
|
||||||
um::{
|
um::{
|
||||||
processthreadsapi::{OpenProcess, TerminateProcess},
|
processthreadsapi::{OpenProcess, TerminateProcess},
|
||||||
winnt::{PROCESS_QUERY_INFORMATION, PROCESS_TERMINATE},
|
winnt::{PROCESS_QUERY_INFORMATION, PROCESS_TERMINATE},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// This file is meant to house (OS specific) implementations on how to kill processes.
|
||||||
|
use crate::utils::error::BottomError;
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
struct Process(HANDLE);
|
struct Process(HANDLE);
|
||||||
|
|
||||||
|
@ -1,28 +1,30 @@
|
|||||||
use crate::{
|
|
||||||
app::{self, data_harvester::processes::ProcessHarvest, WidgetPosition},
|
|
||||||
constants::*,
|
|
||||||
data_conversion::{ConvertedCpuData, ConvertedProcessData},
|
|
||||||
utils::error,
|
|
||||||
};
|
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use tui::{
|
use tui::{
|
||||||
backend,
|
backend,
|
||||||
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
layout::{Alignment, Constraint, Direction, Layout, Rect},
|
||||||
style::{Color, Style},
|
style::{Color, Style},
|
||||||
terminal::Frame,
|
Terminal,
|
||||||
widgets::{Axis, Block, Borders, Chart, Dataset, Marker, Paragraph, Row, Table, Text, Widget},
|
terminal::Frame,
|
||||||
Terminal,
|
widgets::{Axis, Block, Borders, Chart, Dataset, Marker, Paragraph, Row, Table, Text, Widget},
|
||||||
};
|
};
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
mod canvas_colours;
|
|
||||||
use canvas_colours::*;
|
use canvas_colours::*;
|
||||||
|
|
||||||
mod drawing_utils;
|
|
||||||
use drawing_utils::*;
|
use drawing_utils::*;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
app::{self, data_harvester::processes::ProcessHarvest, WidgetPosition},
|
||||||
|
constants::*,
|
||||||
|
data_conversion::{ConvertedCpuData, ConvertedProcessData},
|
||||||
|
utils::error,
|
||||||
|
};
|
||||||
|
|
||||||
|
mod canvas_colours;
|
||||||
|
mod drawing_utils;
|
||||||
|
|
||||||
// Headers
|
// Headers
|
||||||
const CPU_LEGEND_HEADER: [&str; 2] = ["CPU", "Use%"];
|
const CPU_LEGEND_HEADER: [&str; 2] = ["CPU", "Use%"];
|
||||||
const CPU_SELECT_LEGEND_HEADER: [&str; 2] = ["CPU", "Show (Space)"];
|
const CPU_SELECT_LEGEND_HEADER: [&str; 2] = ["CPU", "Show (Space)"];
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
mod colour_utils;
|
|
||||||
use colour_utils::*;
|
|
||||||
use tui::style::{Color, Modifier, Style};
|
use tui::style::{Color, Modifier, Style};
|
||||||
|
|
||||||
|
use colour_utils::*;
|
||||||
|
|
||||||
use crate::{constants::*, utils::error};
|
use crate::{constants::*, utils::error};
|
||||||
|
|
||||||
|
mod colour_utils;
|
||||||
|
|
||||||
pub struct CanvasColours {
|
pub struct CanvasColours {
|
||||||
pub currently_selected_text_colour: Color,
|
pub currently_selected_text_colour: Color,
|
||||||
pub currently_selected_bg_colour: Color,
|
pub currently_selected_bg_colour: Color,
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
use crate::utils::{error, gen_util::*};
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use tui::style::{Color, Style};
|
use tui::style::{Color, Style};
|
||||||
|
|
||||||
|
use crate::utils::{error, gen_util::*};
|
||||||
|
|
||||||
const GOLDEN_RATIO: f32 = 0.618_034; // Approx, good enough for use (also Clippy gets mad if it's too long)
|
const GOLDEN_RATIO: f32 = 0.618_034; // Approx, good enough for use (also Clippy gets mad if it's too long)
|
||||||
pub const STANDARD_FIRST_COLOUR: Color = Color::LightMagenta;
|
pub const STANDARD_FIRST_COLOUR: Color = Color::LightMagenta;
|
||||||
pub const STANDARD_SECOND_COLOUR: Color = Color::LightYellow;
|
pub const STANDARD_SECOND_COLOUR: Color = Color::LightYellow;
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
//! This mainly concerns converting collected data into things that the canvas
|
//! This mainly concerns converting collected data into things that the canvas
|
||||||
//! can actually handle.
|
//! can actually handle.
|
||||||
|
|
||||||
use crate::{
|
|
||||||
app::{
|
|
||||||
data_farmer,
|
|
||||||
data_harvester::{self, processes::ProcessHarvest},
|
|
||||||
App,
|
|
||||||
},
|
|
||||||
constants,
|
|
||||||
utils::gen_util::{get_exact_byte_values, get_simple_byte_values},
|
|
||||||
};
|
|
||||||
use constants::*;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use constants::*;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
app::{
|
||||||
|
App,
|
||||||
|
data_farmer,
|
||||||
|
data_harvester::{self, processes::ProcessHarvest},
|
||||||
|
},
|
||||||
|
constants,
|
||||||
|
utils::gen_util::{get_exact_byte_values, get_simple_byte_values},
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct ConvertedNetworkData {
|
pub struct ConvertedNetworkData {
|
||||||
pub rx: Vec<(f64, f64)>,
|
pub rx: Vec<(f64, f64)>,
|
||||||
|
47
src/main.rs
47
src/main.rs
@ -1,26 +1,13 @@
|
|||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate log;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
extern crate futures;
|
||||||
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate futures;
|
extern crate log;
|
||||||
|
|
||||||
use serde::Deserialize;
|
|
||||||
|
|
||||||
use crossterm::{
|
|
||||||
event::{
|
|
||||||
poll, read, DisableMouseCapture, EnableMouseCapture, Event as CEvent, KeyCode, KeyEvent,
|
|
||||||
KeyModifiers, MouseEvent,
|
|
||||||
},
|
|
||||||
execute,
|
|
||||||
style::Print,
|
|
||||||
terminal::LeaveAlternateScreen,
|
|
||||||
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen},
|
|
||||||
};
|
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
@ -30,8 +17,28 @@ use std::{
|
|||||||
thread,
|
thread,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crossterm::{
|
||||||
|
event::{
|
||||||
|
DisableMouseCapture, EnableMouseCapture, Event as CEvent, KeyCode, KeyEvent, KeyModifiers, MouseEvent,
|
||||||
|
poll, read,
|
||||||
|
},
|
||||||
|
execute,
|
||||||
|
style::Print,
|
||||||
|
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen},
|
||||||
|
terminal::LeaveAlternateScreen,
|
||||||
|
};
|
||||||
|
use serde::Deserialize;
|
||||||
use tui::{backend::CrosstermBackend, Terminal};
|
use tui::{backend::CrosstermBackend, Terminal};
|
||||||
|
|
||||||
|
use app::{
|
||||||
|
App,
|
||||||
|
data_harvester::{self, processes::ProcessSorting},
|
||||||
|
};
|
||||||
|
use constants::*;
|
||||||
|
use data_conversion::*;
|
||||||
|
use utils::error::{self, BottomError};
|
||||||
|
|
||||||
pub mod app;
|
pub mod app;
|
||||||
mod utils {
|
mod utils {
|
||||||
pub mod error;
|
pub mod error;
|
||||||
@ -42,14 +49,6 @@ mod canvas;
|
|||||||
mod constants;
|
mod constants;
|
||||||
mod data_conversion;
|
mod data_conversion;
|
||||||
|
|
||||||
use app::{
|
|
||||||
data_harvester::{self, processes::ProcessSorting},
|
|
||||||
App,
|
|
||||||
};
|
|
||||||
use constants::*;
|
|
||||||
use data_conversion::*;
|
|
||||||
use utils::error::{self, BottomError};
|
|
||||||
|
|
||||||
enum Event<I, J> {
|
enum Event<I, J> {
|
||||||
KeyInput(I),
|
KeyInput(I),
|
||||||
MouseInput(J),
|
MouseInput(J),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
use std::process::Command;
|
||||||
|
|
||||||
use assert_cmd::prelude::*;
|
use assert_cmd::prelude::*;
|
||||||
use predicates::prelude::*;
|
use predicates::prelude::*;
|
||||||
use std::process::Command;
|
|
||||||
|
|
||||||
// These tests are mostly here just to ensure that invalid results will be caught when passing arguments...
|
// These tests are mostly here just to ensure that invalid results will be caught when passing arguments...
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user