diff options
author | Chris Wilson <chris+github@qwirx.com> | 2008-04-03 22:32:46 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2008-04-03 22:32:46 +0000 |
commit | 1aee1d8842576aa2a2cf370f5f5466aa58f17a55 (patch) | |
tree | e6db0f1e9a8b956ac66568c86aa5a2cc0b23fc4f /bin/bbackupquery | |
parent | 947d4f202bc72ceff341ae4401ecc9ceb06759c7 (diff) |
Make usage output (from bbstoreaccounts info and bbackupquery usage)
consistent and easier to read, with blocks, B/kB/MB/GB, % and an ASCII
bar graph.
Diffstat (limited to 'bin/bbackupquery')
-rw-r--r-- | bin/bbackupquery/BackupQueries.cpp | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp index 197cd3b7..0faa4770 100644 --- a/bin/bbackupquery/BackupQueries.cpp +++ b/bin/bbackupquery/BackupQueries.cpp @@ -27,6 +27,8 @@ #include <set> #include <limits> +#include <iostream> +#include <ostream> #include "BackupQueries.h" #include "Utils.h" @@ -2156,22 +2158,9 @@ void BackupQueries::CommandUsage() // -------------------------------------------------------------------------- void BackupQueries::CommandUsageDisplayEntry(const char *Name, int64_t Size, int64_t HardLimit, int32_t BlockSize) { - // Calculate size in Mb - double mb = (((double)Size) * ((double)BlockSize)) / ((double)(1024*1024)); - int64_t percent = (Size * 100) / HardLimit; - - // Bar graph - char bar[41]; - unsigned int b = (int)((Size * (sizeof(bar)-1)) / HardLimit); - if(b > sizeof(bar)-1) {b = sizeof(bar)-1;} - for(unsigned int l = 0; l < b; l++) - { - bar[l] = '*'; - } - bar[b] = '\0'; - - // Print the entryj - ::printf("%14s %10.1fMb %3d%% %s\n", Name, mb, (int32_t)percent, bar); + std::cout << FormatUsageLineStart(Name) << + FormatUsageBar(Size, Size * BlockSize, HardLimit * BlockSize) << + std::endl; } |