aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoin-util.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-06-17 15:17:28 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-06-18 20:09:41 +0200
commitfa08bc288f81dd42a482e2bfef37d21a1e5fddd2 (patch)
tree3a5742c219f3cc9e1eb8083bf034d00dbb31feac /src/bitcoin-util.cpp
parentfa751a47ff4253f58518d7f43d33ec1227ea0dbc (diff)
downloadbitcoin-fa08bc288f81dd42a482e2bfef37d21a1e5fddd2.tar.xz
Remove gArgs from AppInitUtil
Also fix incorrect {}
Diffstat (limited to 'src/bitcoin-util.cpp')
-rw-r--r--src/bitcoin-util.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/bitcoin-util.cpp b/src/bitcoin-util.cpp
index 55c3580e15..d26ffd2855 100644
--- a/src/bitcoin-util.cpp
+++ b/src/bitcoin-util.cpp
@@ -41,22 +41,22 @@ static void SetupBitcoinUtilArgs(ArgsManager &argsman)
// This function returns either one of EXIT_ codes when it's expected to stop the process or
// CONTINUE_EXECUTION when it's expected to continue further.
-static int AppInitUtil(int argc, char* argv[])
+static int AppInitUtil(ArgsManager& args, int argc, char* argv[])
{
- SetupBitcoinUtilArgs(gArgs);
+ SetupBitcoinUtilArgs(args);
std::string error;
- if (!gArgs.ParseParameters(argc, argv, error)) {
+ if (!args.ParseParameters(argc, argv, error)) {
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error);
return EXIT_FAILURE;
}
- if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
+ if (HelpRequested(args) || args.IsArgSet("-version")) {
// First part of help message is specific to this utility
std::string strUsage = PACKAGE_NAME " bitcoin-util utility version " + FormatFullVersion() + "\n";
- if (!gArgs.IsArgSet("-version")) {
+ if (!args.IsArgSet("-version")) {
strUsage += "\n"
"Usage: bitcoin-util [options] [commands] Do stuff\n";
- strUsage += "\n" + gArgs.GetHelpMessage();
+ strUsage += "\n" + args.GetHelpMessage();
}
tfm::format(std::cout, "%s", strUsage);
@@ -70,7 +70,7 @@ static int AppInitUtil(int argc, char* argv[])
// Check for chain settings (Params() calls are only valid after this clause)
try {
- SelectParams(gArgs.GetChainName());
+ SelectParams(args.GetChainName());
} catch (const std::exception& e) {
tfm::format(std::cerr, "Error: %s\n", e.what());
return EXIT_FAILURE;
@@ -151,12 +151,14 @@ __declspec(dllexport) int main(int argc, char* argv[])
int main(int argc, char* argv[])
#endif
{
+ ArgsManager& args = gArgs;
SetupEnvironment();
try {
- int ret = AppInitUtil(argc, argv);
- if (ret != CONTINUE_EXECUTION)
+ int ret = AppInitUtil(args, argc, argv);
+ if (ret != CONTINUE_EXECUTION) {
return ret;
+ }
} catch (const std::exception& e) {
PrintExceptionContinue(&e, "AppInitUtil()");
return EXIT_FAILURE;
@@ -165,7 +167,7 @@ int main(int argc, char* argv[])
return EXIT_FAILURE;
}
- const auto cmd = gArgs.GetCommand();
+ const auto cmd = args.GetCommand();
if (!cmd) {
tfm::format(std::cerr, "Error: must specify a command\n");
return EXIT_FAILURE;