Skip to content

Conversation

Brotcrunsher
Copy link
Contributor

Previously it was possible to specify multiple, however only one was picked in this arbitrary and (probably) undocumented priority: getinfo > netinfo > generate > addrinfo.

…sible to specify multiple, however only one was picked in this arbitrary and (probably) undocumented priority: getinfo > netinfo > generate > addrinfo.
@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 4, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK pablomartin4btc

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Comment on lines +1173 to +1178
int nRh = 0;
if (gArgs.IsArgSet("-getinfo")) nRh++;
if (gArgs.GetBoolArg("-netinfo", false)) nRh++;
if (gArgs.GetBoolArg("-generate", false)) nRh++;
if (gArgs.GetBoolArg("-addrinfo", false)) nRh++;
if (nRh > 1) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
int nRh = 0;
if (gArgs.IsArgSet("-getinfo")) nRh++;
if (gArgs.GetBoolArg("-netinfo", false)) nRh++;
if (gArgs.GetBoolArg("-generate", false)) nRh++;
if (gArgs.GetBoolArg("-addrinfo", false)) nRh++;
if (nRh > 1) {
if (gArgs.IsArgSet("-getinfo") + gArgs.GetBoolArg("-netinfo", false) + gArgs.GetBoolArg("-generate", false) + gArgs.GetBoolArg("-addrinfo", false) > 1) {

This is admittedly a bit obscure, so maybe there's a better way (but it's still an improvement over the temporary variable IMO)

@luke-jr
Copy link
Member

luke-jr commented Jul 3, 2023

nit: Commit summary is too long. Would also be nice to rebase on top of 42af959

luke-jr pushed a commit to luke-jr/bitcoin that referenced this pull request Aug 16, 2023
…sible to specify multiple, however only one was picked in this arbitrary and (probably) undocumented priority: getinfo > netinfo > generate > addrinfo.

Github-Pull: bitcoin#27815
Rebased-From: 244e6c8
@achow101 achow101 requested a review from sipa September 20, 2023 16:55
@pablomartin4btc
Copy link
Member

Concept ACK.

I agree this validation should be put in place, please check #26990 if you haven't already, in the second commit 11e0a80 there's a function that already does this (IsExclusivelyCliCommand()), feel free to take anything you find useful.

As pointed out by @luke-jr please check the project guidelines regarding commits specifications.

Also, for future reference, check the guidelines regarding C++ coding style and naming conventions (e.g. nRh in your code change).

Thanks for working on this!

@maflcko
Copy link
Member

maflcko commented Oct 25, 2023

Are you still working on this?

@maflcko maflcko closed this Nov 16, 2023
@maflcko maflcko removed the CI failed label Nov 16, 2023
achow101 added a commit that referenced this pull request Sep 4, 2024
…oin-cli

c8e6771 test: restrict multiple CLI arguments (naiyoma)
8838c4f common/args.h: automate check for multiple cli commands (naiyoma)

Pull request description:

  This PR is a continuation of the validation suggested [here](#27815) to ensure that only one Request Handler can be specified at a time.

ACKs for top commit:
  stratospher:
    reACK c8e6771.
  achow101:
    ACK c8e6771
  tdb3:
    cr re ACK c8e6771

Tree-SHA512: f4fe036fee342a54f1a7ac702ac35c40bf3d420fde6ab16313a75327292d5ee5c8ece1be9f852a13fcf73da1148b143b37b4894e294052abdde6eefb2e8c6f3f
@bitcoin bitcoin locked and limited conversation to collaborators May 21, 2025
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.

6 participants