Better command line argument handling #3628#4597
Better command line argument handling #3628#4597demon1999 wants to merge 14 commits intoethereum:developfrom
Conversation
|
Thanks a lot for your work! I'll try to look at it next week. You could rebase it on the latest develop and resolve conflicts meanwhile. |
|
@demon1999 are you still around? |
|
Yes, I am. Now I'm reading about rebase. |
|
@demon1999 it would be better to split this PR into smaller parts. Can you make one that adds only boost program_options first. Then a PR that converts options for one of the smaller tools like rlp or ethvm. |
|
right. it is better to be done module by module. Id like to test testeth options first. |
|
Ок, I'll do it when I'll have time. |
|
Hi again. |
eth/AccountManager.cpp
Outdated
| #include <libdevcore/FileSystem.h> | ||
| #include <libdevcore/CommonIO.h> | ||
| #include <libethcore/KeyManager.h> | ||
| #include <boost/program_options.hpp> |
There was a problem hiding this comment.
Are these includes needed? Only includes are added to this file and nothing else.
There was a problem hiding this comment.
I think, I don't need it.
eth/main.cpp
Outdated
| ("private", po::value<string>(), "<name> Use a private chain.") | ||
| ("test", "Testing mode: Disable PoW and provide test rpc interface.") | ||
| ("config", po::value<string>(), "<file> Configure specialised blockchain using given JSON information.") | ||
| ("oppose-dao-fork", "Ignore DAO hard fork (default is to participate).\n") |
There was a problem hiding this comment.
This and -f options are not supported anymore.
Probably there're more outdated options, I'll take a closer look later
eth/main.cpp
Outdated
| ("address,a", po::value<string>(), "<addr> Set the author (mining payout) address to given address (default: auto).") | ||
| ("author", po::value<string>(), "<addr> Set the author (mining payout) address to given address (default: auto).") | ||
| ("mining,m", po::value<string>(), "<on/off/number> Enable mining, optionally for a specified number of blocks (default: off).") | ||
| ("force-mining,f", "Mine even when there are no transactions to mine (default: off).") |
There was a problem hiding this comment.
all this 4 options?
There was a problem hiding this comment.
Only -f & --force-mining
mining itself is still supported
eth/main.cpp
Outdated
| clientDefaultMode.add_options() | ||
| ("format", po::value<string>(), "<format> Set format.") | ||
| ("script", po::value<string>(), "<script> Add script.") | ||
| ("mainnet", "Use the main network protocol.") |
There was a problem hiding this comment.
Some lines are indented with spaces, please change to tabs everywhere
|
|
||
| add_executable(main rlp/main.cpp) | ||
|
|
||
| add_executable(peer test/unittests/libp2p/peer.cpp) |
| ("verbosity,v", po::value<string>(), "<0 - 9> Set the log verbosity from 0 to 9 (default: 8).") | ||
| ("version,V", "Show the version and exit.") | ||
| ("help,h", "Show this help message and exit.") | ||
| ; |
There was a problem hiding this comment.
This formatting looks weird in our style, please leave semicolon on the last line of the statement.
|
|
||
| po::options_description generalOptions("General Options"); | ||
| generalOptions.add_options() | ||
| ("verbosity,v", po::value<string>(), "<0 - 9> Set the log verbosity from 0 to 9 (default: 8).") |
There was a problem hiding this comment.
Couldn't we make it po::value<int> ?
|
|
||
| namespace po = boost::program_options; | ||
|
|
||
| void help() |
| help(); | ||
| else if (arg == "-V" || arg == "--version") | ||
| version(); | ||
| else if (((arg == "-v" || arg == "--verbosity") && i + 1 < argc) || arg == "-h" || arg == "--help" || arg == "-V" || arg == "--version") { |
There was a problem hiding this comment.
opening brace should be on a separate line
| else if (arg == "-V" || arg == "--version") | ||
| version(); | ||
| else if (((arg == "-v" || arg == "--verbosity") && i + 1 < argc) || arg == "-h" || arg == "--help" || arg == "-V" || arg == "--version") { | ||
| argv[ac] = argv[i]; |
There was a problem hiding this comment.
Could you explain what are you trying to achieve in this part?
I don't think assiging to argv is a very good idea
I think you're trying to get rid of all the options that are handled in KeyCLI::interpretOption() and leave only -v, -V, -h in argv
Why do you need this? Wouldn't po::store(po::parse_command_line(ac, argv, generalOptions), vm); below just ignore options not listed in generalOptions ?
There was a problem hiding this comment.
|
@demon1999 Are you still planning to update this PR or should we close this one and you will proceed with several smaller PRs? |
|
You should close it. One of small pr's is 4635 |
Resolves #3628