Skip to content

Commit

Permalink
Add function for formatting totals
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisChambers committed Jul 22, 2020
1 parent 26d240b commit c01b690
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,21 @@ fn print_file_dep_info(info: &FileInfoDepTree, prefix: &str, is_last: bool) {
/// Prints a single `FileInfoDepTree` to stdout.
fn print_dep(prefix: &str, is_last: bool, info: &FileInfoDepTree) {
let has_children = !info.deps.is_empty();
let totals = get_totals_string(info);


println!(
"{}{}─{} {}{}",
prefix,
get_sibling_connector(is_last),
get_child_connector(has_children),
info.name,
totals
get_formatted_totals(info)
);
}

fn get_totals_string(info: &FileInfoDepTree) -> String {
/// Gets the formatted totals for the provided `FileInfoDepTree`.
///
/// If the total size is reported as 0 then an empty string is returned.
fn get_formatted_totals(info: &FileInfoDepTree) -> String {
if info.total_size == 0 {
"".to_string()
} else {
Expand Down

0 comments on commit c01b690

Please sign in to comment.