Skip to content

Commit fa08bc2

Browse files
author
MarcoFalke
committed
Remove gArgs from AppInitUtil
Also fix incorrect {}
1 parent fa751a4 commit fa08bc2

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/bitcoin-util.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,22 @@ static void SetupBitcoinUtilArgs(ArgsManager &argsman)
4141

4242
// This function returns either one of EXIT_ codes when it's expected to stop the process or
4343
// CONTINUE_EXECUTION when it's expected to continue further.
44-
static int AppInitUtil(int argc, char* argv[])
44+
static int AppInitUtil(ArgsManager& args, int argc, char* argv[])
4545
{
46-
SetupBitcoinUtilArgs(gArgs);
46+
SetupBitcoinUtilArgs(args);
4747
std::string error;
48-
if (!gArgs.ParseParameters(argc, argv, error)) {
48+
if (!args.ParseParameters(argc, argv, error)) {
4949
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error);
5050
return EXIT_FAILURE;
5151
}
5252

53-
if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
53+
if (HelpRequested(args) || args.IsArgSet("-version")) {
5454
// First part of help message is specific to this utility
5555
std::string strUsage = PACKAGE_NAME " bitcoin-util utility version " + FormatFullVersion() + "\n";
56-
if (!gArgs.IsArgSet("-version")) {
56+
if (!args.IsArgSet("-version")) {
5757
strUsage += "\n"
5858
"Usage: bitcoin-util [options] [commands] Do stuff\n";
59-
strUsage += "\n" + gArgs.GetHelpMessage();
59+
strUsage += "\n" + args.GetHelpMessage();
6060
}
6161

6262
tfm::format(std::cout, "%s", strUsage);
@@ -70,7 +70,7 @@ static int AppInitUtil(int argc, char* argv[])
7070

7171
// Check for chain settings (Params() calls are only valid after this clause)
7272
try {
73-
SelectParams(gArgs.GetChainName());
73+
SelectParams(args.GetChainName());
7474
} catch (const std::exception& e) {
7575
tfm::format(std::cerr, "Error: %s\n", e.what());
7676
return EXIT_FAILURE;
@@ -151,12 +151,14 @@ __declspec(dllexport) int main(int argc, char* argv[])
151151
int main(int argc, char* argv[])
152152
#endif
153153
{
154+
ArgsManager& args = gArgs;
154155
SetupEnvironment();
155156

156157
try {
157-
int ret = AppInitUtil(argc, argv);
158-
if (ret != CONTINUE_EXECUTION)
158+
int ret = AppInitUtil(args, argc, argv);
159+
if (ret != CONTINUE_EXECUTION) {
159160
return ret;
161+
}
160162
} catch (const std::exception& e) {
161163
PrintExceptionContinue(&e, "AppInitUtil()");
162164
return EXIT_FAILURE;
@@ -165,7 +167,7 @@ int main(int argc, char* argv[])
165167
return EXIT_FAILURE;
166168
}
167169

168-
const auto cmd = gArgs.GetCommand();
170+
const auto cmd = args.GetCommand();
169171
if (!cmd) {
170172
tfm::format(std::cerr, "Error: must specify a command\n");
171173
return EXIT_FAILURE;

0 commit comments

Comments
 (0)