Changeset 2353


Ignore:
Timestamp:
17/10/2008 00:15:25 (4 years ago)
Author:
chris
Message:

Add -m option to bbackupquery usage command for machine-readable output.

Location:
box/trunk/bin/bbackupquery
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • box/trunk/bin/bbackupquery/BackupQueries.cpp

    r2283 r2353  
    223223                { "restore", "drif" }, 
    224224                { "help", "" }, 
    225                 { "usage", "" }, 
     225                { "usage", "m" }, 
    226226                { "undelete", "" }, 
    227227                { "delete", "" }, 
     
    359359                 
    360360        case Command_Usage: 
    361                 CommandUsage(); 
     361                CommandUsage(opts); 
    362362                break; 
    363363                 
     
    22492249// 
    22502250// -------------------------------------------------------------------------- 
    2251 void BackupQueries::CommandUsage() 
    2252 { 
     2251void BackupQueries::CommandUsage(const bool *opts) 
     2252{ 
     2253        bool MachineReadable = opts['m']; 
     2254 
    22532255        // Request full details from the server 
    22542256        std::auto_ptr<BackupProtocolClientAccountUsage> usage(mrConnection.QueryGetAccountUsage()); 
     
    22572259        int64_t hardLimit = usage->GetBlocksHardLimit(); 
    22582260        int32_t blockSize = usage->GetBlockSize(); 
    2259         CommandUsageDisplayEntry("Used", usage->GetBlocksUsed(), hardLimit, blockSize); 
    2260         CommandUsageDisplayEntry("Old files", usage->GetBlocksInOldFiles(), hardLimit, blockSize); 
    2261         CommandUsageDisplayEntry("Deleted files", usage->GetBlocksInDeletedFiles(), hardLimit, blockSize); 
    2262         CommandUsageDisplayEntry("Directories", usage->GetBlocksInDirectories(), hardLimit, blockSize); 
    2263         CommandUsageDisplayEntry("Soft limit", usage->GetBlocksSoftLimit(), hardLimit, blockSize); 
    2264         CommandUsageDisplayEntry("Hard limit", hardLimit, hardLimit, blockSize); 
    2265 } 
    2266  
    2267  
    2268 // -------------------------------------------------------------------------- 
    2269 // 
    2270 // Function 
    2271 //              Name:    BackupQueries::CommandUsageDisplayEntry(const char *, int64_t, int64_t, int32_t) 
     2261        CommandUsageDisplayEntry("Used", usage->GetBlocksUsed(), hardLimit, 
     2262                blockSize, MachineReadable); 
     2263        CommandUsageDisplayEntry("Old files", usage->GetBlocksInOldFiles(), 
     2264                hardLimit, blockSize, MachineReadable); 
     2265        CommandUsageDisplayEntry("Deleted files", usage->GetBlocksInDeletedFiles(), 
     2266                hardLimit, blockSize, MachineReadable); 
     2267        CommandUsageDisplayEntry("Directories", usage->GetBlocksInDirectories(), 
     2268                hardLimit, blockSize, MachineReadable); 
     2269        CommandUsageDisplayEntry("Soft limit", usage->GetBlocksSoftLimit(), 
     2270                hardLimit, blockSize, MachineReadable); 
     2271        CommandUsageDisplayEntry("Hard limit", hardLimit, hardLimit, blockSize, 
     2272                MachineReadable); 
     2273} 
     2274 
     2275 
     2276// -------------------------------------------------------------------------- 
     2277// 
     2278// Function 
     2279//              Name:    BackupQueries::CommandUsageDisplayEntry(const char *, 
     2280//                       int64_t, int64_t, int32_t, bool) 
    22722281//              Purpose: Display an entry in the usage table 
    22732282//              Created: 19/4/04 
    22742283// 
    22752284// -------------------------------------------------------------------------- 
    2276 void BackupQueries::CommandUsageDisplayEntry(const char *Name, int64_t Size, int64_t HardLimit, int32_t BlockSize) 
    2277 { 
    2278         std::cout << FormatUsageLineStart(Name, false) << 
    2279                 FormatUsageBar(Size, Size * BlockSize, HardLimit * BlockSize, false) << 
    2280                 std::endl; 
     2285void BackupQueries::CommandUsageDisplayEntry(const char *Name, int64_t Size, 
     2286int64_t HardLimit, int32_t BlockSize, bool MachineReadable) 
     2287{ 
     2288        std::cout << FormatUsageLineStart(Name, MachineReadable) << 
     2289                FormatUsageBar(Size, Size * BlockSize, HardLimit * BlockSize, 
     2290                        MachineReadable) << std::endl; 
    22812291} 
    22822292 
  • box/trunk/bin/bbackupquery/BackupQueries.h

    r2283 r2353  
    5959        void CommandDelete(const std::vector<std::string> &args, 
    6060                const bool *opts); 
    61         void CommandUsage(); 
     61        void CommandUsage(const bool *opts); 
    6262        void CommandUsageDisplayEntry(const char *Name, int64_t Size, 
    63                 int64_t HardLimit, int32_t BlockSize); 
     63                int64_t HardLimit, int32_t BlockSize, bool MachineReadable); 
    6464        void CommandHelp(const std::vector<std::string> &args); 
    6565 
  • box/trunk/bin/bbackupquery/documentation.txt

    r2283 r2353  
    143143< 
    144144 
    145 > usage 
     145> usage [-m] 
    146146 
    147147        Show space used on the server for this account. 
     148 
     149        -m -- display the output in machine-readable form 
    148150 
    149151        Used: Total amount of space used on the server. 
Note: See TracChangeset for help on using the changeset viewer.