mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Make printing slightly prettier
This commit is contained in:
+20
-4
@@ -271,8 +271,10 @@ fn display_node<S: Into<String>>(
|
|||||||
let mut is = indentation_str.into();
|
let mut is = indentation_str.into();
|
||||||
print_this_node(node_to_print, is_first, depth, is.as_ref());
|
print_this_node(node_to_print, is_first, depth, is.as_ref());
|
||||||
|
|
||||||
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.dir.name.matches('/').count();
|
let printable_node_slashes = node_to_print.dir.name.matches('/').count();
|
||||||
|
|
||||||
@@ -287,15 +289,29 @@ fn display_node<S: Into<String>>(
|
|||||||
});
|
});
|
||||||
|
|
||||||
let mut is_biggest = true;
|
let mut is_biggest = true;
|
||||||
|
let mut has_display_children = false;
|
||||||
for node in to_display {
|
for node in to_display {
|
||||||
if node_to_print.children.contains(node) {
|
if node_to_print.children.contains(node) {
|
||||||
|
let has_children = node.children.len() > 0;
|
||||||
if node.dir.name.matches("/").count() == printable_node_slashes + 1 {
|
if node.dir.name.matches("/").count() == printable_node_slashes + 1 {
|
||||||
num_sibblings -= 1;
|
num_sibblings -= 1;
|
||||||
|
for ref n in node.children.iter() {
|
||||||
|
has_display_children = has_display_children || to_display.contains(n);
|
||||||
|
}
|
||||||
|
let has_children = has_children && has_display_children;
|
||||||
let tree_chars = {
|
let tree_chars = {
|
||||||
if num_sibblings == 0 {
|
if num_sibblings == 0 {
|
||||||
"└──"
|
if has_children {
|
||||||
|
"└─┬"
|
||||||
|
} else {
|
||||||
|
"└──"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
"├──"
|
if has_children {
|
||||||
|
"├─┬"
|
||||||
|
} else {
|
||||||
|
"├──"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
display_node(
|
display_node(
|
||||||
|
|||||||
Reference in New Issue
Block a user