Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit 0414492

Browse files
committed
Reformat program_options setup code with clang-format
1 parent 8a0f6ad commit 0414492

File tree

5 files changed

+891
-830
lines changed

5 files changed

+891
-830
lines changed

eth/main.cpp

Lines changed: 106 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -281,77 +281,125 @@ int main(int argc, char** argv)
281281
string genesisJSON;
282282

283283
po::options_description clientDefaultMode("Client mode (default)", c_lineWidth);
284-
clientDefaultMode.add_options()
285-
("mainnet", "Use the main network protocol.")
286-
("ropsten", "Use the Ropsten testnet.")
287-
("private", po::value<string>()->value_name("<name>"), "Use a private chain.")
288-
("test", "Testing mode: Disable PoW and provide test rpc interface.")
289-
("config", po::value<string>()->value_name("<file>"), "Configure specialised blockchain using given JSON information.\n")
290-
("genesis", po::value<string>()->value_name("<file>"), "Set genesis JSON file.")
291-
("mode,o", po::value<string>()->value_name("<full/peer>"), "Start a full node or a peer node (default: full).\n")
292-
("ipc", "Enable IPC server (default: on).")
293-
("ipcpath", po::value<string>()->value_name("<path>"), "Set .ipc socket path (default: data directory)")
294-
("no-ipc", "Disable IPC server.")
295-
("admin", po::value<string>()->value_name("<password>"), "Specify admin session key for JSON-RPC (default: auto-generated and printed at start-up).")
296-
("kill,K", "Kill the blockchain first.")
297-
("rebuild,R", "Rebuild the blockchain from the existing database.")
298-
("rescue", "Attempt to rescue a corrupt database.\n")
299-
("import-presale", po::value<string>()->value_name("<file>"), "Import a pre-sale key; you'll need to specify the password to this key.")
300-
("import-secret,s", po::value<string>()->value_name("<secret>"), "Import a secret key into the key store.")
301-
("import-session-secret,S", po::value<string>()->value_name("<secret>"), "Import a secret session into the key store.")
302-
("master", po::value<string>()->value_name("<password>"), "Give the master password for the key store. Use --master \"\" to show a prompt.")
303-
("password", po::value<string>()->value_name("<password>"), "Give a password for a private key.\n");
284+
auto addClientOption = clientDefaultMode.add_options();
285+
addClientOption("mainnet", "Use the main network protocol.");
286+
addClientOption("ropsten", "Use the Ropsten testnet.");
287+
addClientOption("private", po::value<string>()->value_name("<name>"), "Use a private chain.");
288+
addClientOption("test", "Testing mode: Disable PoW and provide test rpc interface.");
289+
addClientOption("config", po::value<string>()->value_name("<file>"),
290+
"Configure specialised blockchain using given JSON information.\n");
291+
addClientOption("genesis", po::value<string>()->value_name("<file>"), "Set genesis JSON file.");
292+
addClientOption("mode,o", po::value<string>()->value_name("<full/peer>"),
293+
"Start a full node or a peer node (default: full).\n");
294+
addClientOption("ipc", "Enable IPC server (default: on).");
295+
addClientOption("ipcpath", po::value<string>()->value_name("<path>"),
296+
"Set .ipc socket path (default: data directory)");
297+
addClientOption("no-ipc", "Disable IPC server.");
298+
addClientOption("admin", po::value<string>()->value_name("<password>"),
299+
"Specify admin session key for JSON-RPC (default: auto-generated and printed at "
300+
"start-up).");
301+
addClientOption("kill,K", "Kill the blockchain first.");
302+
addClientOption("rebuild,R", "Rebuild the blockchain from the existing database.");
303+
addClientOption("rescue", "Attempt to rescue a corrupt database.\n");
304+
addClientOption("import-presale", po::value<string>()->value_name("<file>"),
305+
"Import a pre-sale key; you'll need to specify the password to this key.");
306+
addClientOption("import-secret,s", po::value<string>()->value_name("<secret>"),
307+
"Import a secret key into the key store.");
308+
addClientOption("import-session-secret,S", po::value<string>()->value_name("<secret>"),
309+
"Import a secret session into the key store.");
310+
addClientOption("master", po::value<string>()->value_name("<password>"),
311+
"Give the master password for the key store. Use --master \"\" to show a prompt.");
312+
addClientOption("password", po::value<string>()->value_name("<password>"),
313+
"Give a password for a private key.\n");
304314

