[config] Help text cleanup #10748

Open
wants to merge 9 commits into
from
View
@@ -37,15 +37,15 @@ std::string HelpMessageCli()
strUsage += HelpMessageOpt("-?", _("This help message"));
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), BITCOIN_CONF_FILENAME));
strUsage += HelpMessageOpt("-datadir=<dir>", _("Specify data directory"));
- AppendParamsHelpMessages(strUsage);
strUsage += HelpMessageOpt("-named", strprintf(_("Pass named instead of positional arguments (default: %s)"), DEFAULT_NAMED));
+ strUsage += HelpMessageOpt("-rpcclienttimeout=<n>", strprintf(_("Timeout in seconds during HTTP requests, or 0 for no timeout. (default: %d)"), DEFAULT_HTTP_CLIENT_TIMEOUT));
strUsage += HelpMessageOpt("-rpcconnect=<ip>", strprintf(_("Send commands to node running on <ip> (default: %s)"), DEFAULT_RPCCONNECT));
+ strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Connect to JSON-RPC on <port> (default: %u or testnet: %u)"), defaultBaseParams->RPCPort(), testnetBaseParams->RPCPort()));
- strUsage += HelpMessageOpt("-rpcwait", _("Wait for RPC server to start"));
strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections"));
- strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
- strUsage += HelpMessageOpt("-rpcclienttimeout=<n>", strprintf(_("Timeout in seconds during HTTP requests, or 0 for no timeout. (default: %d)"), DEFAULT_HTTP_CLIENT_TIMEOUT));
+ strUsage += HelpMessageOpt("-rpcwait", _("Wait for RPC server to start"));
strUsage += HelpMessageOpt("-stdin", _("Read extra arguments from standard input, one per line until EOF/Ctrl-D (recommended for sensitive information such as passphrases)"));
+ AppendParamsHelpMessages(strUsage);
return strUsage;
}
View
@@ -19,6 +19,9 @@
#include "httpserver.h"
#include "httprpc.h"
#include "utilstrencodings.h"
+#ifdef ENABLE_WALLET
@laanwj

laanwj Jul 10, 2017

Owner

Right, we need to move the wallet dependency up here if we want to remove the wallet dependency from libbitcoin_server.

+#include "wallet/wallet.h"
+#endif
#include <boost/thread.hpp>
@@ -87,7 +90,17 @@ bool AppInit(int argc, char* argv[])
strUsage += "\n" + _("Usage:") + "\n" +
" bitcoind [options] " + strprintf(_("Start %s Daemon"), _(PACKAGE_NAME)) + "\n";
- strUsage += "\n" + HelpMessage(HMM_BITCOIND);
+ strUsage += "\n" + HelpMessage();
+
+#if HAVE_DECL_DAEMON
+ strUsage += HelpMessageGroup(_("Server options:"));
+ strUsage += HelpMessageOpt("-daemon", _("Run in the background as a daemon and accept commands"));
+#endif
+
+#ifdef ENABLE_WALLET
+ strUsage += CWallet::GetWalletHelpString(); // "Wallet options" / "Wallet debugging/testing options"
+#endif
+
}
fprintf(stdout, "%s", strUsage.c_str());
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -50,14 +50,8 @@ bool AppInitSanityChecks();
*/
bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler);
-/** The help message mode determines what help message to show */
-enum HelpMessageMode {
- HMM_BITCOIND,
- HMM_BITCOIN_QT
-};
-
/** Help for options shared between UI and daemon (for -help) */
-std::string HelpMessage(HelpMessageMode mode);
+std::string HelpMessage();
/** Returns licensing information (for -version) */
std::string LicenseInfo();
View
@@ -20,6 +20,9 @@
#include "clientversion.h"
#include "init.h"
#include "util.h"
+#ifdef ENABLE_WALLET
@laanwj

laanwj Jul 10, 2017 edited

Owner

Please don't introduce a wallet dependency here. Utilitydialog is supposed to be neutral in that regard.

Edit: though I don't really see an alternative either...

@jnewbery

jnewbery Jul 10, 2017

Member

I'm not very familiar with the qt code. I see that there are already plenty of #ifdef ENABLE_WALLET in the qt code already. Is there something special about utilitydialog.cpp ?

I'm very happy to take an alternative approach if you have suggestions.

@laanwj

laanwj Jul 10, 2017

Owner

Is there something special about utilitydialog.cpp ?

No, but adding ENABLE_WALLET should be avoided everywhere if possible. I think it may be unavoidable here, though.

