Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.
Merged
Prev Previous commit
Next Next commit
Remove "import" and "export" options (without dashes) and handle "--i…
…mport" and ""--export" as other regular options
  • Loading branch information
gumb0 committed Dec 12, 2017
commit 68be8c2b5cb2b9c811c8a8f1774bc60a9493c132
33 changes: 15 additions & 18 deletions eth/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ int main(int argc, char** argv)

po::options_description importExportMode("Import/export modes", c_lineWidth);
importExportMode.add_options()
("import,I", po::value<string>()->value_name("<file>"), "Import blocks from file.")
("export,E", po::value<string>()->value_name("<file>"), "Export blocks to file.")
("from", po::value<string>()->value_name("<n>"), "Export only from block n; n may be a decimal, a '0x' prefixed hash, or 'latest'.")
("to", po::value<string>()->value_name("<n>"), "Export only to block n (inclusive); n may be a decimal, a '0x' prefixed hash, or 'latest'.")
("only", po::value<string>()->value_name("<n>"), "Equivalent to --export-from n --export-to n.")
Expand Down Expand Up @@ -374,27 +376,12 @@ int main(int argc, char** argv)
return -1;
}
for (size_t i = 0; i < unrecognisedOptions.size(); ++i)
{
string arg = unrecognisedOptions[i];
if (m.interpretOption(i, unrecognisedOptions))
{
}
else if ((arg == "-I" || arg == "--import" || arg == "import") && i + 1 < unrecognisedOptions.size())
{
mode = OperationMode::Import;
filename = unrecognisedOptions[++i];
}
else if ((arg == "-E" || arg == "--export" || arg == "export") && i + 1 < unrecognisedOptions.size())
{
mode = OperationMode::Export;
filename = unrecognisedOptions[++i];
}
else
if (!m.interpretOption(i, unrecognisedOptions))
{
cerr << "Invalid argument: " << arg << "\n";
cerr << "Invalid argument: " << unrecognisedOptions[i] << "\n";
exit(-1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed one exit() here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}
}

#if ETH_EVMJIT
if (vm.count("vm"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't indent the following line with brace (and if body)

{
Expand Down Expand Up @@ -653,6 +640,16 @@ int main(int argc, char** argv)
{
remotePort = vm["port"].as<short>();
}
if (vm.count("import"))
{
mode = OperationMode::Import;
filename = vm["import"].as<string>();
}
if (vm.count("export"))
{
mode = OperationMode::Export;
filename = vm["export"].as<string>();
}
if (vm.count("password"))
passwordsToNote.push_back(vm["password"].as<string>());
if (vm.count("master"))
Expand Down