Give an error and exit if there are unknown parameters

If an unknown option is given via either the command line args or
the conf file, throw an error and exit

Update tests for ArgsManager knowing args

Ignore unknown options in the config file for bitcoin-cli

Fix tests and bitcoin-cli to match actual options used
This commit is contained in:
Andrew Chow
2018-04-28 19:40:51 -04:00
parent 174f7c8080
commit 4f8704d57f
12 changed files with 205 additions and 66 deletions

View File

@@ -64,6 +64,10 @@ static void SetupBitcoinTxArgs()
gArgs.AddArg("load=NAME:FILENAME", "Load JSON file FILENAME into register NAME", false, OptionsCategory::REGISTER_COMMANDS);
gArgs.AddArg("set=NAME:JSON-STRING", "Set register NAME to given JSON-STRING", false, OptionsCategory::REGISTER_COMMANDS);
// Hidden
gArgs.AddArg("-h", "", false, OptionsCategory::HIDDEN);
gArgs.AddArg("-help", "", false, OptionsCategory::HIDDEN);
}
//
@@ -76,7 +80,11 @@ static int AppInitRawTx(int argc, char* argv[])
// Parameters
//
SetupBitcoinTxArgs();
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 EXIT_FAILURE;
}
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
try {