From fd35734a94d32d8efbe658cf1e006c28ec0e5aa4 Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Wed, 2 Oct 2019 19:48:57 +0100 Subject: [PATCH 01/11] Simplify string code, remove into --- src/display.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/display.rs b/src/display.rs index 63e74181..94525710 100644 --- a/src/display.rs +++ b/src/display.rs @@ -35,14 +35,14 @@ fn get_size(nodes: &[(String, u64)], node_to_print: &str) -> Option { None } -fn display_node>( +fn display_node( node_to_print: &str, found: &mut HashSet, to_display: &[(String, u64)], is_biggest: bool, short_paths: bool, depth: Option, - indentation_str: S, + indentation_str: &str, ) { if found.contains(node_to_print) { return; @@ -57,9 +57,8 @@ fn display_node>( match get_size(to_display, node_to_print) { None => println!("Can not find path: {}", node_to_print), Some(size) => { - let is = indentation_str.into(); - print_this_node(node_to_print, size, is_biggest, short_paths, is.as_ref()); - let new_indent = clean_indentation_string(is); + print_this_node(node_to_print, size, is_biggest, short_paths, indentation_str); + let new_indent = clean_indentation_string(indentation_str); let ntp_with_slash = strip_end_slash(node_to_print); @@ -84,7 +83,7 @@ fn display_node>( is_biggest, short_paths, new_depth, - new_indent.to_string() + get_tree_chars(num_siblings != 0, has_children), + &*(new_indent.to_string() + get_tree_chars(num_siblings != 0, has_children)), ); is_biggest = false; } @@ -93,8 +92,8 @@ fn display_node>( } } -fn clean_indentation_string>(s: S) -> String { - let mut is = s.into(); +fn clean_indentation_string(s: &str) -> String { + let mut is :String = s.into(); is = is.replace("└─┬", " "); is = is.replace("└──", " "); is = is.replace("├──", "│ "); From 1c60d1e2ac257ebecbf1bc91f2e513806efab180 Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Wed, 2 Oct 2019 19:54:00 +0100 Subject: [PATCH 02/11] Display: replace boolean with integer count This will probably be useful when i refactor for the reverse mode --- src/display.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/display.rs b/src/display.rs index 94525710..9009d820 100644 --- a/src/display.rs +++ b/src/display.rs @@ -69,8 +69,8 @@ fn display_node( ntp_with_slash.matches('/').count() + 1 }; let mut num_siblings = count_siblings(to_display, num_slashes - 1, node_to_print); + let max_siblings = num_siblings; - let mut is_biggest = true; for &(ref k, _) in to_display.iter() { let temp = String::from(ensure_end_slash(node_to_print)); if k.starts_with(temp.as_str()) && k.matches('/').count() == num_slashes { @@ -80,12 +80,11 @@ fn display_node( k, found, to_display, - is_biggest, + num_siblings == max_siblings - 1, short_paths, new_depth, &*(new_indent.to_string() + get_tree_chars(num_siblings != 0, has_children)), ); - is_biggest = false; } } } From 9fbfcb275a1b5289935bcb26e4a366a85c0d9545 Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Wed, 2 Oct 2019 20:06:09 +0100 Subject: [PATCH 03/11] pull out a method (will be needed for reverse) --- src/display.rs | 65 +++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/src/display.rs b/src/display.rs index 9009d820..49170c1f 100644 --- a/src/display.rs +++ b/src/display.rs @@ -54,39 +54,50 @@ fn display_node( Some(0) => return, Some(d) => Some(d - 1), }; + match get_size(to_display, node_to_print) { None => println!("Can not find path: {}", node_to_print), Some(size) => { print_this_node(node_to_print, size, is_biggest, short_paths, indentation_str); - let new_indent = clean_indentation_string(indentation_str); + fan_out(node_to_print, found, to_display, short_paths, new_depth, indentation_str); + } + } +} - let ntp_with_slash = strip_end_slash(node_to_print); +fn fan_out( + node_to_print: &str, + found: &mut HashSet, + to_display: &[(String, u64)], + short_paths: bool, + new_depth: Option, + indentation_str: &str, +) { + let new_indent = clean_indentation_string(indentation_str); + let ntp_with_slash = strip_end_slash(node_to_print); - // Annoying edge case for when run on root directory - let num_slashes = if ntp_with_slash == "/" { - 1 - } else { - ntp_with_slash.matches('/').count() + 1 - }; - let mut num_siblings = count_siblings(to_display, num_slashes - 1, node_to_print); - let max_siblings = num_siblings; - - for &(ref k, _) in to_display.iter() { - let temp = String::from(ensure_end_slash(node_to_print)); - if k.starts_with(temp.as_str()) && k.matches('/').count() == num_slashes { - num_siblings -= 1; - let has_children = has_children(to_display, new_depth, k, num_slashes); - display_node( - k, - found, - to_display, - num_siblings == max_siblings - 1, - short_paths, - new_depth, - &*(new_indent.to_string() + get_tree_chars(num_siblings != 0, has_children)), - ); - } - } + // Annoying edge case for when run on root directory + let num_slashes = if ntp_with_slash == "/" { + 1 + } else { + ntp_with_slash.matches('/').count() + 1 + }; + let mut num_siblings = count_siblings(to_display, num_slashes - 1, node_to_print); + let max_siblings = num_siblings; + + for &(ref k, _) in to_display.iter() { + let temp = String::from(ensure_end_slash(node_to_print)); + if k.starts_with(temp.as_str()) && k.matches('/').count() == num_slashes { + num_siblings -= 1; + let has_children = has_children(to_display, new_depth, k, num_slashes); + display_node( + k, + found, + to_display, + num_siblings == max_siblings - 1, + short_paths, + new_depth, + &*(new_indent.to_string() + get_tree_chars(num_siblings != 0, has_children)), + ); } } } From ec2d9e19d4669a3919cd68b04dd2de4c6c94bc86 Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Wed, 2 Oct 2019 20:14:13 +0100 Subject: [PATCH 04/11] Run format, introduce new function. strip_end_slash_including_root will remove end slashes including the root directory. The root directory has been a long running problem because if we strip the final slash we will run dust on no directory instead of the root. --- src/display.rs | 37 +++++++++++++++++++++++-------------- src/utils/mod.rs | 8 ++++++++ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/display.rs b/src/display.rs index 49170c1f..d12b02aa 100644 --- a/src/display.rs +++ b/src/display.rs @@ -3,7 +3,7 @@ extern crate ansi_term; use self::ansi_term::Colour::Fixed; use self::ansi_term::Style; use std::collections::HashSet; -use utils::{ensure_end_slash, strip_end_slash}; +use utils::{ensure_end_slash, strip_end_slash_including_root}; static UNITS: [char; 4] = ['T', 'G', 'M', 'K']; @@ -58,8 +58,21 @@ fn display_node( match get_size(to_display, node_to_print) { None => println!("Can not find path: {}", node_to_print), Some(size) => { - print_this_node(node_to_print, size, is_biggest, short_paths, indentation_str); - fan_out(node_to_print, found, to_display, short_paths, new_depth, indentation_str); + print_this_node( + node_to_print, + size, + is_biggest, + short_paths, + indentation_str, + ); + fan_out( + node_to_print, + found, + to_display, + short_paths, + new_depth, + indentation_str, + ); } } } @@ -73,22 +86,18 @@ fn fan_out( indentation_str: &str, ) { let new_indent = clean_indentation_string(indentation_str); - let ntp_with_slash = strip_end_slash(node_to_print); + let num_slashes = strip_end_slash_including_root(node_to_print) + .matches('/') + .count(); - // Annoying edge case for when run on root directory - let num_slashes = if ntp_with_slash == "/" { - 1 - } else { - ntp_with_slash.matches('/').count() + 1 - }; - let mut num_siblings = count_siblings(to_display, num_slashes - 1, node_to_print); + let mut num_siblings = count_siblings(to_display, num_slashes, node_to_print); let max_siblings = num_siblings; for &(ref k, _) in to_display.iter() { let temp = String::from(ensure_end_slash(node_to_print)); - if k.starts_with(temp.as_str()) && k.matches('/').count() == num_slashes { + if k.starts_with(temp.as_str()) && k.matches('/').count() == num_slashes + 1 { num_siblings -= 1; - let has_children = has_children(to_display, new_depth, k, num_slashes); + let has_children = has_children(to_display, new_depth, k, num_slashes + 1); display_node( k, found, @@ -103,7 +112,7 @@ fn fan_out( } fn clean_indentation_string(s: &str) -> String { - let mut is :String = s.into(); + let mut is: String = s.into(); is = is.replace("└─┬", " "); is = is.replace("└──", " "); is = is.replace("├──", "│ "); diff --git a/src/utils/mod.rs b/src/utils/mod.rs index e33f08da..c6c813cf 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -64,6 +64,14 @@ pub fn strip_end_slash(s: &str) -> String { new_name } +pub fn strip_end_slash_including_root(s: &str) -> String { + let mut new_name = String::from(s); + while new_name.ends_with('/') || new_name.ends_with("/.") { + new_name.pop(); + } + new_name +} + fn examine_dir( top_dir: &str, apparent_size: bool, From 1d9a56e025a3268783fa2fd82005d7d9d3edb22e Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Wed, 2 Oct 2019 22:31:49 +0100 Subject: [PATCH 05/11] A way of supporting reverse --- src/display.rs | 98 ++++++++++++++++++++++++++++++++++++------------ src/main.rs | 18 ++++++++- src/utils/mod.rs | 9 +++++ 3 files changed, 100 insertions(+), 25 deletions(-) diff --git a/src/display.rs b/src/display.rs index d12b02aa..cf2a81b2 100644 --- a/src/display.rs +++ b/src/display.rs @@ -13,15 +13,32 @@ pub fn draw_it( depth: Option, base_dirs: HashSet, to_display: Vec<(String, u64)>, + is_reversed: bool, ) { if !permissions { eprintln!("Did not have permissions for all directories"); } let mut found = HashSet::new(); + let first_tree_chars = { + if is_reversed { + "─┴" + } else { + "─┬" + } + }; for &(ref k, _) in to_display.iter() { 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, + first_tree_chars, + is_reversed, + ); } } } @@ -36,18 +53,19 @@ fn get_size(nodes: &[(String, u64)], node_to_print: &str) -> Option { } fn display_node( - node_to_print: &str, - found: &mut HashSet, + node: &str, + nodes_already_found: &mut HashSet, to_display: &[(String, u64)], is_biggest: bool, short_paths: bool, depth: Option, - indentation_str: &str, + indent: &str, + is_reversed: bool, ) { - if found.contains(node_to_print) { + if nodes_already_found.contains(node) { return; } - found.insert(node_to_print.to_string()); + nodes_already_found.insert(node.to_string()); let new_depth = match depth { None => None, @@ -55,35 +73,36 @@ fn display_node( Some(d) => Some(d - 1), }; - match get_size(to_display, node_to_print) { - None => println!("Can not find path: {}", node_to_print), + match get_size(to_display, node) { + None => println!("Can not find path: {}", node), Some(size) => { - print_this_node( - node_to_print, - size, - is_biggest, - short_paths, - indentation_str, - ); + if !is_reversed { + print_this_node(node, size, is_biggest, short_paths, indent); + } fan_out( - node_to_print, - found, + node, + nodes_already_found, to_display, short_paths, new_depth, - indentation_str, + indent, + is_reversed, ); + if is_reversed { + print_this_node(node, size, is_biggest, short_paths, indent); + } } } } fn fan_out( node_to_print: &str, - found: &mut HashSet, + nodes_already_found: &mut HashSet, to_display: &[(String, u64)], short_paths: bool, new_depth: Option, indentation_str: &str, + is_reversed: bool, ) { let new_indent = clean_indentation_string(indentation_str); let num_slashes = strip_end_slash_including_root(node_to_print) @@ -98,14 +117,26 @@ fn fan_out( if k.starts_with(temp.as_str()) && k.matches('/').count() == num_slashes + 1 { num_siblings -= 1; let has_children = has_children(to_display, new_depth, k, num_slashes + 1); + let (new_tree_chars, biggest) = if is_reversed { + ( + get_tree_chars_reversed(num_siblings != max_siblings - 1, has_children), + num_siblings == 0, + ) + } else { + ( + get_tree_chars(num_siblings != 0, has_children), + num_siblings == max_siblings - 1, + ) + }; display_node( k, - found, + nodes_already_found, to_display, - num_siblings == max_siblings - 1, + biggest, short_paths, new_depth, - &*(new_indent.to_string() + get_tree_chars(num_siblings != 0, has_children)), + &*(new_indent.to_string() + new_tree_chars), + is_reversed, ); } } @@ -113,11 +144,18 @@ fn fan_out( fn clean_indentation_string(s: &str) -> String { let mut is: String = s.into(); + // For reversed: + is = is.replace("┌─┴", " "); + is = is.replace("┌──", " "); + is = is.replace("├─┴", "│ "); + is = is.replace("─┴", " "); + // For normal is = is.replace("└─┬", " "); is = is.replace("└──", " "); - is = is.replace("├──", "│ "); is = is.replace("├─┬", "│ "); is = is.replace("─┬", " "); + // For both + is = is.replace("├──", "│ "); is } @@ -163,6 +201,20 @@ fn get_tree_chars(has_smaller_siblings: bool, has_children: bool) -> &'static st } } +fn get_tree_chars_reversed(has_smaller_siblings: bool, has_children: bool) -> &'static str { + if !has_smaller_siblings { + if has_children { + "┌─┴" + } else { + "┬──" + } + } else if has_children { + "├─┴" + } else { + "├──" + } +} + fn print_this_node( node_name: &str, size: u64, diff --git a/src/main.rs b/src/main.rs index 5e4888a8..e6bfa799 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,10 @@ extern crate walkdir; use self::display::draw_it; use clap::{App, AppSettings, Arg}; -use utils::{find_big_ones, get_dir_tree, simplify_dir_names, sort, trim_deep_ones}; +use utils::{ + compare_tuple_smallest_first, find_big_ones, get_dir_tree, simplify_dir_names, sort, + trim_deep_ones, +}; mod display; mod utils; @@ -43,6 +46,12 @@ fn main() { .long("apparent-size") .help("If set will use file length. Otherwise we use blocks"), ) + .arg( + Arg::with_name("reverse") + .short("r") + .long("reverse") + .help("If applied tree will be printed upside down (biggest lowest)"), + ) .arg(Arg::with_name("inputs").multiple(true)) .get_matches(); @@ -85,18 +94,23 @@ fn main() { let simplified_dirs = simplify_dir_names(target_dirs); let (permissions, nodes) = get_dir_tree(&simplified_dirs, use_apparent_size); let sorted_data = sort(nodes); - let biggest_ones = { + let mut biggest_ones = { match depth { None => find_big_ones(sorted_data, number_of_lines + simplified_dirs.len()), Some(d) => trim_deep_ones(sorted_data, d, &simplified_dirs), } }; + if options.is_present("reverse") { + biggest_ones.sort_by(compare_tuple_smallest_first); + } + draw_it( permissions, !use_full_path, depth, simplified_dirs, biggest_ones, + options.is_present("reverse"), ); } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index c6c813cf..62636864 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -121,6 +121,15 @@ pub fn compare_tuple(a: &(String, u64), b: &(String, u64)) -> Ordering { } } +pub fn compare_tuple_smallest_first(a: &(String, u64), b: &(String, u64)) -> Ordering { + let result = a.1.cmp(&b.1); + if result == Ordering::Equal { + b.0.cmp(&a.0) + } else { + result + } +} + pub fn sort(data: HashMap) -> Vec<(String, u64)> { let mut new_l: Vec<(String, u64)> = data.iter().map(|(a, b)| (a.clone(), *b)).collect(); new_l.sort_by(|a, b| compare_tuple(&a, &b)); From e03094a4fa94290835187141f48ae34b9d61a76c Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Thu, 3 Oct 2019 23:07:52 +0100 Subject: [PATCH 06/11] Add reverse flag Pull several variables related to how output is printed into DisplayData struct --- src/display.rs | 236 +++++++++++++++++++++++-------------------------- src/main.rs | 15 ++-- 2 files changed, 120 insertions(+), 131 deletions(-) diff --git a/src/display.rs b/src/display.rs index cf2a81b2..4795c0bf 100644 --- a/src/display.rs +++ b/src/display.rs @@ -2,65 +2,129 @@ extern crate ansi_term; use self::ansi_term::Colour::Fixed; use self::ansi_term::Style; +use std::cmp::max; use std::collections::HashSet; use utils::{ensure_end_slash, strip_end_slash_including_root}; static UNITS: [char; 4] = ['T', 'G', 'M', 'K']; +pub struct DisplayData { + pub short_paths: bool, + pub is_reversed: bool, + pub to_display: Vec<(String, u64)>, +} + +impl DisplayData { + fn get_first_chars(&self) -> &str { + if self.is_reversed { + "─┴" + } else { + "─┬" + } + } + + fn get_tree_chars( + &self, + num_siblings: u64, + max_siblings: u64, + has_children: bool, + ) -> &'static str { + if self.is_reversed { + if num_siblings == max_siblings - 1 { + if has_children { + "┌─┴" + } else { + "┌──" + } + } else if has_children { + "├─┴" + } else { + "├──" + } + } else { + if num_siblings == 0 { + if has_children { + "└─┬" + } else { + "└──" + } + } else if has_children { + "├─┬" + } else { + "├──" + } + } + } + + fn biggest(&self, num_siblings: u64, max_siblings: u64) -> bool { + if self.is_reversed { + num_siblings == 0 + } else { + num_siblings == max_siblings - 1 + } + } + + fn get_size(&self, node_to_print: &str) -> Option { + for &(ref k, ref v) in self.to_display.iter() { + if *k == *node_to_print { + return Some(*v); + } + } + None + } + + fn count_siblings(&self, num_slashes: usize, ntp: &str) -> u64 { + self.to_display.iter().fold(0, |a, b| { + if b.0.starts_with(ntp) && b.0.as_str().matches('/').count() == num_slashes + 1 { + a + 1 + } else { + a + } + }) + } + + fn has_children(&self, new_depth: Option, ntp: &str, num_slashes: usize) -> bool { + // this shouldn't be needed we should have already stripped + if new_depth.is_none() || new_depth.unwrap() != 1 { + for &(ref k2, _) in self.to_display.iter() { + let ntp_with_slash = String::from(ntp.to_owned() + "/"); + if k2.starts_with(ntp_with_slash.as_str()) + && k2.matches('/').count() == num_slashes + 1 + { + return true; + } + } + } + false + } +} + pub fn draw_it( permissions: bool, - short_paths: bool, depth: Option, base_dirs: HashSet, - to_display: Vec<(String, u64)>, - is_reversed: bool, + display_data: &DisplayData, ) { if !permissions { eprintln!("Did not have permissions for all directories"); } + let first_tree_chars = display_data.get_first_chars(); let mut found = HashSet::new(); - let first_tree_chars = { - if is_reversed { - "─┴" - } else { - "─┬" - } - }; - for &(ref k, _) in to_display.iter() { + for &(ref k, _) in display_data.to_display.iter() { if base_dirs.contains(k) { - display_node( - &k, - &mut found, - &to_display, - true, - short_paths, - depth, - first_tree_chars, - is_reversed, - ); - } - } -} - -fn get_size(nodes: &[(String, u64)], node_to_print: &str) -> Option { - for &(ref k, ref v) in nodes.iter() { - if *k == *node_to_print { - return Some(*v); + display_node(&k, &mut found, true, depth, first_tree_chars, display_data); } } - None } fn display_node( node: &str, nodes_already_found: &mut HashSet, - to_display: &[(String, u64)], is_biggest: bool, - short_paths: bool, depth: Option, indent: &str, - is_reversed: bool, + display_data: &DisplayData, ) { if nodes_already_found.contains(node) { return; @@ -73,23 +137,17 @@ fn display_node( Some(d) => Some(d - 1), }; - match get_size(to_display, node) { + match display_data.get_size(node) { None => println!("Can not find path: {}", node), Some(size) => { - if !is_reversed { - print_this_node(node, size, is_biggest, short_paths, indent); + let short_path = display_data.short_paths; + // move this inside display_data? + if !display_data.is_reversed { + print_this_node(node, size, is_biggest, short_path, indent); } - fan_out( - node, - nodes_already_found, - to_display, - short_paths, - new_depth, - indent, - is_reversed, - ); - if is_reversed { - print_this_node(node, size, is_biggest, short_paths, indent); + fan_out(node, nodes_already_found, new_depth, indent, display_data); + if display_data.is_reversed { + print_this_node(node, size, is_biggest, short_path, indent); } } } @@ -98,45 +156,33 @@ fn display_node( fn fan_out( node_to_print: &str, nodes_already_found: &mut HashSet, - to_display: &[(String, u64)], - short_paths: bool, new_depth: Option, indentation_str: &str, - is_reversed: bool, + display_data: &DisplayData, ) { let new_indent = clean_indentation_string(indentation_str); let num_slashes = strip_end_slash_including_root(node_to_print) .matches('/') .count(); - let mut num_siblings = count_siblings(to_display, num_slashes, node_to_print); + let mut num_siblings = display_data.count_siblings(num_slashes, node_to_print); let max_siblings = num_siblings; - for &(ref k, _) in to_display.iter() { + for &(ref k, _) in display_data.to_display.iter() { let temp = String::from(ensure_end_slash(node_to_print)); if k.starts_with(temp.as_str()) && k.matches('/').count() == num_slashes + 1 { num_siblings -= 1; - let has_children = has_children(to_display, new_depth, k, num_slashes + 1); - let (new_tree_chars, biggest) = if is_reversed { - ( - get_tree_chars_reversed(num_siblings != max_siblings - 1, has_children), - num_siblings == 0, - ) - } else { - ( - get_tree_chars(num_siblings != 0, has_children), - num_siblings == max_siblings - 1, - ) - }; + let has_children = display_data.has_children(new_depth, k, num_slashes + 1); + let new_tree_chars = + display_data.get_tree_chars(num_siblings, max_siblings, has_children); + let biggest = display_data.biggest(num_siblings, max_siblings); display_node( k, nodes_already_found, - to_display, biggest, - short_paths, new_depth, &*(new_indent.to_string() + new_tree_chars), - is_reversed, + display_data, ); } } @@ -159,62 +205,6 @@ fn clean_indentation_string(s: &str) -> String { is } -fn count_siblings(to_display: &[(String, u64)], num_slashes: usize, ntp: &str) -> u64 { - to_display.iter().fold(0, |a, b| { - if b.0.starts_with(ntp) && b.0.as_str().matches('/').count() == num_slashes + 1 { - a + 1 - } else { - a - } - }) -} - -fn has_children( - to_display: &[(String, u64)], - new_depth: Option, - ntp: &str, - num_slashes: usize, -) -> bool { - if new_depth.is_none() || new_depth.unwrap() != 1 { - for &(ref k2, _) in to_display.iter() { - let ntp_with_slash = String::from(ntp.to_owned() + "/"); - if k2.starts_with(ntp_with_slash.as_str()) && k2.matches('/').count() == num_slashes + 1 - { - return true; - } - } - } - false -} - -fn get_tree_chars(has_smaller_siblings: bool, has_children: bool) -> &'static str { - if !has_smaller_siblings { - if has_children { - "└─┬" - } else { - "└──" - } - } else if has_children { - "├─┬" - } else { - "├──" - } -} - -fn get_tree_chars_reversed(has_smaller_siblings: bool, has_children: bool) -> &'static str { - if !has_smaller_siblings { - if has_children { - "┌─┴" - } else { - "┬──" - } - } else if has_children { - "├─┴" - } else { - "├──" - } -} - fn print_this_node( node_name: &str, size: u64, diff --git a/src/main.rs b/src/main.rs index e6bfa799..80b780d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ extern crate assert_cli; extern crate walkdir; use self::display::draw_it; +use self::display::DisplayData; use clap::{App, AppSettings, Arg}; use utils::{ compare_tuple_smallest_first, find_big_ones, get_dir_tree, simplify_dir_names, sort, @@ -103,15 +104,13 @@ fn main() { if options.is_present("reverse") { biggest_ones.sort_by(compare_tuple_smallest_first); } + let dd = DisplayData { + short_paths: !use_full_path, + is_reversed: options.is_present("reverse"), + to_display: biggest_ones, + }; - draw_it( - permissions, - !use_full_path, - depth, - simplified_dirs, - biggest_ones, - options.is_present("reverse"), - ); + draw_it(permissions, depth, simplified_dirs, &dd); } #[cfg(test)] From db6c8a019d1bf76a99e7c8b46c513538a52b9efe Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Sat, 5 Oct 2019 17:57:47 +0100 Subject: [PATCH 07/11] Massive refactor WIP Replace array of (string, int) pairs with tree of nodes. A tree of nodes more accurately represents the underlying file structure and hence is a better fit for the problem space. Regression: Reverse doesn't work in this commit. I suspect more methods can be simplifed and reduced. --- src/display.rs | 141 ++++++++++------------------------------------- src/main.rs | 45 ++++++++++++--- src/utils/mod.rs | 21 +++---- 3 files changed, 78 insertions(+), 129 deletions(-) diff --git a/src/display.rs b/src/display.rs index 4795c0bf..e6036674 100644 --- a/src/display.rs +++ b/src/display.rs @@ -2,16 +2,13 @@ extern crate ansi_term; use self::ansi_term::Colour::Fixed; use self::ansi_term::Style; -use std::cmp::max; -use std::collections::HashSet; -use utils::{ensure_end_slash, strip_end_slash_including_root}; +use utils::Node; static UNITS: [char; 4] = ['T', 'G', 'M', 'K']; pub struct DisplayData { pub short_paths: bool, pub is_reversed: bool, - pub to_display: Vec<(String, u64)>, } impl DisplayData { @@ -63,128 +60,54 @@ impl DisplayData { num_siblings == max_siblings - 1 } } - - fn get_size(&self, node_to_print: &str) -> Option { - for &(ref k, ref v) in self.to_display.iter() { - if *k == *node_to_print { - return Some(*v); - } - } - None - } - - fn count_siblings(&self, num_slashes: usize, ntp: &str) -> u64 { - self.to_display.iter().fold(0, |a, b| { - if b.0.starts_with(ntp) && b.0.as_str().matches('/').count() == num_slashes + 1 { - a + 1 - } else { - a - } - }) - } - - fn has_children(&self, new_depth: Option, ntp: &str, num_slashes: usize) -> bool { - // this shouldn't be needed we should have already stripped - if new_depth.is_none() || new_depth.unwrap() != 1 { - for &(ref k2, _) in self.to_display.iter() { - let ntp_with_slash = String::from(ntp.to_owned() + "/"); - if k2.starts_with(ntp_with_slash.as_str()) - && k2.matches('/').count() == num_slashes + 1 - { - return true; - } - } - } - false - } } pub fn draw_it( permissions: bool, depth: Option, - base_dirs: HashSet, - display_data: &DisplayData, + use_full_path: bool, + is_reversed: bool, + root_node: Node, ) { if !permissions { eprintln!("Did not have permissions for all directories"); } - let first_tree_chars = display_data.get_first_chars(); - let mut found = HashSet::new(); + let display_data = DisplayData { + short_paths: !use_full_path, + is_reversed, + }; - for &(ref k, _) in display_data.to_display.iter() { - if base_dirs.contains(k) { - display_node(&k, &mut found, true, depth, first_tree_chars, display_data); - } + for c in root_node.children { + let first_tree_chars = display_data.get_first_chars(); + display_node(*c, true, depth, first_tree_chars, &display_data) } } fn display_node( - node: &str, - nodes_already_found: &mut HashSet, + node: Node, is_biggest: bool, depth: Option, indent: &str, display_data: &DisplayData, ) { - if nodes_already_found.contains(node) { - return; - } - nodes_already_found.insert(node.to_string()); - let new_depth = match depth { None => None, Some(0) => return, Some(d) => Some(d - 1), }; - - match display_data.get_size(node) { - None => println!("Can not find path: {}", node), - Some(size) => { - let short_path = display_data.short_paths; - // move this inside display_data? - if !display_data.is_reversed { - print_this_node(node, size, is_biggest, short_path, indent); - } - fan_out(node, nodes_already_found, new_depth, indent, display_data); - if display_data.is_reversed { - print_this_node(node, size, is_biggest, short_path, indent); - } - } - } -} - -fn fan_out( - node_to_print: &str, - nodes_already_found: &mut HashSet, - new_depth: Option, - indentation_str: &str, - display_data: &DisplayData, -) { - let new_indent = clean_indentation_string(indentation_str); - let num_slashes = strip_end_slash_including_root(node_to_print) - .matches('/') - .count(); - - let mut num_siblings = display_data.count_siblings(num_slashes, node_to_print); - let max_siblings = num_siblings; - - for &(ref k, _) in display_data.to_display.iter() { - let temp = String::from(ensure_end_slash(node_to_print)); - if k.starts_with(temp.as_str()) && k.matches('/').count() == num_slashes + 1 { - num_siblings -= 1; - let has_children = display_data.has_children(new_depth, k, num_slashes + 1); - let new_tree_chars = - display_data.get_tree_chars(num_siblings, max_siblings, has_children); - let biggest = display_data.biggest(num_siblings, max_siblings); - display_node( - k, - nodes_already_found, - biggest, - new_depth, - &*(new_indent.to_string() + new_tree_chars), - display_data, - ); - } + let short = display_data.short_paths; + print_this_node(&node, is_biggest, short, indent); + + let mut num_siblings = node.children.len() as u64; + let max_sibling = num_siblings; + let new_indent = clean_indentation_string(indent); + + for c in node.children { + num_siblings -= 1; + let chars = display_data.get_tree_chars(num_siblings, max_sibling, c.children.len() > 0); + let is_biggest = display_data.biggest(num_siblings, max_sibling); + let full_indent = (new_indent.clone() + chars); + display_node(*c, is_biggest, new_depth, &*full_indent, display_data) } } @@ -205,18 +128,12 @@ fn clean_indentation_string(s: &str) -> String { is } -fn print_this_node( - node_name: &str, - size: u64, - is_biggest: bool, - short_paths: bool, - indentation: &str, -) { - let pretty_size = format!("{:>5}", human_readable_number(size),); +fn print_this_node(node: &Node, is_biggest: bool, short_paths: bool, indentation: &str) { + let pretty_size = format!("{:>5}", human_readable_number(node.size),); println!( "{}", format_string( - node_name, + &*node.name, is_biggest, short_paths, pretty_size.as_ref(), @@ -224,7 +141,7 @@ fn print_this_node( ) ) } - +// idea: squash these 2 pub fn format_string( dir_name: &str, is_biggest: bool, diff --git a/src/main.rs b/src/main.rs index 80b780d7..d7948d55 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,11 +4,10 @@ extern crate assert_cli; extern crate walkdir; use self::display::draw_it; -use self::display::DisplayData; use clap::{App, AppSettings, Arg}; use utils::{ compare_tuple_smallest_first, find_big_ones, get_dir_tree, simplify_dir_names, sort, - trim_deep_ones, + trim_deep_ones, Node, }; mod display; @@ -104,13 +103,45 @@ fn main() { if options.is_present("reverse") { biggest_ones.sort_by(compare_tuple_smallest_first); } - let dd = DisplayData { - short_paths: !use_full_path, - is_reversed: options.is_present("reverse"), - to_display: biggest_ones, + let tree = build_tree(&biggest_ones); + //println!("{:?}", tree); + + draw_it( + permissions, + depth, + use_full_path, + options.is_present("reverse"), + tree, + ); +} + +fn build_tree(biggest_ones: &Vec<(String, u64)>) -> Node { + let mut top_parent = Node { + name: "".to_string(), + size: 0, + children: vec![], }; - draw_it(permissions, depth, simplified_dirs, &dd); + // assume sorted order + for b in biggest_ones.clone() { + let n = Node { + name: b.0, + size: b.1, + children: vec![], + }; + recursively_build_tree(&mut top_parent, n) + } + top_parent +} + +fn recursively_build_tree(parent_node: &mut Node, new_node: Node) { + for c in parent_node.children.iter_mut() { + if new_node.name.starts_with(&c.name) { + return recursively_build_tree(&mut *c, new_node); + } + } + let temp = Box::::new(new_node); + parent_node.children.push(temp); } #[cfg(test)] diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 62636864..d4d89dcb 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -7,6 +7,13 @@ use walkdir::WalkDir; mod platform; use self::platform::*; +#[derive(Debug)] +pub struct Node { + pub name: String, + pub size: u64, + pub children: Vec>, +} + pub fn simplify_dir_names(filenames: Vec<&str>) -> HashSet { let mut top_level_names: HashSet = HashSet::new(); @@ -64,14 +71,6 @@ pub fn strip_end_slash(s: &str) -> String { new_name } -pub fn strip_end_slash_including_root(s: &str) -> String { - let mut new_name = String::from(s); - while new_name.ends_with('/') || new_name.ends_with("/.") { - new_name.pop(); - } - new_name -} - fn examine_dir( top_dir: &str, apparent_size: bool, @@ -93,6 +92,7 @@ fn examine_dir( inodes.insert(inode_dev_pair); } } + // This path and all its parent paths have their counter incremented let mut e_path = e.path().to_path_buf(); loop { let path_name = e_path.to_string_lossy().to_string(); @@ -112,7 +112,8 @@ fn examine_dir( } } } -pub fn compare_tuple(a: &(String, u64), b: &(String, u64)) -> Ordering { + +pub fn sort_by_size_first_name_second(a: &(String, u64), b: &(String, u64)) -> Ordering { let result = b.1.cmp(&a.1); if result == Ordering::Equal { a.0.cmp(&b.0) @@ -132,7 +133,7 @@ pub fn compare_tuple_smallest_first(a: &(String, u64), b: &(String, u64)) -> Ord pub fn sort(data: HashMap) -> Vec<(String, u64)> { let mut new_l: Vec<(String, u64)> = data.iter().map(|(a, b)| (a.clone(), *b)).collect(); - new_l.sort_by(|a, b| compare_tuple(&a, &b)); + new_l.sort_by(|a, b| sort_by_size_first_name_second(&a, &b)); new_l } From 4cffc4370b58fb85b7b94e72f67431cced5b3d5d Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Sun, 6 Oct 2019 21:59:17 +0100 Subject: [PATCH 08/11] Bring back the reverse flag Following the large refactor on the previous commit, this commit fixes the reverse functionality. Depth detection moved into the tree building instead of being calculated when drawing the tree to screen --- src/display.rs | 57 ++++++++++++++++++++++++------------------------ src/main.rs | 28 +++++++++++------------- src/utils/mod.rs | 9 -------- 3 files changed, 42 insertions(+), 52 deletions(-) diff --git a/src/display.rs b/src/display.rs index e6036674..510c2512 100644 --- a/src/display.rs +++ b/src/display.rs @@ -60,15 +60,18 @@ impl DisplayData { num_siblings == max_siblings - 1 } } + + fn get_children_from_node(&self, node: Node) -> impl Iterator> { + if self.is_reversed { + let n: Vec> = node.children.into_iter().rev().map(|a| a).collect(); + return n.into_iter(); + } else { + return node.children.into_iter(); + } + } } -pub fn draw_it( - permissions: bool, - depth: Option, - use_full_path: bool, - is_reversed: bool, - root_node: Node, -) { +pub fn draw_it(permissions: bool, use_full_path: bool, is_reversed: bool, root_node: Node) { if !permissions { eprintln!("Did not have permissions for all directories"); } @@ -77,37 +80,35 @@ pub fn draw_it( is_reversed, }; - for c in root_node.children { + for c in display_data.get_children_from_node(root_node) { let first_tree_chars = display_data.get_first_chars(); - display_node(*c, true, depth, first_tree_chars, &display_data) + display_node(*c, true, first_tree_chars, &display_data) } } -fn display_node( - node: Node, - is_biggest: bool, - depth: Option, - indent: &str, - display_data: &DisplayData, -) { - let new_depth = match depth { - None => None, - Some(0) => return, - Some(d) => Some(d - 1), - }; +fn display_node(node: Node, is_biggest: bool, indent: &str, display_data: &DisplayData) { let short = display_data.short_paths; - print_this_node(&node, is_biggest, short, indent); let mut num_siblings = node.children.len() as u64; let max_sibling = num_siblings; let new_indent = clean_indentation_string(indent); + let name = node.name.clone(); + let size = node.size; + + if !display_data.is_reversed { + print_this_node(&*name, size, is_biggest, short, indent); + } - for c in node.children { + for c in display_data.get_children_from_node(node) { num_siblings -= 1; let chars = display_data.get_tree_chars(num_siblings, max_sibling, c.children.len() > 0); let is_biggest = display_data.biggest(num_siblings, max_sibling); - let full_indent = (new_indent.clone() + chars); - display_node(*c, is_biggest, new_depth, &*full_indent, display_data) + let full_indent = new_indent.clone() + chars; + display_node(*c, is_biggest, &*full_indent, display_data) + } + + if display_data.is_reversed { + print_this_node(&*name, size, is_biggest, short, indent); } } @@ -128,12 +129,12 @@ fn clean_indentation_string(s: &str) -> String { is } -fn print_this_node(node: &Node, is_biggest: bool, short_paths: bool, indentation: &str) { - let pretty_size = format!("{:>5}", human_readable_number(node.size),); +fn print_this_node(name: &str, size: u64, is_biggest: bool, short_paths: bool, indentation: &str) { + let pretty_size = format!("{:>5}", human_readable_number(size),); println!( "{}", format_string( - &*node.name, + name, is_biggest, short_paths, pretty_size.as_ref(), diff --git a/src/main.rs b/src/main.rs index d7948d55..3fc2d4ff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,10 +5,7 @@ extern crate walkdir; use self::display::draw_it; use clap::{App, AppSettings, Arg}; -use utils::{ - compare_tuple_smallest_first, find_big_ones, get_dir_tree, simplify_dir_names, sort, - trim_deep_ones, Node, -}; +use utils::{find_big_ones, get_dir_tree, simplify_dir_names, sort, trim_deep_ones, Node}; mod display; mod utils; @@ -94,28 +91,24 @@ fn main() { let simplified_dirs = simplify_dir_names(target_dirs); let (permissions, nodes) = get_dir_tree(&simplified_dirs, use_apparent_size); let sorted_data = sort(nodes); - let mut biggest_ones = { + let biggest_ones = { match depth { None => find_big_ones(sorted_data, number_of_lines + simplified_dirs.len()), Some(d) => trim_deep_ones(sorted_data, d, &simplified_dirs), } }; - if options.is_present("reverse") { - biggest_ones.sort_by(compare_tuple_smallest_first); - } - let tree = build_tree(&biggest_ones); + let tree = build_tree(biggest_ones, depth); //println!("{:?}", tree); draw_it( permissions, - depth, use_full_path, options.is_present("reverse"), tree, ); } -fn build_tree(biggest_ones: &Vec<(String, u64)>) -> Node { +fn build_tree(biggest_ones: Vec<(String, u64)>, depth: Option) -> Node { let mut top_parent = Node { name: "".to_string(), size: 0, @@ -123,21 +116,26 @@ fn build_tree(biggest_ones: &Vec<(String, u64)>) -> Node { }; // assume sorted order - for b in biggest_ones.clone() { + for b in biggest_ones { let n = Node { name: b.0, size: b.1, children: vec![], }; - recursively_build_tree(&mut top_parent, n) + recursively_build_tree(&mut top_parent, n, depth) } top_parent } -fn recursively_build_tree(parent_node: &mut Node, new_node: Node) { +fn recursively_build_tree(parent_node: &mut Node, new_node: Node, depth: Option) { + let new_depth = match depth { + None => None, + Some(0) => return, + Some(d) => Some(d - 1), + }; for c in parent_node.children.iter_mut() { if new_node.name.starts_with(&c.name) { - return recursively_build_tree(&mut *c, new_node); + return recursively_build_tree(&mut *c, new_node, new_depth); } } let temp = Box::::new(new_node); diff --git a/src/utils/mod.rs b/src/utils/mod.rs index d4d89dcb..6ab741da 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -122,15 +122,6 @@ pub fn sort_by_size_first_name_second(a: &(String, u64), b: &(String, u64)) -> O } } -pub fn compare_tuple_smallest_first(a: &(String, u64), b: &(String, u64)) -> Ordering { - let result = a.1.cmp(&b.1); - if result == Ordering::Equal { - b.0.cmp(&a.0) - } else { - result - } -} - pub fn sort(data: HashMap) -> Vec<(String, u64)> { let mut new_l: Vec<(String, u64)> = data.iter().map(|(a, b)| (a.clone(), *b)).collect(); new_l.sort_by(|a, b| sort_by_size_first_name_second(&a, &b)); From 0c19a66432cd72a8adeceee6c6d3a53deb3bc4f8 Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Sun, 6 Oct 2019 22:16:16 +0100 Subject: [PATCH 09/11] Add test for reverse flag --- src/display.rs | 14 ++++---------- src/tests.rs | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/display.rs b/src/display.rs index 510c2512..da78bbf7 100644 --- a/src/display.rs +++ b/src/display.rs @@ -53,7 +53,7 @@ impl DisplayData { } } - fn biggest(&self, num_siblings: u64, max_siblings: u64) -> bool { + fn is_biggest(&self, num_siblings: u64, max_siblings: u64) -> bool { if self.is_reversed { num_siblings == 0 } else { @@ -102,7 +102,7 @@ fn display_node(node: Node, is_biggest: bool, indent: &str, display_data: &Displ for c in display_data.get_children_from_node(node) { num_siblings -= 1; let chars = display_data.get_tree_chars(num_siblings, max_sibling, c.children.len() > 0); - let is_biggest = display_data.biggest(num_siblings, max_sibling); + let is_biggest = display_data.is_biggest(num_siblings, max_sibling); let full_indent = new_indent.clone() + chars; display_node(*c, is_biggest, &*full_indent, display_data) } @@ -133,16 +133,10 @@ fn print_this_node(name: &str, size: u64, is_biggest: bool, short_paths: bool, i let pretty_size = format!("{:>5}", human_readable_number(size),); println!( "{}", - format_string( - name, - is_biggest, - short_paths, - pretty_size.as_ref(), - indentation - ) + format_string(name, is_biggest, short_paths, &*pretty_size, indentation) ) } -// idea: squash these 2 + pub fn format_string( dir_name: &str, is_biggest: bool, diff --git a/src/tests.rs b/src/tests.rs index 0e725341..096c1287 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -109,6 +109,27 @@ pub fn test_apparent_size() { .unwrap(); } +#[test] +pub fn test_reverse_flag() { + // variable names the same length make the output easier to read + let a = " ┌── a_file"; + let b = " ├── hello_file"; + let c = " ┌─┴ many"; + let d = " ─┴ test_dir"; + + assert_cli::Assert::main_binary() + .with_args(&["-r", "src/test_dir"]) + .stdout() + .contains(a) + .stdout() + .contains(b) + .stdout() + .contains(c) + .stdout() + .contains(d) + .unwrap(); +} + #[test] pub fn test_d_flag_works() { // We should see the top level directory but not the sub dirs / files: From 25c50f88c41ea8e2aa9d7cb9ee0db500bd29823f Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Tue, 8 Oct 2019 21:05:09 +0100 Subject: [PATCH 10/11] cargo upgrade --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d0ff9c7..7bcac884 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,7 +22,7 @@ dependencies = [ "difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "environment 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "skeptic 0.13.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -88,7 +88,7 @@ dependencies = [ "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -230,7 +230,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "proc-macro2" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -249,7 +249,7 @@ name = "quote" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -382,14 +382,14 @@ name = "serde_derive" version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "serde_json" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -407,7 +407,7 @@ dependencies = [ "error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -422,7 +422,7 @@ name = "syn" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -560,7 +560,7 @@ dependencies = [ "checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" "checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" -"checksum proc-macro2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "afdc77cc74ec70ed262262942ebb7dac3d479e9e5cfa2da1841c0806f6cdabcc" +"checksum proc-macro2 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90cf5f418035b98e655e9cdb225047638296b862b42411c4e45bb88d700f7fc0" "checksum pulldown-cmark 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eef52fac62d0ea7b9b4dc7da092aa64ea7ec3d90af6679422d3d7e0e14b6ee15" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" @@ -581,7 +581,7 @@ dependencies = [ "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "9796c9b7ba2ffe7a9ce53c2287dfc48080f4b2b362fcc245a259b3a7201119dd" "checksum serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)" = "4b133a43a1ecd55d4086bd5b4dc6c1751c68b1bfbeba7a5040442022c7e7c02e" -"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" +"checksum serde_json 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "2f72eb2a68a7dc3f9a691bfda9305a1c017a6215e5a4545c258500d2099a37c2" "checksum skeptic 0.13.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6fb8ed853fdc19ce09752d63f3a2e5b5158aeb261520cd75eb618bd60305165" "checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" "checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" From 0effaa7fd7e90f32512be0680ee3e9165cbd7aa8 Mon Sep 17 00:00:00 2001 From: "andy.boot" Date: Tue, 8 Oct 2019 21:05:37 +0100 Subject: [PATCH 11/11] Increment version --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7bcac884..b3da4850 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -141,7 +141,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "du-dust" -version = "0.3.2" +version = "0.4.0" dependencies = [ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "assert_cli 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index aa1051d8..f76d81c8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "du-dust" description = "A more intuitive version of du" -version = "0.3.2" +version = "0.4.0" authors = ["bootandy ", "nebkor "] documentation = "https://github.com/bootandy/dust"