@jonasschnelli

jonasschnelli Jul 13, 2017

Member

I think a possible solution would be to have a signal for collecting help strings. The signal emitter then could take care of sorting the groups. But probably out of scope.

@jnewbery

jnewbery Jul 13, 2017

Member

possible solution would be to have a signal for collecting help strings

Certainly possible to have a signal for wallet to pass its help strings to server, but qt also has its own help strings (bitcoind should also have its own help string for -server, but that's actually implemented in init.cpp for now). Difficult to see where/how those would all be sorted.

Really I don't think it matters too much, and I'm happy with other approaches, or to drop this PR entirely if people don't think this is an improvement.

+#include "wallet/wallet.h"
+#endif
#include <stdio.h>
@@ -77,21 +80,19 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
cursor.insertText(header);
cursor.insertBlock();
- std::string strUsage = HelpMessage(HMM_BITCOIN_QT);
- const bool showDebug = GetBoolArg("-help-debug", false);
+ std::string strUsage = HelpMessage();
strUsage += HelpMessageGroup(tr("UI Options:").toStdString());
- if (showDebug) {
- strUsage += HelpMessageOpt("-allowselfsignedrootcertificates", strprintf("Allow self signed root certificates (default: %u)", DEFAULT_SELFSIGNED_ROOTCERTS));
- }
+ strUsage += HelpMessageOpt("-allowselfsignedrootcertificates", strprintf("Allow self signed root certificates (default: %u)", DEFAULT_SELFSIGNED_ROOTCERTS), HELP_MESSAGE_FILTER_DEBUG);
strUsage += HelpMessageOpt("-choosedatadir", strprintf(tr("Choose data directory on startup (default: %u)").toStdString(), DEFAULT_CHOOSE_DATADIR));
strUsage += HelpMessageOpt("-lang=<lang>", tr("Set language, for example \"de_DE\" (default: system locale)").toStdString());
strUsage += HelpMessageOpt("-min", tr("Start minimized").toStdString());
+ strUsage += HelpMessageOpt("-resetguisettings", tr("Reset all settings changed in the GUI").toStdString());
strUsage += HelpMessageOpt("-rootcertificates=<file>", tr("Set SSL root certificates for payment request (default: -system-)").toStdString());
strUsage += HelpMessageOpt("-splash", strprintf(tr("Show splash screen on startup (default: %u)").toStdString(), DEFAULT_SPLASHSCREEN));
- strUsage += HelpMessageOpt("-resetguisettings", tr("Reset all settings changed in the GUI").toStdString());
- if (showDebug) {
- strUsage += HelpMessageOpt("-uiplatform", strprintf("Select platform to customize UI for (one of windows, macosx, other; default: %s)", BitcoinGUI::DEFAULT_UIPLATFORM));
- }
+ strUsage += HelpMessageOpt("-uiplatform", strprintf("Select platform to customize UI for (one of windows, macosx, other; default: %s)", BitcoinGUI::DEFAULT_UIPLATFORM), HELP_MESSAGE_FILTER_DEBUG);
+#ifdef ENABLE_WALLET
+ strUsage += CWallet::GetWalletHelpString(); // "Wallet options" / "Wallet debugging/testing options"
+#endif
QString coreOptions = QString::fromStdString(strUsage);
text = version + "\n" + header + "\n" + coreOptions;
View
@@ -482,17 +482,17 @@ void ArgsManager::ForceSetArg(const std::string& strArg, const std::string& strV
mapMultiArgs[strArg].push_back(strValue);
}
-
-
static const int screenWidth = 79;
static const int optIndent = 2;
static const int msgIndent = 7;
-std::string HelpMessageGroup(const std::string &message) {
+std::string HelpMessageGroup(const std::string &message, const int filter) {
+ if (filter & HELP_MESSAGE_FILTER_DEBUG && !GetBoolArg("-help-debug", false)) return std::string("");
return std::string(message) + std::string("\n\n");
}
-std::string HelpMessageOpt(const std::string &option, const std::string &message) {
+std::string HelpMessageOpt(const std::string &option, const std::string &message, const int filter) {
+ if (filter & HELP_MESSAGE_FILTER_DEBUG && !GetBoolArg("-help-debug", false)) return std::string("");
return std::string(optIndent,' ') + std::string(option) +
std::string("\n") + std::string(msgIndent,' ') +
FormatParagraph(message, screenWidth - msgIndent, msgIndent) +
View
@@ -44,6 +44,9 @@ class CTranslationInterface
boost::signals2::signal<std::string (const char* psz)> Translate;
};
+const int HELP_MESSAGE_FILTER_NONE = 0;
+const int HELP_MESSAGE_FILTER_DEBUG = 1 << 0;
+
extern bool fPrintToConsole;
extern bool fPrintToDebugLog;
@@ -313,18 +316,20 @@ static inline bool SoftSetBoolArg(const std::string& strArg, bool fValue)
* Format a string to be used as group of options in help messages
*
* @param message Group name (e.g. "RPC server options:")
+ * @param filter bitfield filter for whether to display the message
* @return the formatted string
*/
-std::string HelpMessageGroup(const std::string& message);
+std::string HelpMessageGroup(const std::string& message, const int filter=HELP_MESSAGE_FILTER_NONE);
/**
* Format a string to be used as option description in help messages
*
* @param option Option message (e.g. "-rpcuser=<user>")
* @param message Option description (e.g. "Username for JSON-RPC connections")
+ * @param filter bitfield filter for whether to display the message
* @return the formatted string
*/
-std::string HelpMessageOpt(const std::string& option, const std::string& message);
+std::string HelpMessageOpt(const std::string& option, const std::string& message, const int filter=HELP_MESSAGE_FILTER_NONE);
/**
* Return the number of physical cores available on the current system.
View
@@ -3731,7 +3731,7 @@ std::vector<std::string> CWallet::GetDestValues(const std::string& prefix) const
return values;
}
-std::string CWallet::GetWalletHelpString(bool showDebug)
+std::string CWallet::GetWalletHelpString()
{
std::string strUsage = HelpMessageGroup(_("Wallet options:"));
strUsage += HelpMessageOpt("-disablewallet", _("Do not load the wallet and disable wallet RPC calls"));
@@ -3755,15 +3755,11 @@ std::string CWallet::GetWalletHelpString(bool showDebug)
strUsage += HelpMessageOpt("-zapwallettxes=<mode>", _("Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup") +
" " + _("(1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)"));
- if (showDebug)
- {
- strUsage += HelpMessageGroup(_("Wallet debugging/testing options:"));
-
- strUsage += HelpMessageOpt("-dblogsize=<n>", strprintf("Flush wallet database activity from memory to disk log every <n> megabytes (default: %u)", DEFAULT_WALLET_DBLOGSIZE));
- strUsage += HelpMessageOpt("-flushwallet", strprintf("Run a thread to flush wallet periodically (default: %u)", DEFAULT_FLUSHWALLET));
- strUsage += HelpMessageOpt("-privdb", strprintf("Sets the DB_PRIVATE flag in the wallet db environment (default: %u)", DEFAULT_WALLET_PRIVDB));
- strUsage += HelpMessageOpt("-walletrejectlongchains", strprintf(_("Wallet will not create transactions that violate mempool chain limits (default: %u)"), DEFAULT_WALLET_REJECT_LONG_CHAINS));
- }
+ strUsage += HelpMessageGroup(_("Wallet debugging/testing options:"), HELP_MESSAGE_FILTER_DEBUG);
+ strUsage += HelpMessageOpt("-dblogsize=<n>", strprintf("Flush wallet database activity from memory to disk log every <n> megabytes (default: %u)", DEFAULT_WALLET_DBLOGSIZE), HELP_MESSAGE_FILTER_DEBUG);
+ strUsage += HelpMessageOpt("-flushwallet", strprintf("Run a thread to flush wallet periodically (default: %u)", DEFAULT_FLUSHWALLET), HELP_MESSAGE_FILTER_DEBUG);
+ strUsage += HelpMessageOpt("-privdb", strprintf("Sets the DB_PRIVATE flag in the wallet db environment (default: %u)", DEFAULT_WALLET_PRIVDB), HELP_MESSAGE_FILTER_DEBUG);
+ strUsage += HelpMessageOpt("-walletrejectlongchains", strprintf(_("Wallet will not create transactions that violate mempool chain limits (default: %u)"), DEFAULT_WALLET_REJECT_LONG_CHAINS), HELP_MESSAGE_FILTER_DEBUG);
return strUsage;
}
View
@@ -1093,7 +1093,7 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
bool MarkReplaced(const uint256& originalHash, const uint256& newHash);
/* Returns the wallets help message */
- static std::string GetWalletHelpString(bool showDebug);
+ static std::string GetWalletHelpString();
/* Initializes the wallet, returns a new CWallet instance or a null pointer in case of an error */
static CWallet* CreateWalletFromFile(const std::string walletFile);