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.
| 124 | // CONTINUE_EXECUTION when it's expected to continue further. |
| 125 | // |
| 126 | static int AppInitRPC(int argc, char* argv[]) |
| 127 | { |
| 128 | SetupCliArgs(gArgs); |
| 129 | std::string error; |
| 130 | if (!gArgs.ParseParameters(argc, argv, error)) { |
| 131 | tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error); |
| 132 | return EXIT_FAILURE; |
| 133 | } |
| 134 | if (argc < 2 || HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { |
| 135 | std::string strUsage = PACKAGE_NAME " RPC client version " + FormatFullVersion() + "\n"; |
| 136 | |
| 137 | if (gArgs.IsArgSet("-version")) { |
| 138 | strUsage += FormatParagraph(LicenseInfo()); |
| 139 | } else { |
| 140 | strUsage += "\n" |
| 141 | "Usage: elements-cli [options] <command> [params] Send command to " PACKAGE_NAME "\n" |
| 142 | "or: elements-cli [options] -named <command> [name=value]... Send command to " PACKAGE_NAME " (with named arguments)\n" |
| 143 | "or: elements-cli [options] help List commands\n" |
| 144 | "or: elements-cli [options] help <command> Get help for a command\n"; |
| 145 | strUsage += "\n" + gArgs.GetHelpMessage(); |
| 146 | } |
| 147 | |
| 148 | tfm::format(std::cout, "%s", strUsage); |
| 149 | if (argc < 2) { |
| 150 | tfm::format(std::cerr, "Error: too few parameters\n"); |
| 151 | return EXIT_FAILURE; |
| 152 | } |
| 153 | return EXIT_SUCCESS; |
| 154 | } |
| 155 | if (!CheckDataDirOption()) { |
| 156 | tfm::format(std::cerr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "")); |
| 157 | return EXIT_FAILURE; |
| 158 | } |
| 159 | if (!gArgs.ReadConfigFiles(error, true)) { |
| 160 | tfm::format(std::cerr, "Error reading configuration file: %s\n", error); |
| 161 | return EXIT_FAILURE; |
| 162 | } |
| 163 | // Check for chain settings (BaseParams() calls are only valid after this clause) |
| 164 | try { |
| 165 | SelectBaseParams(gArgs.GetChainName()); |
| 166 | } catch (const std::exception& e) { |
| 167 | tfm::format(std::cerr, "Error: %s\n", e.what()); |
| 168 | return EXIT_FAILURE; |
| 169 | } |
| 170 | return CONTINUE_EXECUTION; |
| 171 | } |
| 172 | |
| 173 | |
| 174 | /** Reply structure for request_done to fill in */ |
no test coverage detected