Skip to content

Commit bc3d6be

Browse files
committed
sec fix - replaced colored with owo-colors
1 parent ea831e7 commit bc3d6be

File tree

3 files changed

+55
-43
lines changed

3 files changed

+55
-43
lines changed

Cargo.lock

Lines changed: 7 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
clap = "4.1.8"
10-
colored = "2.0.0"
10+
owo-colors = "3"
1111
flexi_logger = "0.23"
1212
log = "0.4"
1313
ctrlc = "3.2.5"

src/main.rs

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clap::{Arg, ArgAction, Command};
2-
use colored::*;
32
use flexi_logger::{detailed_format, Duplicate, FileSpec, Logger};
43
use log::{error, info, warn};
4+
use owo_colors::OwoColorize;
55

66
use std::{
77
env,
@@ -372,7 +372,7 @@ fn sl() -> Command {
372372
"✨"
373373
))
374374
// TODO update version
375-
.version("1.1.1")
375+
.version("1.1.2")
376376
.author("Leann Phydon <[email protected]>")
377377
.arg(
378378
Arg::new("colour")
@@ -722,8 +722,12 @@ fn print_output_long(
722722
let cstr = format!("{}", name_or_path.bold().truecolor(226, 120, 120));
723723
name.push_str(&cstr);
724724
} else if SPECIAL.iter().any(|it| &file_extension == it) {
725-
let cstr = format!("{}", name_or_path.truecolor(226, 164, 120))
726-
.on_truecolor(22, 24, 33);
725+
let cstr = format!(
726+
"{}",
727+
name_or_path
728+
.truecolor(226, 164, 120)
729+
.on_truecolor(22, 24, 33)
730+
);
727731
name.push_str(&cstr);
728732
} else if PROGRAMMING.iter().any(|it| &file_extension == it) {
729733
let cstr = format!("{}", name_or_path.truecolor(180, 190, 130));
@@ -775,43 +779,56 @@ fn print_output_long(
775779
perm_write.push_str(&permissions.write);
776780
}
777781

778-
let fsize_unit = if colour {
779-
if let Some(f) = filesize.pop() {
780-
f.truecolor(50, 170, 130)
781-
} else {
782-
"".to_string().truecolor(198, 200, 209)
782+
let mut fsize_unit = String::new();
783+
match colour {
784+
true => {
785+
if let Some(f) = filesize.pop() {
786+
fsize_unit.push_str(&f.truecolor(50, 170, 130).to_string())
787+
} else {
788+
fsize_unit.push_str(&"".truecolor(198, 200, 209).to_string())
789+
}
783790
}
784-
} else {
785-
if let Some(f) = filesize.pop() {
786-
f.truecolor(198, 200, 209)
787-
} else {
788-
"".to_string().truecolor(198, 200, 209)
791+
false => {
792+
if let Some(f) = filesize.pop() {
793+
fsize_unit.push_str(&f.truecolor(198, 200, 209).to_string())
794+
} else {
795+
fsize_unit.push_str(&"".truecolor(198, 200, 209).to_string())
796+
}
789797
}
790798
};
791799

792-
let fsize = if colour {
793-
if let Some(f) = filesize.pop() {
794-
f.truecolor(102, 255, 179)
795-
} else {
796-
"".to_string().truecolor(198, 200, 209)
800+
let mut fsize = String::new();
801+
match colour {
802+
true => {
803+
if let Some(f) = filesize.pop() {
804+
fsize.push_str(&f.truecolor(102, 255, 179).to_string())
805+
} else {
806+
fsize.push_str(&"".truecolor(198, 200, 209).to_string())
807+
}
797808
}
798-
} else {
799-
if let Some(f) = filesize.pop() {
800-
f.truecolor(198, 200, 209)
801-
} else {
802-
"".to_string().truecolor(198, 200, 209)
809+
false => {
810+
if let Some(f) = filesize.pop() {
811+
fsize.push_str(&f.truecolor(198, 200, 209).to_string())
812+
} else {
813+
fsize.push_str(&"".truecolor(198, 200, 209).to_string())
814+
}
803815
}
804816
};
805817

806-
let modified = if colour {
807-
modified.truecolor(97, 88, 111)
808-
} else {
809-
modified.truecolor(198, 200, 209)
818+
let modified = match colour {
819+
true => modified.truecolor(97, 88, 111),
820+
false => modified.truecolor(198, 200, 209),
810821
};
811822

812823
println!(
813-
"{}{}{}\t{:>7}{} {:>14} {}",
814-
ftype, perm_read, perm_write, fsize, fsize_unit, modified, name,
824+
"{}{}{}\t{:>30}{} {:>35} {}",
825+
ftype,
826+
perm_read,
827+
perm_write,
828+
fsize,
829+
fsize_unit,
830+
modified.to_string(),
831+
name,
815832
);
816833
}
817834

0 commit comments

Comments
 (0)