diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp --- a/src/bench/bench_bitcoin.cpp +++ b/src/bench/bench_bitcoin.cpp @@ -19,8 +19,8 @@ static const int64_t DEFAULT_PLOT_HEIGHT = 768; static void SetupBenchArgs() { - gArgs.AddArg("-?", "Print this help message and exit", - ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + SetupHelpOptions(gArgs); + gArgs.AddArg("-list", "List benchmarks without executing them. Can be combined " "with -scaling and -filter", @@ -59,10 +59,6 @@ "-plot-height=", strprintf("Plot height in pixel (default: %u)", DEFAULT_PLOT_HEIGHT), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); - - // Hidden - gArgs.AddArg("-h", "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); - gArgs.AddArg("-help", "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); } int main(int argc, char **argv) { diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -35,6 +35,8 @@ static const int CONTINUE_EXECUTION = -1; static void SetupCliArgs() { + SetupHelpOptions(gArgs); + const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN); const auto testnetBaseParams = @@ -42,8 +44,6 @@ const auto regtestBaseParams = CreateBaseChainParams(CBaseChainParams::REGTEST); - gArgs.AddArg("-?", "This help message", ArgsManager::ALLOW_ANY, - OptionsCategory::OPTIONS); gArgs.AddArg("-version", "Print version and exit", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); gArgs.AddArg("-conf=", @@ -111,10 +111,6 @@ "Send RPC for non-default wallet on RPC server (needs to exactly match " "corresponding -wallet option passed to bitcoind)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); - - // Hidden - gArgs.AddArg("-h", "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); - gArgs.AddArg("-help", "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); } /** libevent event log callback */ diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -36,8 +36,8 @@ const std::function G_TRANSLATION_FUN = nullptr; static void SetupBitcoinTxArgs() { - gArgs.AddArg("-?", "This help message", ArgsManager::ALLOW_ANY, - OptionsCategory::OPTIONS); + SetupHelpOptions(gArgs); + gArgs.AddArg("-create", "Create new, empty TX.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); gArgs.AddArg("-json", "Select JSON output", ArgsManager::ALLOW_ANY, @@ -93,10 +93,6 @@ gArgs.AddArg("set=NAME:JSON-STRING", "Set register NAME to given JSON-STRING", ArgsManager::ALLOW_ANY, OptionsCategory::REGISTER_COMMANDS); - - // Hidden - gArgs.AddArg("-h", "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); - gArgs.AddArg("-help", "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); } // diff --git a/src/bitcoin-wallet.cpp b/src/bitcoin-wallet.cpp --- a/src/bitcoin-wallet.cpp +++ b/src/bitcoin-wallet.cpp @@ -18,10 +18,9 @@ const std::function G_TRANSLATION_FUN = nullptr; static void SetupWalletToolArgs() { + SetupHelpOptions(gArgs); SetupChainParamsBaseOptions(); - gArgs.AddArg("-?", "This help message", ArgsManager::ALLOW_ANY, - OptionsCategory::OPTIONS); gArgs.AddArg("-datadir=", "Specify data directory", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); gArgs.AddArg("-wallet=", "Specify wallet name", @@ -39,10 +38,6 @@ OptionsCategory::COMMANDS); gArgs.AddArg("create", "Create new wallet file", ArgsManager::ALLOW_ANY, OptionsCategory::COMMANDS); - - // Hidden - gArgs.AddArg("-h", "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); - gArgs.AddArg("-help", "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); } static bool WalletAppInit(int argc, char *argv[]) { diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -347,6 +347,12 @@ } void SetupServerArgs() { + SetupHelpOptions(gArgs); + // server-only for now + gArgs.AddArg("-help-debug", + "Print help message with debugging options and exit", false, + OptionsCategory::DEBUG_TEST); + const auto defaultBaseParams = CreateBaseChainParams(CBaseChainParams::MAIN); const auto testnetBaseParams = @@ -361,7 +367,7 @@ // Hidden Options std::vector hidden_args = { - "-h", "-help", "-dbcrashratio", "-forcecompactdb", "-parkdeepreorg", + "-dbcrashratio", "-forcecompactdb", "-parkdeepreorg", "-automaticunparking", "-replayprotectionactivationtime", "-enableminerfund", // GUI args. These will be overwritten by SetupUIArgs for the GUI @@ -376,8 +382,6 @@ // alphabetical ordering. Do not translate _(...) -help-debug options, Many // technical terms, and only a very small audience, so is unnecessary stress // to translators. - gArgs.AddArg("-?", "Print this help message and exit", - ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); gArgs.AddArg("-version", "Print version and exit", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); #if defined(HAVE_SYSTEM) @@ -891,9 +895,6 @@ "in conjunction with -debug=1 to output debug logs for all " "categories except one or more specified categories."), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); - gArgs.AddArg("-help-debug", - "Print help message with debugging options and exit", - ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); gArgs.AddArg("-logips", strprintf("Include IP addresses in debug output (default: %d)", DEFAULT_LOGIPS), diff --git a/src/seeder/main.cpp b/src/seeder/main.cpp --- a/src/seeder/main.cpp +++ b/src/seeder/main.cpp @@ -122,8 +122,13 @@ private: void SetupSeederArgs() { - gArgs.AddArg("-?", "Print this help message and exit", - ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + SetupHelpOptions(gArgs); + gArgs.AddArg("-help-debug", + "Show all debugging options (usage: --help -help-debug)", + ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); + + SetupChainParamsBaseOptions(); + gArgs.AddArg("-version", "Print version and exit", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); gArgs.AddArg("-host=", "Hostname of the DNS seed", @@ -153,14 +158,6 @@ ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); gArgs.AddArg("-wipeignore", "Wipe list of ignored nodes", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); - gArgs.AddArg("-help-debug", - "Show all debugging options (usage: --help -help-debug)", - ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); - SetupChainParamsBaseOptions(); - - gArgs.AddArg("-help", "", ArgsManager::ALLOW_ANY, - OptionsCategory::HIDDEN); - gArgs.AddArg("-h", "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); } }; diff --git a/src/util/system.h b/src/util/system.h --- a/src/util/system.h +++ b/src/util/system.h @@ -365,6 +365,9 @@ */ bool HelpRequested(const ArgsManager &args); +/** Add help options to the args manager */ +void SetupHelpOptions(ArgsManager &args); + /** * Format a string to be used as group of options in help messages. * diff --git a/src/util/system.cpp b/src/util/system.cpp --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -560,6 +560,12 @@ args.IsArgSet("-help") || args.IsArgSet("-help-debug"); } +void SetupHelpOptions(ArgsManager &args) { + args.AddArg("-?", "Print this help message and exit", false, + OptionsCategory::OPTIONS); + args.AddHiddenArgs({"-h", "-help"}); +} + static const int screenWidth = 79; static const int optIndent = 2; static const int msgIndent = 7; diff --git a/test/lint/check-doc.py b/test/lint/check-doc.py --- a/test/lint/check-doc.py +++ b/test/lint/check-doc.py @@ -37,19 +37,21 @@ '-zmqpubhashtxhwm', '-zmqpubrawblockhwm', '-zmqpubrawtxhwm', - ]) # list false positive undocumented arguments -SET_FALSE_POSITIVE_UNDOCUMENTED = set(['-dbcrashratio', - '-enableminerfund', - '-forcecompactdb', - '-parkdeepreorg', - '-automaticunparking', - # Remove after November 2020 upgrade - '-axionactivationtime', - '-replayprotectionactivationtime', - ]) +SET_FALSE_POSITIVE_UNDOCUMENTED = set([ + '-help', + '-h', + '-dbcrashratio', + '-enableminerfund', + '-forcecompactdb', + '-parkdeepreorg', + '-automaticunparking', + # Remove after November 2020 upgrade + '-axionactivationtime', + '-replayprotectionactivationtime', +]) def main():