@@ -41,22 +41,22 @@ static void SetupBitcoinUtilArgs(ArgsManager &argsman)
41
41
42
42
// This function returns either one of EXIT_ codes when it's expected to stop the process or
43
43
// 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[])
45
45
{
46
- SetupBitcoinUtilArgs (gArgs );
46
+ SetupBitcoinUtilArgs (args );
47
47
std::string error;
48
- if (!gArgs .ParseParameters (argc, argv, error)) {
48
+ if (!args .ParseParameters (argc, argv, error)) {
49
49
tfm::format (std::cerr, " Error parsing command line arguments: %s\n " , error);
50
50
return EXIT_FAILURE;
51
51
}
52
52
53
- if (HelpRequested (gArgs ) || gArgs .IsArgSet (" -version" )) {
53
+ if (HelpRequested (args ) || args .IsArgSet (" -version" )) {
54
54
// First part of help message is specific to this utility
55
55
std::string strUsage = PACKAGE_NAME " bitcoin-util utility version " + FormatFullVersion () + " \n " ;
56
- if (!gArgs .IsArgSet (" -version" )) {
56
+ if (!args .IsArgSet (" -version" )) {
57
57
strUsage += " \n "
58
58
" Usage: bitcoin-util [options] [commands] Do stuff\n " ;
59
- strUsage += " \n " + gArgs .GetHelpMessage ();
59
+ strUsage += " \n " + args .GetHelpMessage ();
60
60
}
61
61
62
62
tfm::format (std::cout, " %s" , strUsage);
@@ -70,7 +70,7 @@ static int AppInitUtil(int argc, char* argv[])
70
70
71
71
// Check for chain settings (Params() calls are only valid after this clause)
72
72
try {
73
- SelectParams (gArgs .GetChainName ());
73
+ SelectParams (args .GetChainName ());
74
74
} catch (const std::exception& e) {
75
75
tfm::format (std::cerr, " Error: %s\n " , e.what ());
76
76
return EXIT_FAILURE;
@@ -151,12 +151,14 @@ __declspec(dllexport) int main(int argc, char* argv[])
151
151
int main (int argc, char * argv[])
152
152
#endif
153
153
{
154
+ ArgsManager& args = gArgs ;
154
155
SetupEnvironment ();
155
156
156
157
try {
157
- int ret = AppInitUtil (argc, argv);
158
- if (ret != CONTINUE_EXECUTION)
158
+ int ret = AppInitUtil (args, argc, argv);
159
+ if (ret != CONTINUE_EXECUTION) {
159
160
return ret;
161
+ }
160
162
} catch (const std::exception& e) {
161
163
PrintExceptionContinue (&e, " AppInitUtil()" );
162
164
return EXIT_FAILURE;
@@ -165,7 +167,7 @@ int main(int argc, char* argv[])
165
167
return EXIT_FAILURE;
166
168
}
167
169
168
- const auto cmd = gArgs .GetCommand ();
170
+ const auto cmd = args .GetCommand ();
169
171
if (!cmd) {
170
172
tfm::format (std::cerr, " Error: must specify a command\n " );
171
173
return EXIT_FAILURE;
0 commit comments