305315
po::options_description clientTransacting("Client transacting", c_lineWidth);
306-
clientTransacting.add_options()
307-
("ask", po::value<u256>()->value_name("<wei>"), ("Set the minimum ask gas price under which no transaction will be mined\n(default " + toString(DefaultGasPrice) + ").").c_str())
308-
("bid", po::value<u256>()->value_name("<wei>"), ("Set the bid gas price to pay for transactions\n(default " + toString(DefaultGasPrice) + ").").c_str())
309-
("unsafe-transactions", "Allow all transactions to proceed without verification. EXTREMELY UNSAFE.\n");
316+
auto addTransactingOption = clientTransacting.add_options();
317+
addTransactingOption("ask", po::value<u256>()->value_name("<wei>"),
318+
("Set the minimum ask gas price under which no transaction will be mined\n(default " +
319+
toString(DefaultGasPrice) + ").")
320+
.c_str());
321+
addTransactingOption("bid", po::value<u256>()->value_name("<wei>"),
322+
("Set the bid gas price to pay for transactions\n(default " + toString(DefaultGasPrice) +
323+
").")
324+
.c_str());
325+
addTransactingOption("unsafe-transactions",
326+
"Allow all transactions to proceed without verification. EXTREMELY UNSAFE.\n");
310327

311328
po::options_description clientMining("Client mining", c_lineWidth);
312-
clientMining.add_options()
313-
("address,a", po::value<Address>()->value_name("<addr>"), "Set the author (mining payout) address to given address (default: auto).")
314-
("mining,m", po::value<string>()->value_name("<on/off/number>"), "Enable mining, optionally for a specified number of blocks (default: off).")
315-
("extra-data", po::value<string>(), "Set extra data for the sealed blocks.\n");
329+
auto addMininigOption = clientMining.add_options();
330+
addMininigOption("address,a", po::value<Address>()->value_name("<addr>"),
331+
"Set the author (mining payout) address to given address (default: auto).");
332+
addMininigOption("mining,m", po::value<string>()->value_name("<on/off/number>"),
333+
"Enable mining, optionally for a specified number of blocks (default: off).");
334+
addMininigOption("extra-data", po::value<string>(), "Set extra data for the sealed blocks.\n");
316335

