| 170 | } |
| 171 | |
| 172 | bool CommonOptions::parse(int argc, char const* const* argv) |
| 173 | { |
| 174 | po::variables_map arguments; |
| 175 | addOptions(); |
| 176 | |
| 177 | try |
| 178 | { |
| 179 | po::command_line_parser cmdLineParser(argc, argv); |
| 180 | cmdLineParser.options(options); |
| 181 | auto parsedOptions = cmdLineParser.run(); |
| 182 | po::store(parsedOptions, arguments); |
| 183 | po::notify(arguments); |
| 184 | if (arguments.count("eof-version")) |
| 185 | { |
| 186 | // Request as uint64_t, since uint8_t will be parsed as character by boost. |
| 187 | uint64_t eofVersion = arguments["eof-version"].as<uint64_t>(); |
| 188 | if (eofVersion != 1) |
| 189 | BOOST_THROW_EXCEPTION(std::runtime_error("Invalid EOF version: " + std::to_string(eofVersion))); |
| 190 | m_eofVersion = 1; |
| 191 | } |
| 192 | |
| 193 | for (auto const& parsedOption: parsedOptions.options) |
| 194 | if (parsedOption.position_key >= 0) |
| 195 | { |
| 196 | if ( |
| 197 | parsedOption.original_tokens.empty() || |
| 198 | (parsedOption.original_tokens.size() == 1 && parsedOption.original_tokens.front().empty()) |
| 199 | ) |
| 200 | continue; // ignore empty options |
| 201 | std::stringstream errorMessage; |
| 202 | errorMessage << "Unrecognized option: "; |
| 203 | for (auto const& token: parsedOption.original_tokens) |
| 204 | errorMessage << token; |
| 205 | BOOST_THROW_EXCEPTION(std::runtime_error(errorMessage.str())); |
| 206 | } |
| 207 | } |
| 208 | catch (po::error const& exception) |
| 209 | { |
| 210 | solThrow(ConfigException, exception.what()); |
| 211 | } |
| 212 | |
| 213 | if (vmPaths.empty()) |
| 214 | { |
| 215 | if (auto envPath = getenv("ETH_EVMONE")) |
| 216 | vmPaths.emplace_back(envPath); |
| 217 | else if (auto repoPath = findInDefaultPath(evmoneFilename)) |
| 218 | vmPaths.emplace_back(*repoPath); |
| 219 | else |
| 220 | vmPaths.emplace_back(evmoneFilename); |
| 221 | } |
| 222 | |
| 223 | return true; |
| 224 | } |
| 225 | |
| 226 | std::string CommonOptions::toString(std::vector<std::string> const& _selectedOptions) const |
| 227 | { |