Skip to content

Commit

Permalink
Added colours to rm_size field
Browse files Browse the repository at this point in the history
  • Loading branch information
Bdeering1 committed Jun 16, 2023
1 parent bc79d22 commit e003662
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/menu.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

use console::{Key, Style, Term, pad_str, Alignment};

use crate::project::{Project, ProjectType};
Expand Down Expand Up @@ -50,7 +49,7 @@ fn create_label(project: &Project, max_path_len: usize) -> String {
} else {
String::from("unknown")
};

let type_color = match project.project_type {
ProjectType::Cargo => 214,
ProjectType::Node => 28,
Expand All @@ -66,13 +65,18 @@ fn create_label(project: &Project, max_path_len: usize) -> String {
Some(_days) => 2,
None => 1,
};
let rm_size_color = match project.rm_size {
size if size > 1000_000_000 => 1,
size if size > 100_000_000 => 3,
_ => 2,
};

format!(
"{}{}{}{}",
pad_right(project.path.display().to_string(), max_path_len + MIN_PATH_PADDING),
pad_right(apply_color256(project_type, type_color), PROJECT_TYPE_PADDING),
pad_left(apply_color256(last_modified, last_mod_color), LAST_MOD_PADDING),
pad_left(project.rm_size_str.to_owned(), SIZE_PADDING),
pad_left(apply_color256(project.rm_size_str.to_owned(), rm_size_color), SIZE_PADDING),
)
}

Expand Down
1 change: 0 additions & 1 deletion src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ fn get_time_since_last_mod(path: &PathBuf) -> Option<u64> {
return None;
}
Some(time_since.unwrap().as_secs() / Duration::from_secs(SECONDS_PER_DAY).as_secs())
// Some((time_since.unwrap().as_secs() + 39) % 250)
}

fn get_rm_size(rm_dirs: &Vec<PathBuf>) -> u64 {
Expand Down

0 comments on commit e003662

Please sign in to comment.