summaryrefslogtreecommitdiffstats
path: root/src/common.rs
diff options
context:
space:
mode:
authorSebastian Thiel <sthiel@thoughtworks.com>2019-06-01 14:12:26 +0530
committerSebastian Thiel <sthiel@thoughtworks.com>2019-06-01 14:12:26 +0530
commite7da7843ad7894a3560b4d70076a74798404da94 (patch)
treeea657e381c22a049c54d38b4edff55796451c429 /src/common.rs
parent9ba5a348c67a898abb0ae648e686da48649a33df (diff)
Nicer formatting of numbers
Diffstat (limited to 'src/common.rs')
-rw-r--r--src/common.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/common.rs b/src/common.rs
index 91a24f1..e17a712 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -26,9 +26,23 @@ impl WalkOptions {
Binary => true,
Metric => false,
};
- Byte::from_bytes(b as u128)
+ let b = Byte::from_bytes(b as u128)
.get_appropriate_unit(binary)
- .format(2)
+ .format(2);
+ let mut splits = b.split(' ');
+ match (splits.next(), splits.next()) {
+ (Some(bytes), Some(unit)) => format!(
+ "{:>8} {:>unit_width$}",
+ bytes,
+ unit,
+ unit_width = match self.format {
+ Binary => 3,
+ Metric => 2,
+ _ => 2,
+ }
+ ),
+ _ => b,
+ }
}
pub fn iter_from_path(&self, path: &Path, sort: Sorting) -> WalkDir {