New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Have gArgs handle printing help #13190
Conversation
Concept ACK |
I guess you'd have to cherry-pick the fixup to contrib/check-doc as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested ACK 3333c7ef48cfde42619b7f6ae62893de192ed574:
- Bumped the man pages in a commit on current master, cherry-picked 3333c7ef48cfde42619b7f6ae62893de192ed574, Generated the man pages and checked that
git diff
only shows differences to to sort-by-name. - Additionally checked that the strings are move-only by hand
- Did an utACK on the code changes.
src/init.cpp
Outdated
gArgs.AddArg("-banscore=<n>", strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), DEFAULT_BANSCORE_THRESHOLD), false, OptionsCategory::CONNECTION); | ||
gArgs.AddArg("-bantime=<n>", strprintf(_("Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), DEFAULT_MISBEHAVING_BANTIME), false, OptionsCategory::CONNECTION); | ||
gArgs.AddArg("-bind=<addr>", _("Bind to given address and always listen on it. Use [host]:port notation for IPv6"), false, OptionsCategory::CONNECTION); | ||
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase issue? (Translation string was changed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, fixed
I added a commit for the check-doc fix. |
re-ACK 3ea4d9080d615e09017c23e9678f47c9edddb869 (only changes were suggested fixups) |
utACK 3ea4d90. Please squash otherwise |
Squashed |
utACK dadad0d559f62ff7d9752655dc4bbb922e97423d I did not review all the command line help/AddArg statements, but I did compare the output of |
Concept ACK, makes sense to split this out |
Needs rebase |
gArgs knows what the available arguments are and their help. Getting the help message is moved to gArgs and HelpMessage() is removed
Rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reutACK 4d4185a
Two nits below, but feel free to ignore. This is probably a pain to keep rebasing.
/** | ||
* Get the help string | ||
*/ | ||
std::string GetHelpMessage(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this can be marked const.
for (auto& arg : m_available_args) { | ||
if (arg.first.first != last_cat) { | ||
last_cat = arg.first.first; | ||
if (last_cat == OptionsCategory::CONNECTION) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style nit: use braces when putting then/else branches on separate lines.
Code review and lightly tested ACK 4d4185a |
re-ACK 4d4185a (only change was rebase) |
4d4185a Make gArgs aware of the arguments (Andrew Chow) Pull request description: 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. Tree-SHA512: d794c872b834bc56c78d947549f9cf046a8174984ab0c7b4ba06bc51d36dca11a4ed88afafe76bb4f776cdba042e17e30b9c2ed7b195bef7df77a1327823f989
9030557 Test gArgs erroring on unknown args (Andrew Chow) 4f8704d Give an error and exit if there are unknown parameters (Andrew Chow) 174f7c8 Use a struct for arguments and nested map for categories (Andrew Chow) Pull request description: Following bitcoin#13190, gArgs is aware of all of the command line arguments. This PR has gArgs check whether the arguments provided are actually valid arguments. When an unknown argument is encountered, an error is printed to stderr and the program exist. Since gArgs is used for everything that has command line arguments, `bitcoind`, `bitcoin-cli`, `bitcoin-qt`, `bitcoin-tx`, and `bench_bitcoin` are all effected by this change and all now have the same argument checking behavior. Closes bitcoin#1044 Tree-SHA512: 388201319a7d6493204bb5433da47e8e6c8266882e809f6df45f86d925f1f320f2fd13edb3e57ffc6a37415dfdfc689f83929452bca224229783accb367032e7
This commit contains 2 refactors. 1. mark "const" on ArgsManager::GetHelpMessage and IsArgKnown. 2. remove unused "error" argument from ArgsManager::IsArgKnown. Firstly, I mark "const" on where it is possible to. It is mentioned before (e.g. bitcoin#13190 (review)). And about 2nd change, ArgsManager::IsArgKnown was added at commit #4f8704d which was merged at PR bitcoin#13112. But from its beggining, "error" argument never be used. I think it should be refactored.
This commit contains 2 refactors. 1. mark "const" on ArgsManager::GetHelpMessage and IsArgKnown. 2. remove unused "error" argument from ArgsManager::IsArgKnown. Firstly, I mark "const" on where it is possible to. It is mentioned before (e.g. bitcoin/bitcoin#13190 (review)). And about 2nd change, ArgsManager::IsArgKnown was added at commit #4f8704d which was merged at PR #13112. But from its beggining, "error" argument never be used. I think it should be refactored.
This commit contains 2 refactors. 1. mark "const" on ArgsManager::GetHelpMessage and IsArgKnown. 2. remove unused "error" argument from ArgsManager::IsArgKnown. Firstly, I mark "const" on where it is possible to. It is mentioned before (e.g. bitcoin#13190 (review)). And about 2nd change, ArgsManager::IsArgKnown was added at commit #4f8704d which was merged at PR bitcoin#13112. But from its beggining, "error" argument never be used. I think it should be refactored.
This commit contains 2 refactors. 1. mark "const" on ArgsManager::GetHelpMessage and IsArgKnown. 2. remove unused "error" argument from ArgsManager::IsArgKnown. Firstly, I mark "const" on where it is possible to. It is mentioned before (e.g. bitcoin#13190 (review)). And about 2nd change, ArgsManager::IsArgKnown was added at commit #4f8704d which was merged at PR bitcoin#13112. But from its beggining, "error" argument never be used. I think it should be refactored.
4be3b76 refactor: Cleanup walletinitinterface.h (Hennadii Stepanov) Pull request description: Forward declarations of `CScheduler` and `CRPCTable` classes are no longer needed after ea961c3 (#14437) commit. Including `<string>` is no longer needed after 4d4185a (#13190) commit. ACKs for top commit: theStack: ACK 4be3b76 promag: ACK 4be3b76. kristapsk: ACK 4be3b76 (tested that it builds) Tree-SHA512: 5ed72e3deda3d7c7fb698a1a11db76199727e6c570dfc78422690dbda9a92af32e1913920062dd3c9f618095e7498c219ff9c145a4c151486865ebeaa20a1d3c
Summary: This commit contains 2 refactors. 1. mark "const" on ArgsManager::GetHelpMessage and IsArgKnown. 2. remove unused "error" argument from ArgsManager::IsArgKnown. Firstly, I mark "const" on where it is possible to. It is mentioned before (e.g. bitcoin/bitcoin#13190 (review)). And about 2nd change, ArgsManager::IsArgKnown was added at commit #4f8704d which was merged at PR #13112. But from its beggining, "error" argument never be used. I think it should be refactored. This is a backport of Core PR13733 Test Plan: make check Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D4168
Summary: This commit contains 2 refactors. 1. mark "const" on ArgsManager::GetHelpMessage and IsArgKnown. 2. remove unused "error" argument from ArgsManager::IsArgKnown. Firstly, I mark "const" on where it is possible to. It is mentioned before (e.g. bitcoin/bitcoin#13190 (review)). And about 2nd change, ArgsManager::IsArgKnown was added at commit #4f8704d which was merged at PR #13112. But from its beggining, "error" argument never be used. I think it should be refactored. This is a backport of Core PR13733 Test Plan: make check Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D4168
Summary: This commit contains 2 refactors. 1. mark "const" on ArgsManager::GetHelpMessage and IsArgKnown. 2. remove unused "error" argument from ArgsManager::IsArgKnown. Firstly, I mark "const" on where it is possible to. It is mentioned before (e.g. bitcoin/bitcoin#13190 (review)). And about 2nd change, ArgsManager::IsArgKnown was added at commit #4f8704d which was merged at PR #13112. But from its beggining, "error" argument never be used. I think it should be refactored. This is a backport of Core PR13733 Test Plan: make check Reviewers: #bitcoin_abc, jasonbcox Reviewed By: #bitcoin_abc, jasonbcox Differential Revision: https://reviews.bitcoinabc.org/D4168
9030557 Test gArgs erroring on unknown args (Andrew Chow) 4f8704d Give an error and exit if there are unknown parameters (Andrew Chow) 174f7c8 Use a struct for arguments and nested map for categories (Andrew Chow) Pull request description: Following bitcoin#13190, gArgs is aware of all of the command line arguments. This PR has gArgs check whether the arguments provided are actually valid arguments. When an unknown argument is encountered, an error is printed to stderr and the program exist. Since gArgs is used for everything that has command line arguments, `bitcoind`, `bitcoin-cli`, `bitcoin-qt`, `bitcoin-tx`, and `bench_bitcoin` are all effected by this change and all now have the same argument checking behavior. Closes dashpay#1044 Tree-SHA512: 388201319a7d6493204bb5433da47e8e6c8266882e809f6df45f86d925f1f320f2fd13edb3e57ffc6a37415dfdfc689f83929452bca224229783accb367032e7
9030557 Test gArgs erroring on unknown args (Andrew Chow) 4f8704d Give an error and exit if there are unknown parameters (Andrew Chow) 174f7c8 Use a struct for arguments and nested map for categories (Andrew Chow) Pull request description: Following bitcoin#13190, gArgs is aware of all of the command line arguments. This PR has gArgs check whether the arguments provided are actually valid arguments. When an unknown argument is encountered, an error is printed to stderr and the program exist. Since gArgs is used for everything that has command line arguments, `bitcoind`, `bitcoin-cli`, `bitcoin-qt`, `bitcoin-tx`, and `bench_bitcoin` are all effected by this change and all now have the same argument checking behavior. Closes dashpay#1044 Tree-SHA512: 388201319a7d6493204bb5433da47e8e6c8266882e809f6df45f86d925f1f320f2fd13edb3e57ffc6a37415dfdfc689f83929452bca224229783accb367032e7
9030557 Test gArgs erroring on unknown args (Andrew Chow) 4f8704d Give an error and exit if there are unknown parameters (Andrew Chow) 174f7c8 Use a struct for arguments and nested map for categories (Andrew Chow) Pull request description: Following bitcoin#13190, gArgs is aware of all of the command line arguments. This PR has gArgs check whether the arguments provided are actually valid arguments. When an unknown argument is encountered, an error is printed to stderr and the program exist. Since gArgs is used for everything that has command line arguments, `bitcoind`, `bitcoin-cli`, `bitcoin-qt`, `bitcoin-tx`, and `bench_bitcoin` are all effected by this change and all now have the same argument checking behavior. Closes dashpay#1044 Tree-SHA512: 388201319a7d6493204bb5433da47e8e6c8266882e809f6df45f86d925f1f320f2fd13edb3e57ffc6a37415dfdfc689f83929452bca224229783accb367032e7
9030557 Test gArgs erroring on unknown args (Andrew Chow) 4f8704d Give an error and exit if there are unknown parameters (Andrew Chow) 174f7c8 Use a struct for arguments and nested map for categories (Andrew Chow) Pull request description: Following bitcoin#13190, gArgs is aware of all of the command line arguments. This PR has gArgs check whether the arguments provided are actually valid arguments. When an unknown argument is encountered, an error is printed to stderr and the program exist. Since gArgs is used for everything that has command line arguments, `bitcoind`, `bitcoin-cli`, `bitcoin-qt`, `bitcoin-tx`, and `bench_bitcoin` are all effected by this change and all now have the same argument checking behavior. Closes dashpay#1044 Tree-SHA512: 388201319a7d6493204bb5433da47e8e6c8266882e809f6df45f86d925f1f320f2fd13edb3e57ffc6a37415dfdfc689f83929452bca224229783accb367032e7
9030557 Test gArgs erroring on unknown args (Andrew Chow) 4f8704d Give an error and exit if there are unknown parameters (Andrew Chow) 174f7c8 Use a struct for arguments and nested map for categories (Andrew Chow) Pull request description: Following bitcoin#13190, gArgs is aware of all of the command line arguments. This PR has gArgs check whether the arguments provided are actually valid arguments. When an unknown argument is encountered, an error is printed to stderr and the program exist. Since gArgs is used for everything that has command line arguments, `bitcoind`, `bitcoin-cli`, `bitcoin-qt`, `bitcoin-tx`, and `bench_bitcoin` are all effected by this change and all now have the same argument checking behavior. Closes dashpay#1044 Tree-SHA512: 388201319a7d6493204bb5433da47e8e6c8266882e809f6df45f86d925f1f320f2fd13edb3e57ffc6a37415dfdfc689f83929452bca224229783accb367032e7
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.