Skip to content
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

Merged
merged 1 commit into from May 9, 2018
Merged

Conversation

achow101
Copy link
Member

@achow101 achow101 commented May 8, 2018

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.

@jnewbery
Copy link
Contributor

jnewbery commented May 8, 2018

Concept ACK

@maflcko
Copy link
Member

maflcko commented May 8, 2018

I guess you'd have to cherry-pick the fixup to contrib/check-doc as well.

Copy link
Member

@maflcko maflcko left a 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);
Copy link
Member

@maflcko maflcko May 8, 2018

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)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, fixed

@achow101
Copy link
Member Author

achow101 commented May 8, 2018

I added a commit for the check-doc fix.

@maflcko
Copy link
Member

maflcko commented May 8, 2018

re-ACK 3ea4d9080d615e09017c23e9678f47c9edddb869 (only changes were suggested fixups)

@promag
Copy link
Member

promag commented May 8, 2018

utACK 3ea4d90.

Please squash otherwise check-doc.py fails for 1st commit.

@achow101
Copy link
Member Author

achow101 commented May 8, 2018

Squashed

@sipa
Copy link
Member

sipa commented May 9, 2018

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.

@meshcollider
Copy link
Contributor

Concept ACK, makes sense to split this out

@maflcko
Copy link
Member

maflcko commented May 9, 2018

Needs rebase

gArgs knows what the available arguments are and their help. Getting
the help message is moved to gArgs and HelpMessage() is removed
@achow101
Copy link
Member Author

achow101 commented May 9, 2018

Rebased

Copy link
Member

@sipa sipa left a 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();
Copy link
Member

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)
Copy link
Member

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.

@laanwj
Copy link
Member

laanwj commented May 9, 2018

Code review and lightly tested ACK 4d4185a

@maflcko
Copy link
Member

maflcko commented May 9, 2018

re-ACK 4d4185a (only change was rebase)

@maflcko maflcko merged commit 4d4185a into bitcoin:master May 9, 2018
maflcko pushed a commit that referenced this pull request May 9, 2018
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
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request May 30, 2018
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
AtsukiTak added a commit to AtsukiTak/bitcoin that referenced this pull request Jul 21, 2018
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.
Bushstar pushed a commit to Bushstar/Feathercoin that referenced this pull request Jul 24, 2018
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.
@ryanofsky ryanofsky mentioned this pull request Sep 5, 2018
HashUnlimited pushed a commit to HashUnlimited/chaincoin that referenced this pull request Sep 12, 2018
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.
jfhk pushed a commit to jfhk/bitcoin that referenced this pull request Nov 14, 2018
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.
meshcollider added a commit that referenced this pull request Sep 8, 2019
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
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 11, 2019
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
jonspock pushed a commit to jonspock/devault that referenced this pull request Dec 27, 2019
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
jonspock pushed a commit to devaultcrypto/devault that referenced this pull request Dec 29, 2019
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
UdjinM6 added a commit to UdjinM6/dash that referenced this pull request Mar 19, 2021
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jun 19, 2021
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
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jun 24, 2021
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
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jun 26, 2021
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
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jun 26, 2021
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
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jun 28, 2021
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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants