|
|
@ -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
|
|
|
|
// 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.
|
|
|
|
// 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;
|
|
|
|
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);
|
|
|
|
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
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
|
|
|
|
// First part of help message is specific to this utility
|
|
|
|
std::string strUsage = PACKAGE_NAME " bitcoin-util utility version " + FormatFullVersion() + "\n";
|
|
|
|
std::string strUsage = PACKAGE_NAME " bitcoin-util utility version " + FormatFullVersion() + "\n";
|
|
|
|
if (!gArgs.IsArgSet("-version")) {
|
|
|
|
if (!args.IsArgSet("-version")) {
|
|
|
|
strUsage += "\n"
|
|
|
|
strUsage += "\n"
|
|
|
|
"Usage: bitcoin-util [options] [commands] Do stuff\n";
|
|
|
|
"Usage: bitcoin-util [options] [commands] Do stuff\n";
|
|
|
|
strUsage += "\n" + gArgs.GetHelpMessage();
|
|
|
|
strUsage += "\n" + args.GetHelpMessage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tfm::format(std::cout, "%s", strUsage);
|
|
|
|
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)
|
|
|
|
// Check for chain settings (Params() calls are only valid after this clause)
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
SelectParams(gArgs.GetChainName());
|
|
|
|
SelectParams(args.GetChainName());
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
tfm::format(std::cerr, "Error: %s\n", e.what());
|
|
|
|
tfm::format(std::cerr, "Error: %s\n", e.what());
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
@ -151,12 +151,14 @@ __declspec(dllexport) int main(int argc, char* argv[])
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
ArgsManager& args = gArgs;
|
|
|
|
SetupEnvironment();
|
|
|
|
SetupEnvironment();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
int ret = AppInitUtil(argc, argv);
|
|
|
|
int ret = AppInitUtil(args, argc, argv);
|
|
|
|
if (ret != CONTINUE_EXECUTION)
|
|
|
|
if (ret != CONTINUE_EXECUTION) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
PrintExceptionContinue(&e, "AppInitUtil()");
|
|
|
|
PrintExceptionContinue(&e, "AppInitUtil()");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
@ -165,7 +167,7 @@ int main(int argc, char* argv[])
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const auto cmd = gArgs.GetCommand();
|
|
|
|
const auto cmd = args.GetCommand();
|
|
|
|
if (!cmd) {
|
|
|
|
if (!cmd) {
|
|
|
|
tfm::format(std::cerr, "Error: must specify a command\n");
|
|
|
|
tfm::format(std::cerr, "Error: must specify a command\n");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
return EXIT_FAILURE;
|
|
|
|