Add command line option --quiet.

This commit is contained in:
Arthur Britto
2012-12-01 17:56:27 -08:00
parent 51ee96e804
commit c2d6dc0ab7
3 changed files with 58 additions and 48 deletions

View File

@@ -1,3 +1,6 @@
//
// TODO: Check permissions on config file before using it.
//
#include "Config.h" #include "Config.h"
#include "utils.h" #include "utils.h"
@@ -48,7 +51,7 @@
Config theConfig; Config theConfig;
void Config::setup(const std::string& strConf) void Config::setup(const std::string& strConf, bool bQuiet)
{ {
boost::system::error_code ec; boost::system::error_code ec;
@@ -58,6 +61,8 @@ void Config::setup(const std::string& strConf)
// that with "db" as the data directory. // that with "db" as the data directory.
// //
QUIET = bQuiet;
if (!strConf.empty()) if (!strConf.empty())
{ {
// --conf=<path> : everything is relative that file. // --conf=<path> : everything is relative that file.
@@ -172,7 +177,8 @@ void Config::setup(const std::string& strConf)
void Config::load() void Config::load()
{ {
std::cout << "Loading: " << CONFIG_FILE << std::endl; if (!QUIET)
std::cerr << "Loading: " << CONFIG_FILE << std::endl;
std::ifstream ifsConfig(CONFIG_FILE.c_str(), std::ios::in); std::ifstream ifsConfig(CONFIG_FILE.c_str(), std::ios::in);

View File

@@ -46,6 +46,8 @@ class Config
{ {
public: public:
// Configuration parameters // Configuration parameters
bool QUIET;
boost::filesystem::path CONFIG_FILE; boost::filesystem::path CONFIG_FILE;
boost::filesystem::path CONFIG_DIR; boost::filesystem::path CONFIG_DIR;
boost::filesystem::path DATA_DIR; boost::filesystem::path DATA_DIR;
@@ -113,7 +115,7 @@ public:
// Client behavior // Client behavior
int ACCOUNT_PROBE_MAX; // How far to scan for accounts. int ACCOUNT_PROBE_MAX; // How far to scan for accounts.
void setup(const std::string& strConf); void setup(const std::string& strConf, bool bQuiet);
void load(); void load();
}; };

View File

@@ -33,51 +33,51 @@ bool init_unit_test()
void printHelp(const po::options_description& desc) void printHelp(const po::options_description& desc)
{ {
cout << SYSTEM_NAME "d [options] <command> <params>" << endl; cerr << SYSTEM_NAME "d [options] <command> <params>" << endl;
cout << desc << endl; cerr << desc << endl;
cout << "Commands: " << endl; cerr << "Commands: " << endl;
cout << " account_domain_set <seed> <paying_account> [<domain>]" << endl; cerr << " account_domain_set <seed> <paying_account> [<domain>]" << endl;
cout << " account_email_set <seed> <paying_account> [<email_address>]" << endl; cerr << " account_email_set <seed> <paying_account> [<email_address>]" << endl;
cout << " account_info <account>|<nickname>" << endl; cerr << " account_info <account>|<nickname>" << endl;
cout << " account_info <seed>|<pass_phrase>|<key> [<index>]" << endl; cerr << " account_info <seed>|<pass_phrase>|<key> [<index>]" << endl;
cout << " account_message_set <seed> <paying_account> <pub_key>" << endl; cerr << " account_message_set <seed> <paying_account> <pub_key>" << endl;
cout << " account_publish_set <seed> <paying_account> <hash> <size>" << endl; cerr << " account_publish_set <seed> <paying_account> <hash> <size>" << endl;
cout << " account_rate_set <seed> <paying_account> <rate>" << endl; cerr << " account_rate_set <seed> <paying_account> <rate>" << endl;
cout << " account_wallet_set <seed> <paying_account> [<wallet_hash>]" << endl; cerr << " account_wallet_set <seed> <paying_account> [<wallet_hash>]" << endl;
cout << " connect <ip> [<port>]" << endl; cerr << " connect <ip> [<port>]" << endl;
cout << " data_delete <key>" << endl; cerr << " data_delete <key>" << endl;
cout << " data_fetch <key>" << endl; cerr << " data_fetch <key>" << endl;
cout << " data_store <key> <value>" << endl; cerr << " data_store <key> <value>" << endl;
cout << " ledger [<id>|current|lastclosed] [full]" << endl; cerr << " ledger [<id>|current|lastclosed] [full]" << endl;
cout << " logrotate " << endl; cerr << " logrotate " << endl;
cout << " nickname_info <nickname>" << endl; cerr << " nickname_info <nickname>" << endl;
cout << " nickname_set <seed> <paying_account> <nickname> [<offer_minimum>] [<authorization>]" << endl; cerr << " nickname_set <seed> <paying_account> <nickname> [<offer_minimum>] [<authorization>]" << endl;
cout << " offer_create <seed> <paying_account> <taker_pays_amount> <taker_pays_currency> <taker_pays_issuer> <takers_gets_amount> <takers_gets_currency> <takers_gets_issuer> <expires> [passive]" << endl; cerr << " offer_create <seed> <paying_account> <taker_pays_amount> <taker_pays_currency> <taker_pays_issuer> <takers_gets_amount> <takers_gets_currency> <takers_gets_issuer> <expires> [passive]" << endl;
cout << " offer_cancel <seed> <paying_account> <sequence>" << endl; cerr << " offer_cancel <seed> <paying_account> <sequence>" << endl;
cout << " password_fund <seed> <paying_account> [<account>]" << endl; cerr << " password_fund <seed> <paying_account> [<account>]" << endl;
cout << " password_set <master_seed> <regular_seed> [<account>]" << endl; cerr << " password_set <master_seed> <regular_seed> [<account>]" << endl;
cout << " peers" << endl; cerr << " peers" << endl;
cout << " ripple ..." << endl; cerr << " ripple ..." << endl;
cout << " ripple_lines_get <account>|<nickname>|<account_public_key> [<index>]" << endl; cerr << " ripple_lines_get <account>|<nickname>|<account_public_key> [<index>]" << endl;
cout << " ripple_line_set <seed> <paying_account> <destination_account> <limit_amount> <currency> [<quality_in>] [<quality_out>]" << endl; cerr << " ripple_line_set <seed> <paying_account> <destination_account> <limit_amount> <currency> [<quality_in>] [<quality_out>]" << endl;
cout << " send <seed> <paying_account> <account_id> <amount> [<currency>] [<send_max>] [<send_currency>]" << endl; cerr << " send <seed> <paying_account> <account_id> <amount> [<currency>] [<send_max>] [<send_currency>]" << endl;
cout << " stop" << endl; cerr << " stop" << endl;
cout << " tx <id>" << endl; cerr << " tx <id>" << endl;
cout << " unl_add <domain>|<public> [<comment>]" << endl; cerr << " unl_add <domain>|<public> [<comment>]" << endl;
cout << " unl_delete <domain>|<public_key>" << endl; cerr << " unl_delete <domain>|<public_key>" << endl;
cout << " unl_list" << endl; cerr << " unl_list" << endl;
cout << " unl_load" << endl; cerr << " unl_load" << endl;
cout << " unl_network" << endl; cerr << " unl_network" << endl;
cout << " unl_reset" << endl; cerr << " unl_reset" << endl;
cout << " validation_create [<seed>|<pass_phrase>|<key>]" << endl; cerr << " validation_create [<seed>|<pass_phrase>|<key>]" << endl;
cout << " validation_seed [<seed>|<pass_phrase>|<key>]" << endl; cerr << " validation_seed [<seed>|<pass_phrase>|<key>]" << endl;
cout << " wallet_add <regular_seed> <paying_account> <master_seed> [<initial_funds>] [<account_annotation>]" << endl; cerr << " wallet_add <regular_seed> <paying_account> <master_seed> [<initial_funds>] [<account_annotation>]" << endl;
cout << " wallet_accounts <seed>" << endl; cerr << " wallet_accounts <seed>" << endl;
cout << " wallet_claim <master_seed> <regular_seed> [<source_tag>] [<account_annotation>]" << endl; cerr << " wallet_claim <master_seed> <regular_seed> [<source_tag>] [<account_annotation>]" << endl;
cout << " wallet_seed [<seed>|<passphrase>|<passkey>]" << endl; cerr << " wallet_seed [<seed>|<passphrase>|<passkey>]" << endl;
cout << " wallet_propose [<passphrase>]" << endl; cerr << " wallet_propose [<passphrase>]" << endl;
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
@@ -96,6 +96,7 @@ int main(int argc, char* argv[])
("standalone,a", "Run with no peers.") ("standalone,a", "Run with no peers.")
("test,t", "Perform unit tests.") ("test,t", "Perform unit tests.")
("parameters", po::value< vector<string> >(), "Specify comma separated parameters.") ("parameters", po::value< vector<string> >(), "Specify comma separated parameters.")
("quiet,q", "Reduce diagnotics.")
("verbose,v", "Increase log level.") ("verbose,v", "Increase log level.")
("load", "Load the current ledger from the local DB.") ("load", "Load the current ledger from the local DB.")
("start", "Start from a fresh Ledger.") ("start", "Start from a fresh Ledger.")
@@ -138,7 +139,6 @@ int main(int argc, char* argv[])
} }
} }
if (vm.count("verbose")) if (vm.count("verbose"))
Log::setMinSeverity(lsTRACE, true); Log::setMinSeverity(lsTRACE, true);
else else
@@ -152,7 +152,9 @@ int main(int argc, char* argv[])
if (!iResult) if (!iResult)
{ {
theConfig.setup(vm.count("conf") ? vm["conf"].as<std::string>() : ""); theConfig.setup(
vm.count("conf") ? vm["conf"].as<std::string>() : "", // Config file.
!!vm.count("quiet")); // Quiet flag.
if (vm.count("standalone")) if (vm.count("standalone"))
{ {