mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
+8
-7
@@ -285,15 +285,16 @@ pub fn format_string(
|
|||||||
let name = get_printable_name(&node.name, display_data.short_paths);
|
let name = get_printable_name(&node.name, display_data.short_paths);
|
||||||
let width = get_unicode_width_of_indent_and_name(indent, &name);
|
let width = get_unicode_width_of_indent_and_name(indent, &name);
|
||||||
|
|
||||||
let name_and_padding = name
|
let (percents, name_and_padding) = if percent_bar != "" {
|
||||||
+ &(repeat(" ")
|
let percents = format!("│{} │ {:>4}", percent_bar, percent_size_str);
|
||||||
.take(display_data.longest_string_length - width)
|
|
||||||
.collect::<String>());
|
|
||||||
|
|
||||||
let percents = if percent_bar != "" {
|
let name_and_padding = name
|
||||||
format!("│{} │ {:>4}", percent_bar, percent_size_str)
|
+ &(repeat(" ")
|
||||||
|
.take(display_data.longest_string_length - width)
|
||||||
|
.collect::<String>());
|
||||||
|
(percents, name_and_padding)
|
||||||
} else {
|
} else {
|
||||||
"".into()
|
("".into(), name)
|
||||||
};
|
};
|
||||||
|
|
||||||
let pretty_size = if is_biggest && display_data.colors_on {
|
let pretty_size = if is_biggest && display_data.colors_on {
|
||||||
|
|||||||
+14
-9
@@ -20,15 +20,20 @@ static DEFAULT_NUMBER_OF_LINES: usize = 30;
|
|||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn init_color(no_color: bool) -> bool {
|
fn init_color(no_color: bool) -> bool {
|
||||||
// Required for windows 10
|
// If no color is already set do not print a warning message
|
||||||
// Fails to resolve for windows 8 so disable color
|
if no_color {
|
||||||
match ansi_term::enable_ansi_support() {
|
true
|
||||||
Ok(_) => no_color,
|
} else {
|
||||||
Err(_) => {
|
// Required for windows 10
|
||||||
eprintln!(
|
// Fails to resolve for windows 8 so disable color
|
||||||
"This version of Windows does not support ANSI colors, setting no_color flag"
|
match ansi_term::enable_ansi_support() {
|
||||||
);
|
Ok(_) => no_color,
|
||||||
true
|
Err(_) => {
|
||||||
|
eprintln!(
|
||||||
|
"This version of Windows does not support ANSI colors, setting no_color flag"
|
||||||
|
);
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,16 @@ pub fn test_basic_output() {
|
|||||||
assert!(output.contains("a_file "));
|
assert!(output.contains("a_file "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
pub fn test_output_no_bars_means_no_excess_spaces() {
|
||||||
|
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||||
|
let output = cmd.arg("-b").arg("src/test_dir/").unwrap().stdout;
|
||||||
|
let output = str::from_utf8(&output).unwrap();
|
||||||
|
// If bars are not being shown we don't need to pad the output with spaces
|
||||||
|
assert!(output.contains("many"));
|
||||||
|
assert!(!output.contains("many "));
|
||||||
|
}
|
||||||
|
|
||||||
// "windows" result data can vary by host (size seems to be variable by one byte); fix code vs test and re-enable
|
// "windows" result data can vary by host (size seems to be variable by one byte); fix code vs test and re-enable
|
||||||
#[cfg_attr(target_os = "windows", ignore)]
|
#[cfg_attr(target_os = "windows", ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
@@ -138,6 +148,8 @@ fn main_output_long_paths() -> String {
|
|||||||
#[cfg_attr(target_os = "windows", ignore)]
|
#[cfg_attr(target_os = "windows", ignore)]
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_apparent_size() {
|
pub fn test_apparent_size() {
|
||||||
|
copy_test_data("src/test_dir");
|
||||||
|
|
||||||
let mut cmd = Command::cargo_bin("dust").unwrap();
|
let mut cmd = Command::cargo_bin("dust").unwrap();
|
||||||
let assert = cmd.arg("-c").arg("-s").arg("src/test_dir").unwrap().stdout;
|
let assert = cmd.arg("-c").arg("-s").arg("src/test_dir").unwrap().stdout;
|
||||||
let output = str::from_utf8(&assert).unwrap();
|
let output = str::from_utf8(&assert).unwrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user