317336
po::options_description clientNetworking("Client networking", c_lineWidth);
318-
clientNetworking.add_options()
319-
("bootstrap,b", "Connect to the default Ethereum peer servers (default unless --no-discovery used).")
320-
("no-bootstrap", "Do not connect to the default Ethereum peer servers (default only when --no-discovery is used).")
321-
("peers,x", po::value<int>()->value_name("<number>"), "Attempt to connect to a given number of peers (default: 11).")
322-
("peer-stretch", po::value<int>()->value_name("<number>"), "Give the accepted connection multiplier (default: 7).")
323-
("public-ip", po::value<string>()->value_name("<ip>"), "Force advertised public IP to the given IP (default: auto).")
324-
("listen-ip", po::value<string>()->value_name("<ip>(:<port>)"), "Listen on the given IP for incoming connections (default: 0.0.0.0).")
325-
("listen", po::value<unsigned short>()->value_name("<port>"), "Listen on the given port for incoming connections (default: 30303).")
326-
("remote,r", po::value<string>()->value_name("<host>(:<port>)"), "Connect to the given remote host (default: none).")
327-
("port", po::value<short>()->value_name("<port>"), "Connect to the given remote port (default: 30303).")
328-
("network-id", po::value<unsigned>()->value_name("<n>"), "Only connect to other hosts with this network id.")
337+
auto addNetworkingOption = clientNetworking.add_options();
338+
addNetworkingOption("bootstrap,b",
339+
"Connect to the default Ethereum peer servers (default unless --no-discovery used).");
340+
addNetworkingOption("no-bootstrap",
341+
"Do not connect to the default Ethereum peer servers (default only when --no-discovery is "
342+
"used).");
343+
addNetworkingOption("peers,x", po::value<int>()->value_name("<number>"),
344+
"Attempt to connect to a given number of peers (default: 11).");
345+
addNetworkingOption("peer-stretch", po::value<int>()->value_name("<number>"),
346+
"Give the accepted connection multiplier (default: 7).");
347+
addNetworkingOption("public-ip", po::value<string>()->value_name("<ip>"),
348+
"Force advertised public IP to the given IP (default: auto).");
349+
addNetworkingOption("listen-ip", po::value<string>()->value_name("<ip>(:<port>)"),
350+
"Listen on the given IP for incoming connections (default: 0.0.0.0).");
351+
addNetworkingOption("listen", po::value<unsigned short>()->value_name("<port>"),
352+
"Listen on the given port for incoming connections (default: 30303).");
353+
addNetworkingOption("remote,r", po::value<string>()->value_name("<host>(:<port>)"),
354+
"Connect to the given remote host (default: none).");
355+
addNetworkingOption("port", po::value<short>()->value_name("<port>"),
356+
"Connect to the given remote port (default: 30303).");
357+
addNetworkingOption("network-id", po::value<unsigned>()->value_name("<n>"),
358+
"Only connect to other hosts with this network id.");
329359
#if ETH_MINIUPNPC
330-
("upnp", po::value<string>()->value_name("<on/off>"), "Use UPnP for NAT (default: on).")
360+
addNetworkingOption(
361+
"upnp", po::value<string>()->value_name("<on/off>"), "Use UPnP for NAT (default: on).");
331362
#endif
332-
("peerset", po::value<string>()->value_name("<list>"), "Space delimited list of peers; element format: type:publickey@ipAddress[:port].\n Types:\n default Attempt connection when no other peers are available and pinning is disabled.\n required Keep connected at all times.\n")
333-
("no-discovery", "Disable node discovery, implies --no-bootstrap.")
334-
("pin", "Only accept or connect to trusted peers.");
363+
addNetworkingOption("peerset", po::value<string>()->value_name("<list>"),
364+
"Space delimited list of peers; element format: type:publickey@ipAddress[:port].\n "
365+
"Types:\n default Attempt connection when no other peers are available and "
366+
"pinning is disabled.\n required Keep connected at all times.\n");
367+
addNetworkingOption("no-discovery", "Disable node discovery, implies --no-bootstrap.");
368+
addNetworkingOption("pin", "Only accept or connect to trusted peers.");
335369

336370
std::string snapshotPath;
337371
po::options_description importExportMode("Import/export modes", c_lineWidth);
338-
importExportMode.add_options()
339-
("import,I", po::value<string>()->value_name("<file>"), "Import blocks from file.")
340-
("export,E", po::value<string>()->value_name("<file>"), "Export blocks to file.")
341-
("from", po::value<string>()->value_name("<n>"), "Export only from block n; n may be a decimal, a '0x' prefixed hash, or 'latest'.")
342-
("to", po::value<string>()->value_name("<n>"), "Export only to block n (inclusive); n may be a decimal, a '0x' prefixed hash, or 'latest'.")
343-
("only", po::value<string>()->value_name("<n>"), "Equivalent to --export-from n --export-to n.")
344-
("format", po::value<string>()->value_name("<binary/hex/human>"), "Set export format.")
345-
("dont-check", "Prevent checking some block aspects. Faster importing, but to apply only when the data is known to be valid.")
346-
("download-snapshot", po::value<string>(&snapshotPath)->value_name("<path>"), "Download Parity Warp Sync snapshot data to the specified path.")
347-
("import-snapshot", po::value<string>()->value_name("<path>"), "Import blockchain and state data from the Parity Warp Sync snapshot.\n");
372+
auto addImportExportOption = importExportMode.add_options();
373+
addImportExportOption(
374+
"import,I", po::value<string>()->value_name("<file>"), "Import blocks from file.");
375+
addImportExportOption(
376+
"export,E", po::value<string>()->value_name("<file>"), "Export blocks to file.");
377+
addImportExportOption("from", po::value<string>()->value_name("<n>"),
378+
"Export only from block n; n may be a decimal, a '0x' prefixed hash, or 'latest'.");
379+
addImportExportOption("to", po::value<string>()->value_name("<n>"),
380+
"Export only to block n (inclusive); n may be a decimal, a '0x' prefixed hash, or "
381+
"'latest'.");
382+
addImportExportOption("only", po::value<string>()->value_name("<n>"),
383+
"Equivalent to --export-from n --export-to n.");
384+
addImportExportOption(
385+
"format", po::value<string>()->value_name("<binary/hex/human>"), "Set export format.");
386+
addImportExportOption("dont-check",
387+
"Prevent checking some block aspects. Faster importing, but to apply only when the data is "
388+
"known to be valid.");
389+
addImportExportOption("download-snapshot",
390+
po::value<string>(&snapshotPath)->value_name("<path>"),
391+
"Download Parity Warp Sync snapshot data to the specified path.");
392+
addImportExportOption("import-snapshot", po::value<string>()->value_name("<path>"),
393+
"Import blockchain and state data from the Parity Warp Sync snapshot.\n");
348394

