Tweak output - the root node now has a: ─┬

This commit is contained in:
andy.boot
2018-05-09 10:58:32 +01:00
parent dd75ec4aa7
commit ce0e14bf00
2 changed files with 29 additions and 28 deletions
+2 -1
View File
@@ -19,7 +19,7 @@ pub fn draw_it(
for &(ref k, _) in to_display.iter() { for &(ref k, _) in to_display.iter() {
if base_dirs.contains(k) { if base_dirs.contains(k) {
display_node(&k, &mut found, &to_display, true, short_paths, depth, "") display_node(&k, &mut found, &to_display, true, short_paths, depth, "─┬")
} }
} }
} }
@@ -64,6 +64,7 @@ fn display_node<S: Into<String>>(
is = is.replace("└──", " "); is = is.replace("└──", " ");
is = is.replace("├──", ""); is = is.replace("├──", "");
is = is.replace("├─┬", ""); is = is.replace("├─┬", "");
is = is.replace("─┬", " ");
let printable_node_slashes = node_to_print.matches('/').count(); let printable_node_slashes = node_to_print.matches('/').count();
+22 -22
View File
@@ -44,8 +44,8 @@ fn main_output(short_paths: bool) -> String {
{} {}
{} {}
{}", {}",
format_string("src/test_dir", true, short_paths, " 4.0K", ""), format_string("src/test_dir", true, short_paths, " 4.0K", "─┬"),
format_string("src/test_dir/many", true, short_paths, " 4.0K", "└─┬",), format_string("src/test_dir/many", true, short_paths, " 4.0K", " └─┬",),
format_string( format_string(
"src/test_dir/many/hello_file", "src/test_dir/many/hello_file",
true, true,
@@ -70,8 +70,8 @@ fn main_output(short_paths: bool) -> String {
{} {}
{} {}
{}", {}",
format_string("src/test_dir", true, short_paths, " 12K", ""), format_string("src/test_dir", true, short_paths, " 12K", "─┬"),
format_string("src/test_dir/many", true, short_paths, " 8.0K", "└─┬",), format_string("src/test_dir/many", true, short_paths, " 8.0K", " └─┬",),
format_string( format_string(
"src/test_dir/many/hello_file", "src/test_dir/many/hello_file",
true, true,
@@ -149,9 +149,9 @@ fn soft_sym_link_output(dir: &str, file_path: &str, link_name: &str) -> String {
"{} "{}
{} {}
{}", {}",
format_string(dir, true, true, " 8.0K", ""), format_string(dir, true, true, " 8.0K", "─┬"),
format_string(file_path, true, true, " 4.0K", "├──",), format_string(file_path, true, true, " 4.0K", " ├──",),
format_string(link_name, false, true, " 4.0K", "└──",), format_string(link_name, false, true, " 4.0K", " └──",),
) )
} }
@@ -161,9 +161,9 @@ fn soft_sym_link_output(dir: &str, file_path: &str, link_name: &str) -> String {
"{} "{}
{} {}
{}", {}",
format_string(dir, true, true, " 8.0K", ""), format_string(dir, true, true, " 8.0K", "─┬"),
format_string(file_path, true, true, " 4.0K", "├──",), format_string(file_path, true, true, " 4.0K", " ├──",),
format_string(link_name, false, true, " 0B", "└──",), format_string(link_name, false, true, " 0B", " └──",),
) )
} }
@@ -209,14 +209,14 @@ fn hard_link_output(dir_s: &str, file_path_s: &str, link_name_s: &str) -> (Strin
let r = format!( let r = format!(
"{} "{}
{}", {}",
format_string(dir_s, true, true, " 4.0K", ""), format_string(dir_s, true, true, " 4.0K", "─┬"),
format_string(file_path_s, true, true, " 4.0K", "└──") format_string(file_path_s, true, true, " 4.0K", " └──")
); );
let r2 = format!( let r2 = format!(
"{} "{}
{}", {}",
format_string(dir_s, true, true, " 4.0K", ""), format_string(dir_s, true, true, " 4.0K", "─┬"),
format_string(link_name_s, true, true, " 4.0K", "└──") format_string(link_name_s, true, true, " 4.0K", " └──")
); );
(r, r2) (r, r2)
} }
@@ -226,14 +226,14 @@ fn hard_link_output(dir_s: &str, file_path_s: &str, link_name_s: &str) -> (Strin
let r = format!( let r = format!(
"{} "{}
{}", {}",
format_string(dir_s, true, true, " 8.0K", ""), format_string(dir_s, true, true, " 8.0K", "─┬"),
format_string(file_path_s, true, true, " 4.0K", "└──") format_string(file_path_s, true, true, " 4.0K", " └──")
); );
let r2 = format!( let r2 = format!(
"{} "{}
{}", {}",
format_string(dir_s, true, true, " 8.0K", ""), format_string(dir_s, true, true, " 8.0K", "─┬"),
format_string(link_name_s, true, true, " 4.0K", "└──") format_string(link_name_s, true, true, " 4.0K", " └──")
); );
(r, r2) (r, r2)
} }
@@ -266,8 +266,8 @@ fn recursive_sym_link_output(dir: &str, link_name: &str) -> String {
format!( format!(
"{} "{}
{}", {}",
format_string(dir, true, true, " 4.0K", ""), format_string(dir, true, true, " 4.0K", "─┬"),
format_string(link_name, true, true, " 4.0K", "└──",), format_string(link_name, true, true, " 4.0K", " └──",),
) )
} }
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
@@ -275,8 +275,8 @@ fn recursive_sym_link_output(dir: &str, link_name: &str) -> String {
format!( format!(
"{} "{}
{}", {}",
format_string(dir, true, true, " 4.0K", ""), format_string(dir, true, true, " 4.0K", "─┬"),
format_string(link_name, true, true, " 0B", "└──",), format_string(link_name, true, true, " 0B", " └──",),
) )
} }