Instead of each binary generating and printing it’s own help string, have gArgs know what the args are and generate the help string.
This is the first commit of #13112 pulled out.
453+
454+ gArgs.AddArg("-addnode=<ip>", _("Add a node to connect to and attempt to keep the connection open (see the `addnode` RPC command help for more info)"), false, OptionsCategory::CONNECTION);
455+ gArgs.AddArg("-banscore=<n>", strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), DEFAULT_BANSCORE_THRESHOLD), false, OptionsCategory::CONNECTION);
456+ gArgs.AddArg("-bantime=<n>", strprintf(_("Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), DEFAULT_MISBEHAVING_BANTIME), false, OptionsCategory::CONNECTION);
457+ gArgs.AddArg("-bind=<addr>", _("Bind to given address and always listen on it. Use [host]:port notation for IPv6"), false, OptionsCategory::CONNECTION);
458+ gArgs.AddArg("-connect=<ip>", _("Connect only to the specified node(s, false, OptionsCategory::OPTIONS)); -connect=0 disables automatic connections (the rules for this peer are the same as for -addnode)"), false, OptionsCategory::CONNECTION);
Tested ACK 3333c7ef48cfde42619b7f6ae62893de192ed574:
git diff
only shows differences to to sort-by-name.utACK 3ea4d90.
Please squash otherwise check-doc.py
fails for 1st commit.
utACK dadad0d559f62ff7d9752655dc4bbb922e97423d
I did not review all the command line help/AddArg statements, but I did compare the output of -help
and -help -help-debug
before and after.
gArgs knows what the available arguments are and their help. Getting
the help message is moved to gArgs and HelpMessage() is removed
254+ void AddArg(const std::string& name, const std::string& help, const bool debug_only, const OptionsCategory& cat);
255+
256+ /**
257+ * Get the help string
258+ */
259+ std::string GetHelpMessage();
562+
563+ OptionsCategory last_cat = OptionsCategory::OPTIONS;
564+ for (auto& arg : m_available_args) {
565+ if (arg.first.first != last_cat) {
566+ last_cat = arg.first.first;
567+ if (last_cat == OptionsCategory::CONNECTION)
reutACK 4d4185a4f0e40c033a587871839a47cb3f89ee93
Two nits below, but feel free to ignore. This is probably a pain to keep rebasing.