349395
po::options_description generalOptions("General Options", c_lineWidth);
350-
generalOptions.add_options()
351-
("db-path,d", po::value<string>()->value_name("<path>"), ("Load database from path\n(default: " + getDataDir().string() + ").\n").c_str())
352-
("verbosity,v", po::value<int>()->value_name("<0 - 9>"), "Set the log verbosity from 0 to 9 (default: 8).")
353-
("version,V", "Show the version and exit.")
354-
("help,h", "Show this help message and exit.\n");
396+
auto addGeneralOption = generalOptions.add_options();
397+
addGeneralOption("db-path,d", po::value<string>()->value_name("<path>"),
398+
("Load database from path\n(default: " + getDataDir().string() + ").\n").c_str());
399+
addGeneralOption("verbosity,v", po::value<int>()->value_name("<0 - 9>"),
400+
"Set the log verbosity from 0 to 9 (default: 8).");
401+
addGeneralOption("version,V", "Show the version and exit.");
402+
addGeneralOption("help,h", "Show this help message and exit.\n");
355403

356404

357405
po::options_description allowedOptions("Allowed options");

ethkey/main.cpp

Lines changed: 62 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/*
2-
This file is part of cpp-ethereum.
2+
This file is part of cpp-ethereum.
33
4-
cpp-ethereum is free software: you can redistribute it and/or modify
5-
it under the terms of the GNU General Public License as published by
6-
the Free Software Foundation, either version 3 of the License, or
7-
(at your option) any later version.
8-
cpp-ethereum is distributed in the hope that it will be useful,
9-
but WITHOUT ANY WARRANTY; without even the implied warranty of
10-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11-
GNU General Public License for more details.
4+
cpp-ethereum is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
cpp-ethereum is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
1212
13-
You should have received a copy of the GNU General Public License
14-
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
13+
You should have received a copy of the GNU General Public License
14+
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
1515
*/
1616
/** @file main.cpp
1717
* @author Gav Wood <i@gavwood.com>
@@ -37,9 +37,9 @@ namespace po = boost::program_options;
3737

3838
void version()
3939
{
40-
cout << "ethkey version " << dev::Version << endl;
41-
cout << "Build: " << DEV_QUOTED(ETH_BUILD_PLATFORM) << "/" << DEV_QUOTED(ETH_BUILD_TYPE) << endl;
42-
exit(0);
40+
cout << "ethkey version " << dev::Version << endl;
41+
cout << "Build: " << DEV_QUOTED(ETH_BUILD_PLATFORM) << "/" << DEV_QUOTED(ETH_BUILD_TYPE) << endl;
42+
exit(0);
4343
}
4444

4545
/*
@@ -58,61 +58,62 @@ that users do not need to install language packs for their OS.
5858
void setDefaultOrCLocale()
5959
{
6060
#if __unix__
61-
if (!std::setlocale(LC_ALL, ""))
62-
{
63-
setenv("LC_ALL", "C", 1);
64-
}
61+
if (!std::setlocale(LC_ALL, ""))
62+
{
63+
setenv("LC_ALL", "C", 1);
64+
}
6565
#endif
6666
}
6767

6868
int main(int argc, char** argv)
6969
{
70-
setDefaultOrCLocale();
71-
KeyCLI m(KeyCLI::OperationMode::ListBare);
72-
g_logVerbosity = 0;
73-
po::options_description generalOptions("General Options");
74-
generalOptions.add_options()
75-
("verbosity,v", po::value<int>()->value_name("<0 - 9>"), "Set the log verbosity from 0 to 9 (default: 8).")
76-
("version,V", "Show the version and exit.")
77-
("help,h", "Show this help message and exit.");
70+
setDefaultOrCLocale();
71+
KeyCLI m(KeyCLI::OperationMode::ListBare);
72+
g_logVerbosity = 0;
73+
po::options_description generalOptions("General Options");
74+
auto addOption = generalOptions.add_options();
75+
addOption("verbosity,v", po::value<int>()->value_name("<0 - 9>"),
76+
"Set the log verbosity from 0 to 9 (default: 8).");
77+
addOption("version,V", "Show the version and exit.");
78+
addOption("help,h", "Show this help message and exit.");
7879

79-
po::variables_map vm;
80-
vector<string> unrecognisedOptions;
81-
try
82-
{
83-
po::parsed_options parsed = po::command_line_parser(argc, argv).options(generalOptions).allow_unregistered().run();
84-
unrecognisedOptions = collect_unrecognized(parsed.options, po::include_positional);
85-
po::store(parsed, vm);
86-
po::notify(vm);
87-
}
88-
catch (po::error const& e)
89-
{
90-
cerr << e.what();
91-
return -1;
92-
}
80+
po::variables_map vm;
81+
vector<string> unrecognisedOptions;
82+
try
83+
{
84+
po::parsed_options parsed = po::command_line_parser(argc, argv).options(generalOptions).allow_unregistered().run();
85+
unrecognisedOptions = collect_unrecognized(parsed.options, po::include_positional);
86+
po::store(parsed, vm);
87+
po::notify(vm);
88+
}
89+
catch (po::error const& e)
90+
{
91+
cerr << e.what();
92+
return -1;
93+
}
9394

94-
for (size_t i = 0; i < unrecognisedOptions.size(); ++i)
95-
if (!m.interpretOption(i, unrecognisedOptions))
96-
{
97-
cerr << "Invalid argument: " << unrecognisedOptions[i] << endl;
98-
return -1;
99-
}
95+
for (size_t i = 0; i < unrecognisedOptions.size(); ++i)
96+
if (!m.interpretOption(i, unrecognisedOptions))
97+
{
98+
cerr << "Invalid argument: " << unrecognisedOptions[i] << endl;
99+
return -1;
100+
}
100101

101-
if (vm.count("help"))
102-
{
103-
cout
104-
<< "Usage ethkey [OPTIONS]" << endl
105-
<< "Options:" << endl << endl;
106-
KeyCLI::streamHelp(cout);
107-
cout << generalOptions;
108-
return 0;
109-
}
110-
if (vm.count("version"))
111-
version();
112-
if (vm.count("verbosity"))
113-
g_logVerbosity = vm["verbosity"].as<int>();
102+
if (vm.count("help"))
103+
{
104+
cout
105+
<< "Usage ethkey [OPTIONS]" << endl
106+
<< "Options:" << endl << endl;
107+
KeyCLI::streamHelp(cout);
108+
cout << generalOptions;
109+
return 0;
110+
}
111+
if (vm.count("version"))
112+
version();
113+
if (vm.count("verbosity"))
114+
g_logVerbosity = vm["verbosity"].as<int>();
114115

115-
m.execute();
116+
m.execute();
116117

117-
return 0;
118+
return 0;
118119
}

0 commit comments

Comments
 (0)