Better handling for color in terminal (#381)

* better handling for color in terminal

* cleanup

* cleanup

* cargo fmt

* clippy + tests

* clean
This commit is contained in:
n4n5
2024-03-25 22:50:29 +01:00
committed by GitHub
parent 7c75c1b0a9
commit fbd34ec4c2
11 changed files with 73 additions and 22 deletions

View File

@@ -232,3 +232,19 @@ pub fn test_show_files_by_invert_regex_match_multiple() {
assert!(!output.contains("test_dir_unicode"));
assert!(output.contains("many"));
}
#[test]
pub fn test_no_color() {
let output = build_command(vec!["-c"]);
// Red is 31
assert!(!output.contains("\x1B[31m"));
assert!(!output.contains("\x1B[0m"));
}
#[test]
pub fn test_force_color() {
let output = build_command(vec!["-C"]);
// Red is 31
assert!(output.contains("\x1B[31m"));
assert!(output.contains("\x1B[0m"));
}