diff options
author | MarcoFalke <falke.marco@gmail.com> | 2018-05-30 13:42:58 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2018-05-30 13:43:07 -0400 |
commit | 61fcef0f89c4eb313b94a93880d7638b90aa0764 (patch) | |
tree | 2421d7c17febf8c273ee8bf0c07e3f5590775b45 /src/bench | |
parent | c4cc8d9930ecb926d913075dd2aa2df65056a8ed (diff) | |
parent | 903055730b57ae7c8d12aca2e3fd0951f12f7e9c (diff) | |
download | bitcoin-61fcef0f89c4eb313b94a93880d7638b90aa0764.tar.xz |
Merge #13112: Throw an error for unknown args
903055730b Test gArgs erroring on unknown args (Andrew Chow)
4f8704d57f Give an error and exit if there are unknown parameters (Andrew Chow)
174f7c8080 Use a struct for arguments and nested map for categories (Andrew Chow)
Pull request description:
Following #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 #1044
Tree-SHA512: 388201319a7d6493204bb5433da47e8e6c8266882e809f6df45f86d925f1f320f2fd13edb3e57ffc6a37415dfdfc689f83929452bca224229783accb367032e7
Diffstat (limited to 'src/bench')
-rw-r--r-- | src/bench/bench_bitcoin.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp index 1a2671e8d1..a820d67fa8 100644 --- a/src/bench/bench_bitcoin.cpp +++ b/src/bench/bench_bitcoin.cpp @@ -33,13 +33,21 @@ static void SetupBenchArgs() gArgs.AddArg("-plot-plotlyurl=<uri>", strprintf("URL to use for plotly.js (default: %s)", DEFAULT_PLOT_PLOTLYURL), false, OptionsCategory::OPTIONS); gArgs.AddArg("-plot-width=<x>", strprintf("Plot width in pixel (default: %u)", DEFAULT_PLOT_WIDTH), false, OptionsCategory::OPTIONS); gArgs.AddArg("-plot-height=<x>", strprintf("Plot height in pixel (default: %u)", DEFAULT_PLOT_HEIGHT), false, OptionsCategory::OPTIONS); + + // Hidden + gArgs.AddArg("-h", "", false, OptionsCategory::HIDDEN); + gArgs.AddArg("-help", "", false, OptionsCategory::HIDDEN); } int main(int argc, char** argv) { SetupBenchArgs(); - gArgs.ParseParameters(argc, argv); + std::string error; + if (!gArgs.ParseParameters(argc, argv, error)) { + fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str()); + return false; + } if (HelpRequested(gArgs)) { std::cout << gArgs.GetHelpMessage(); |