[Box Backup-commit] COMMIT r2353 - box/trunk/bin/bbackupquery
boxbackup-dev at boxbackup.org
boxbackup-dev at boxbackup.org
Fri Oct 17 00:15:26 BST 2008
Author: chris
Date: 2008-10-17 00:15:25 +0100 (Fri, 17 Oct 2008)
New Revision: 2353
Modified:
box/trunk/bin/bbackupquery/BackupQueries.cpp
box/trunk/bin/bbackupquery/BackupQueries.h
box/trunk/bin/bbackupquery/documentation.txt
Log:
Add -m option to bbackupquery usage command for machine-readable output.
Modified: box/trunk/bin/bbackupquery/BackupQueries.cpp
===================================================================
--- box/trunk/bin/bbackupquery/BackupQueries.cpp 2008-10-13 14:39:01 UTC (rev 2352)
+++ box/trunk/bin/bbackupquery/BackupQueries.cpp 2008-10-16 23:15:25 UTC (rev 2353)
@@ -222,7 +222,7 @@
{ "compare", "alcqAEQ" },
{ "restore", "drif" },
{ "help", "" },
- { "usage", "" },
+ { "usage", "m" },
{ "undelete", "" },
{ "delete", "" },
{ NULL, NULL }
@@ -358,7 +358,7 @@
break;
case Command_Usage:
- CommandUsage();
+ CommandUsage(opts);
break;
case Command_Help:
@@ -2248,36 +2248,46 @@
// Created: 19/4/04
//
// --------------------------------------------------------------------------
-void BackupQueries::CommandUsage()
+void BackupQueries::CommandUsage(const bool *opts)
{
+ bool MachineReadable = opts['m'];
+
// Request full details from the server
std::auto_ptr<BackupProtocolClientAccountUsage> usage(mrConnection.QueryGetAccountUsage());
// Display each entry in turn
int64_t hardLimit = usage->GetBlocksHardLimit();
int32_t blockSize = usage->GetBlockSize();
- CommandUsageDisplayEntry("Used", usage->GetBlocksUsed(), hardLimit, blockSize);
- CommandUsageDisplayEntry("Old files", usage->GetBlocksInOldFiles(), hardLimit, blockSize);
- CommandUsageDisplayEntry("Deleted files", usage->GetBlocksInDeletedFiles(), hardLimit, blockSize);
- CommandUsageDisplayEntry("Directories", usage->GetBlocksInDirectories(), hardLimit, blockSize);
- CommandUsageDisplayEntry("Soft limit", usage->GetBlocksSoftLimit(), hardLimit, blockSize);
- CommandUsageDisplayEntry("Hard limit", hardLimit, hardLimit, blockSize);
+ CommandUsageDisplayEntry("Used", usage->GetBlocksUsed(), hardLimit,
+ blockSize, MachineReadable);
+ CommandUsageDisplayEntry("Old files", usage->GetBlocksInOldFiles(),
+ hardLimit, blockSize, MachineReadable);
+ CommandUsageDisplayEntry("Deleted files", usage->GetBlocksInDeletedFiles(),
+ hardLimit, blockSize, MachineReadable);
+ CommandUsageDisplayEntry("Directories", usage->GetBlocksInDirectories(),
+ hardLimit, blockSize, MachineReadable);
+ CommandUsageDisplayEntry("Soft limit", usage->GetBlocksSoftLimit(),
+ hardLimit, blockSize, MachineReadable);
+ CommandUsageDisplayEntry("Hard limit", hardLimit, hardLimit, blockSize,
+ MachineReadable);
}
// --------------------------------------------------------------------------
//
// Function
-// Name: BackupQueries::CommandUsageDisplayEntry(const char *, int64_t, int64_t, int32_t)
+// Name: BackupQueries::CommandUsageDisplayEntry(const char *,
+// int64_t, int64_t, int32_t, bool)
// Purpose: Display an entry in the usage table
// Created: 19/4/04
//
// --------------------------------------------------------------------------
-void BackupQueries::CommandUsageDisplayEntry(const char *Name, int64_t Size, int64_t HardLimit, int32_t BlockSize)
+void BackupQueries::CommandUsageDisplayEntry(const char *Name, int64_t Size,
+int64_t HardLimit, int32_t BlockSize, bool MachineReadable)
{
- std::cout << FormatUsageLineStart(Name, false) <<
- FormatUsageBar(Size, Size * BlockSize, HardLimit * BlockSize, false) <<
- std::endl;
+ std::cout << FormatUsageLineStart(Name, MachineReadable) <<
+ FormatUsageBar(Size, Size * BlockSize, HardLimit * BlockSize,
+ MachineReadable) << std::endl;
}
Modified: box/trunk/bin/bbackupquery/BackupQueries.h
===================================================================
--- box/trunk/bin/bbackupquery/BackupQueries.h 2008-10-13 14:39:01 UTC (rev 2352)
+++ box/trunk/bin/bbackupquery/BackupQueries.h 2008-10-16 23:15:25 UTC (rev 2353)
@@ -58,9 +58,9 @@
void CommandUndelete(const std::vector<std::string> &args, const bool *opts);
void CommandDelete(const std::vector<std::string> &args,
const bool *opts);
- void CommandUsage();
+ void CommandUsage(const bool *opts);
void CommandUsageDisplayEntry(const char *Name, int64_t Size,
- int64_t HardLimit, int32_t BlockSize);
+ int64_t HardLimit, int32_t BlockSize, bool MachineReadable);
void CommandHelp(const std::vector<std::string> &args);
// Implementations
Modified: box/trunk/bin/bbackupquery/documentation.txt
===================================================================
--- box/trunk/bin/bbackupquery/documentation.txt 2008-10-13 14:39:01 UTC (rev 2352)
+++ box/trunk/bin/bbackupquery/documentation.txt 2008-10-16 23:15:25 UTC (rev 2353)
@@ -142,10 +142,12 @@
stored format, which is encrypted and compressed.
<
-> usage
+> usage [-m]
Show space used on the server for this account.
+ -m -- display the output in machine-readable form
+
Used: Total amount of space used on the server.
Old files: Space used by old files
Deleted files: Space used by deleted files
More information about the Boxbackup-commit
mailing list